This commit is contained in:
Stephen Simpson
2025-12-11 13:22:59 -06:00
parent 76fc2e9deb
commit b2ce978f84

View File

@@ -171,11 +171,27 @@ class ManPageConverter:
Returns: Returns:
Cleaned HTML Cleaned HTML
""" """
# Fix empty header cells
html = re.sub( html = re.sub(
r'<td class="head-(ltitle|rtitle)">\(\)</td>', r'<td class="head-(ltitle|rtitle)">\(\)</td>',
r'<td class="head-\1"></td>', r'<td class="head-\1"></td>',
html, html,
) )
# Remove empty <p class="Pp"></p> tags (from .sp directives in troff)
html = re.sub(r'<p class="Pp">\s*</p>', '', html)
# Clean up trailing whitespace and br tags in pre blocks
# Match: <pre>...</pre> and clean trailing <br/> followed by whitespace
def clean_pre_block(match):
content = match.group(1)
# Remove trailing <br/> tags and whitespace before closing </pre>
content = re.sub(r'<br\s*/>\s*$', '', content)
content = re.sub(r'\s+$', '', content)
return f'<pre>{content}</pre>'
html = re.sub(r'<pre>(.*?)</pre>', clean_pre_block, html, flags=re.DOTALL)
html = html.strip() html = html.strip()
return html return html