diff --git a/src/rocky_man/processor/converter.py b/src/rocky_man/processor/converter.py index 6d82920..c868055 100644 --- a/src/rocky_man/processor/converter.py +++ b/src/rocky_man/processor/converter.py @@ -171,11 +171,27 @@ class ManPageConverter: Returns: Cleaned HTML """ + # Fix empty header cells html = re.sub( r'\(\)', r'', html, ) + + # Remove empty

tags (from .sp directives in troff) + html = re.sub(r'

\s*

', '', html) + + # Clean up trailing whitespace and br tags in pre blocks + # Match:
...
and clean trailing
followed by whitespace + def clean_pre_block(match): + content = match.group(1) + # Remove trailing
tags and whitespace before closing + content = re.sub(r'\s*$', '', content) + content = re.sub(r'\s+$', '', content) + return f'
{content}
' + + html = re.sub(r'
(.*?)
', clean_pre_block, html, flags=re.DOTALL) + html = html.strip() return html