From afcedccba6c1dc376f4c5c6b20c0cacb02be6ea2 Mon Sep 17 00:00:00 2001 From: Isaiah Odhner Date: Tue, 2 May 2023 13:43:53 -0400 Subject: [PATCH] Use Rich API for HTML export This should handle escaping. --- src/textual_paint/paint.py | 35 +++-------------------------------- 1 file changed, 3 insertions(+), 32 deletions(-) diff --git a/src/textual_paint/paint.py b/src/textual_paint/paint.py index 0b772a0..eff2b80 100755 --- a/src/textual_paint/paint.py +++ b/src/textual_paint/paint.py @@ -696,40 +696,11 @@ class AnsiArtDocument: text += "\n" return text - 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 += "
" - return html - def get_html(self) -> str: """Get the HTML representation of the document.""" - return """ - - - - - - -
""" + self.get_pre_inner_xhtml() + """
- - -""" - + console = self.get_console() + return console.export_html() + def get_svg(self) -> str: """Get the SVG representation of the document.""" console = self.get_console()