Skip to content
Snippets Groups Projects
Commit a3277117 authored by Richard Berger's avatar Richard Berger
Browse files

Add filter which merges preformatted sections

parent 67d4c076
No related branches found
No related tags found
No related merge requests found
......@@ -90,3 +90,24 @@ def promote_doc_keywords(content):
def filter_multiple_horizontal_rules(content):
return re.sub(r"----------[\s\n]+----------", '', content)
def merge_preformatted_sections(content):
mergable_section_pattern = re.compile(r"\.\. parsed-literal::\n"
r"\n"
r"(?P<listingA>(( [^\n]+\n)|(^\n))+)\n\s*"
r"^\.\. parsed-literal::\n"
r"\n"
r"(?P<listingB>(( [^\n]+\n)|(^\n))+)\n", re.MULTILINE | re.DOTALL)
m = mergable_section_pattern.search(content)
while m:
content = mergable_section_pattern.sub(r".. parsed-literal::\n"
r"\n"
r"\g<listingA>"
r"\g<listingB>"
r"\n", content)
m = mergable_section_pattern.search(content)
return content
......@@ -359,6 +359,7 @@ class Txt2Rst(TxtParser):
self.document_filters.append(lammps_filters.detect_and_add_command_to_index)
self.document_filters.append(lammps_filters.filter_multiple_horizontal_rules)
self.document_filters.append(lammps_filters.promote_doc_keywords)
self.document_filters.append(lammps_filters.merge_preformatted_sections)
def is_ignored_textblock_begin(self, line):
return line.startswith('<!-- HTML_ONLY -->')
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment