|
|
@ -1,4 +1,4 @@ |
|
|
|
from panflute import Cite, Emph, Image, LineBreak, Link, Math, Note, RawInline, SmallCaps, Str, Strikeout, Subscript, Superscript, Underline |
|
|
|
from panflute import Cite, Code, Emph, Image, LineBreak, Link, Math, Note, RawInline, SmallCaps, Str, Strikeout, Subscript, Superscript, Underline |
|
|
|
from panflute import BulletList, Citation, CodeBlock, Definition, DefinitionItem, DefinitionList, Header, HorizontalRule, LineBlock, LineItem, ListItem, Null, OrderedList, Para, Plain, RawBlock, TableBody, TableFoot, TableHead |
|
|
|
from panflute import TableRow, TableCell, Caption, Doc |
|
|
|
from panflute import ListContainer, Element |
|
|
@ -37,7 +37,7 @@ class HTMLGenerator(OutputGenerator): |
|
|
|
def escape_special_chars(self, text: str) -> str: |
|
|
|
text = text.replace("&", "&") |
|
|
|
text = text.replace("<", "<") |
|
|
|
text = text.replace(">", "&rt;") |
|
|
|
text = text.replace(">", ">") |
|
|
|
text = text.replace("\"", """) |
|
|
|
text = text.replace("'", "'") |
|
|
|
# text = text.replace(" ", " ") # Don't replace no-break spaces with HTML escapes, because we trust unicode? |
|
|
@ -125,8 +125,13 @@ class HTMLGenerator(OutputGenerator): |
|
|
|
result = highlight(e.text, lexer, formatter) |
|
|
|
self.writeraw(result) |
|
|
|
else: |
|
|
|
e.text = self.escape_special_chars(e.text) |
|
|
|
self.generate_simple_tag(e, tag="pre") |
|
|
|
|
|
|
|
def generate_Code(self, e: Code): |
|
|
|
e.text = self.escape_special_chars(e.text) |
|
|
|
self.generate_simple_tag(e) |
|
|
|
|
|
|
|
def generate_Image(self, e: Image): |
|
|
|
url = e.url |
|
|
|
|
|
|
|