From dd45068ffe2132abdc1c244a0e7c5e4d642e317c Mon Sep 17 00:00:00 2001 From: Robin Schneider Date: Fri, 8 Jul 2016 20:10:48 +0200 Subject: [PATCH] Expose `strip_regex` for `convert_file` and `convert_text`. Related to: https://github.com/htgoebel/yaml2rst/pull/3 `convert_file` is used in https://github.com/debops/docs --- yaml2rst.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/yaml2rst.py b/yaml2rst.py index 1d6fc05..ab072cc 100644 --- a/yaml2rst.py +++ b/yaml2rst.py @@ -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)