diff --git a/paint.py b/paint.py index f3eed82..12b5061 100755 --- a/paint.py +++ b/paint.py @@ -607,14 +607,69 @@ class AnsiArtDocument: text += "\n" return text - def get_html(self) -> str: - """Get the HTML representation of the document.""" + def get_pre_inner_xhtml(self) -> str: + """Get an XHTML snippet which should be placed in a
 tag."""
         html = ""
         for y in range(self.height):
             for x in range(self.width):
                 html += "" + self.ch[y][x] + ""
-            html += "
" + html += "
" return html + + def get_html(self) -> str: + """Get the HTML representation of the document.""" + return """ + + + + + + +
""" + self.get_pre_inner_xhtml() + """
+ + +""" + + def get_svg(self) -> str: + """Get the SVG representation of the document.""" + css = """ +div, +pre { + overflow: hidden; + margin: 0; + padding: 0; +} +svg { + font: 10px monospace; + line-height: 1; +} +span, +font { + display: inline-block; +} +""" + svg = f""" + + + +
+
{self.get_pre_inner_xhtml()}
+
+
+
+""" + return svg @staticmethod def from_ascii(text: str, default_bg: str = "#ffffff", default_fg: str = "#000000") -> 'AnsiArtDocument':