Fix gaps between lines in HTML export in Chrome/Firefox on Ubuntu

This is dependent on the font.
In both Chrome/Firefox, monospace uses "DejaVu Sans Mono" on my system,
but if I specify "DejaVu Sans Mono" explicitly, it uses a larger
font size (16px, as compared to 12px in Firefox or 13px in Chrome), and
slight gaps are visible.

This fixes a regression when switching over to the Rich API's built-in
HTML exporting — from where I'm sitting — but it may look totally
different on someone else's computer.
This commit is contained in:
Isaiah Odhner 2023-05-03 12:06:53 -04:00
parent b4af4032f7
commit 4f4a65c6fe

View File

@ -625,7 +625,7 @@ CUSTOM_CONSOLE_SVG_FORMAT = """\
</svg>
"""
CONSOLE_HTML_FORMAT = """\
CUSTOM_CONSOLE_HTML_FORMAT = """\
<!DOCTYPE html>
<head>
<meta charset="UTF-8">
@ -639,7 +639,7 @@ body {{
</head>
<html>
<body>
<pre style="font-family:Menlo,'DejaVu Sans Mono',consolas,'Courier New',monospace"><code>{code}</code></pre>
<pre style="font-family:monospace;line-height:1"><code>{code}</code></pre>
</body>
</html>
"""
@ -741,7 +741,7 @@ class AnsiArtDocument:
def get_html(self) -> str:
"""Get the HTML representation of the document."""
console = self.get_console()
return console.export_html(code_format=CONSOLE_HTML_FORMAT)
return console.export_html(code_format=CUSTOM_CONSOLE_HTML_FORMAT)
def get_svg(self) -> str:
"""Get the SVG representation of the document."""