Minor fixes, typos, generating of MetaValues, fixed error where KeyErrors from the inside of the tree would get eaten.
This commit is contained in:
parent
72b9bc7bf1
commit
a1c439c32e
3 changed files with 23 additions and 8 deletions
|
@ -328,7 +328,7 @@ class StandaloneHTMLGenerator(HTMLGenerator):
|
||||||
self.indent_more()
|
self.indent_more()
|
||||||
self.writeln(self.single_tag("meta", attributes={"charset": "utf-8"}))
|
self.writeln(self.single_tag("meta", attributes={"charset": "utf-8"}))
|
||||||
self.writeln(self.single_tag("meta", attributes={"viewport": "width=device-width, initial-scale=1.0"}))
|
self.writeln(self.single_tag("meta", attributes={"viewport": "width=device-width, initial-scale=1.0"}))
|
||||||
self.writeln(self.single_tag("link", attributes={"href": "https://cdn.jsdelivr.net/npm/katex@0.16.4/dist/katex.min.css", "integrity":"sha384-vKruj+a13U8yHIkAyGgK1J3ArTLzrFGBbBc0tDp4ad/EyewESeXE/Iv67Aj8gKZ0", "crossorigin":"anonymous"}))
|
self.writeln(self.single_tag("link", attributes={"rel": "stylesheet", "href": "https://cdn.jsdelivr.net/npm/katex@0.16.4/dist/katex.min.css", "integrity":"sha384-vKruj+a13U8yHIkAyGgK1J3ArTLzrFGBbBc0tDp4ad/EyewESeXE/Iv67Aj8gKZ0", "crossorigin":"anonymous"}))
|
||||||
if "title" in e.metadata:
|
if "title" in e.metadata:
|
||||||
self.write(self.start_tag("title"))
|
self.write(self.start_tag("title"))
|
||||||
self.generate(e.metadata["title"])
|
self.generate(e.metadata["title"])
|
||||||
|
|
|
@ -111,10 +111,12 @@ class NOPProcessor:
|
||||||
e = transformer(e)
|
e = transformer(e)
|
||||||
|
|
||||||
try:
|
try:
|
||||||
e = self.TYPE_DICT[type(e)](e)
|
method = self.TYPE_DICT[type(e)]
|
||||||
except KeyError:
|
except KeyError:
|
||||||
raise self.UnknownElementError(type(e))
|
raise self.UnknownElementError(type(e))
|
||||||
|
|
||||||
|
e = method(e)
|
||||||
|
|
||||||
for transformer in self.get_posttransformers():
|
for transformer in self.get_posttransformers():
|
||||||
e = transformer(e)
|
e = transformer(e)
|
||||||
|
|
||||||
|
|
|
@ -157,9 +157,10 @@ class OutputGenerator:
|
||||||
self.generate_MetaList(e)
|
self.generate_MetaList(e)
|
||||||
else:
|
else:
|
||||||
try:
|
try:
|
||||||
self.TYPE_DICT_MISC[type(e)](e)
|
method = self.TYPE_DICT_MISC[type(e)]
|
||||||
except KeyError as err:
|
except KeyError as err:
|
||||||
raise UnknownElementError(type(e)) from err
|
raise UnknownElementError(type(e)) from err
|
||||||
|
method(e)
|
||||||
if isinstance(e, Group):
|
if isinstance(e, Group):
|
||||||
self.context = old_context
|
self.context = old_context
|
||||||
except FormatitkoRecursiveError as err:
|
except FormatitkoRecursiveError as err:
|
||||||
|
@ -292,9 +293,10 @@ class OutputGenerator:
|
||||||
|
|
||||||
def generate_MetaValue(self, e: MetaValue):
|
def generate_MetaValue(self, e: MetaValue):
|
||||||
try:
|
try:
|
||||||
self.TYPE_DICT_META[type(e)](e)
|
method = self.TYPE_DICT_META[type(e)]
|
||||||
except KeyError:
|
except KeyError:
|
||||||
self.generate(e.content)
|
self.generate(e.content)
|
||||||
|
method(e)
|
||||||
|
|
||||||
def generate_MetaBlocks(self, e: MetaBlocks):
|
def generate_MetaBlocks(self, e: MetaBlocks):
|
||||||
self.generate(e.content)
|
self.generate(e.content)
|
||||||
|
@ -303,16 +305,23 @@ class OutputGenerator:
|
||||||
self.generate(e.content)
|
self.generate(e.content)
|
||||||
|
|
||||||
def generate_MetaBool(self, e: MetaBool):
|
def generate_MetaBool(self, e: MetaBool):
|
||||||
self.generate_simple_tag(e)
|
if e.boolean:
|
||||||
|
self.write("True")
|
||||||
|
else:
|
||||||
|
self.write("False")
|
||||||
|
|
||||||
def generate_MetaMap(self, e: MetaMap):
|
def generate_MetaMap(self, e: MetaMap):
|
||||||
self.generate_simple_tag(e)
|
self.generate_simple_tag(e)
|
||||||
|
|
||||||
def generate_MetaString(self, e: MetaString):
|
def generate_MetaString(self, e: MetaString):
|
||||||
self.generate_simple_tag(e)
|
self.write(e.text)
|
||||||
|
|
||||||
def generate_Inline(self, e: Inline):
|
def generate_Inline(self, e: Inline):
|
||||||
self.TYPE_DICT_INLINE[type(e)](e)
|
try:
|
||||||
|
method = self.TYPE_DICT_INLINE[type(e)]
|
||||||
|
except KeyError as err:
|
||||||
|
raise UnknownElementError(type(e)) from err
|
||||||
|
method(e)
|
||||||
|
|
||||||
def generate_Str(self, e: Str):
|
def generate_Str(self, e: Str):
|
||||||
self.write(self.escape_special_chars(e.text))
|
self.write(self.escape_special_chars(e.text))
|
||||||
|
@ -413,7 +422,11 @@ class OutputGenerator:
|
||||||
|
|
||||||
|
|
||||||
def generate_Block(self, e: Block):
|
def generate_Block(self, e: Block):
|
||||||
self.TYPE_DICT_BLOCK[type(e)](e)
|
try:
|
||||||
|
method = self.TYPE_DICT_BLOCK[type(e)]
|
||||||
|
except KeyError as err:
|
||||||
|
raise UnknownElementError(type(e)) from err
|
||||||
|
method(e)
|
||||||
|
|
||||||
|
|
||||||
# Block elements
|
# Block elements
|
||||||
|
|
Loading…
Reference in a new issue