Skip to content

Commit

Permalink
Merge pull request #5 from ypid/feature/expose-strip_regex
Browse files Browse the repository at this point in the history
Add optional param `strip_regex` for `convert_file` and `convert_text`.
  • Loading branch information
htgoebel authored Jul 10, 2016
2 parents 1253bc9 + dd45068 commit 95c87b5
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 95c87b5

Please sign in to comment.