forked from lijiext/lammps
Add filter which merges preformatted sections
This commit is contained in:
parent
67d4c07689
commit
a3277117e2
|
@ -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 -->')
|
||||
|
|
Loading…
Reference in New Issue