diff --git a/setup.py b/setup.py index 9afbbbf..1f4c724 100644 --- a/setup.py +++ b/setup.py @@ -4,7 +4,7 @@ setup( name="md2tgmd", - version="0.2.1", + version="0.2.2", description="md2tgmd is a Markdown to Telegram-specific-markdown converter.", long_description=Path.open(Path("README.md"), encoding="utf-8").read(), long_description_content_type="text/markdown", diff --git a/src/md2tgmd.py b/src/md2tgmd.py index 830533f..bc1359d 100644 --- a/src/md2tgmd.py +++ b/src/md2tgmd.py @@ -29,7 +29,7 @@ def replace_all(text, pattern, function): return ''.join(new_list) def escapeshape(text): - return '▎*' + " ".join(text.split()[1:]) + '*' + return '▎*' + " ".join(text.split()[1:]) + '*\n\n' def escapeminus(text): return '\\' + text @@ -101,7 +101,7 @@ def escape(text, flag=0): text = re.sub(r"\@{3}(.*?)\@{3}\^{3}(.*?)\^{3}", '[\\1](\\2)', text) text = re.sub(r"~", '\~', text) text = re.sub(r">", '\>', text) - text = replace_all(text, r"(^#+\s.+?$)|```[\D\d\s]+?```", escapeshape) + text = replace_all(text, r"(^#+\s.+?\n+)|```[\D\d\s]+?```", escapeshape) text = re.sub(r"#", '\#', text) text = replace_all(text, r"(\+)|\n[\s]*-\s|```[\D\d\s]+?```|`[\D\d\s]*?`", escapeplus) text = re.sub(r"\n{1,2}(\s*\d{1,2}\.\s)", '\n\n\\1', text) @@ -149,6 +149,7 @@ def escape(text, flag=0): ``` # bn + # b # Header