Skip to content

Commit

Permalink
Expose strip_regex for convert_file and convert_text.
Browse files Browse the repository at this point in the history
Related to: #3

`convert_file` is used in https://github.com/debops/docs
  • Loading branch information
ypid committed Jul 8, 2016
1 parent 1253bc9 commit dd45068
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions yaml2rst.py
Original file line number Diff line number Diff line change
Expand Up @@ -128,12 +128,12 @@ def convert(lines, strip_regex):
state = STATE_YAML


def convert_text(yaml_text):
return '\n'.join(convert(yaml_text.splitlines()))
def convert_text(yaml_text, strip_regex=None):
return '\n'.join(convert(yaml_text.splitlines(), strip_regex))


def convert_file(infilename, outfilename):
def convert_file(infilename, outfilename, strip_regex=None):
with open(infilename) as infh:
with open(outfilename, "w") as outfh:
for l in convert(infh.readlines()):
for l in convert(infh.readlines(), strip_regex):
print(l.rstrip(), file=outfh)

0 comments on commit dd45068

Please sign in to comment.