Attach Groups correctly in the tree, Images now support height in HTML.
This commit is contained in:
parent
3ce0b5037b
commit
7f3490536e
2 changed files with 13 additions and 9 deletions
|
@ -190,6 +190,8 @@ class HTMLGenerator(OutputGenerator):
|
|||
attributes = self.common_attributes(e)
|
||||
if "width" in e.attributes:
|
||||
attributes["width"] = e.attributes["width"]
|
||||
if "height" in e.attributes:
|
||||
attributes["height"] = e.attributes["height"]
|
||||
|
||||
if e.title:
|
||||
attributes["alt"] = e.title
|
||||
|
|
|
@ -99,15 +99,17 @@ class TransformProcessor(NOPProcessor):
|
|||
e.attributes["no-srcset"] = self.context.get_metadata("no-srcset") if self.context.get_metadata("no-srcset") is not None else False
|
||||
return e
|
||||
|
||||
def create_Group(self, *content, new_context: Context, inline: bool=False) -> Group:
|
||||
def create_Group(self, *content, new_context: Context, replaced:Element, inline: bool=False) -> Group:
|
||||
old_context = self.context
|
||||
self.context = new_context
|
||||
content = self.transform([*content])
|
||||
self.context = old_context
|
||||
if inline:
|
||||
return InlineGroup(*content, context=new_context)
|
||||
g = InlineGroup(*content, context=new_context)
|
||||
else:
|
||||
return BlockGroup(*content, context=new_context)
|
||||
g = BlockGroup(*content, context=new_context)
|
||||
attach(g, replaced.parent, replaced.location, replaced.index)
|
||||
g = self.transform(g)
|
||||
self.context = old_context
|
||||
return g
|
||||
|
||||
def transform_Para(self, e: Para) -> Union[Para, Div]:
|
||||
if len(e.content) == 1 and isinstance(e.content[0], Span):
|
||||
|
@ -131,7 +133,7 @@ class TransformProcessor(NOPProcessor):
|
|||
new_context = Context(Doc(), self.context.path, self.context, trusted=self.context.trusted)
|
||||
for attribute, value in e.attributes.items():
|
||||
new_context.set_metadata(attribute, value)
|
||||
return self.create_Group(*e.content, new_context=new_context)
|
||||
return self.create_Group(*e.content, replaced=e, new_context=new_context)
|
||||
|
||||
if "c" in e.attributes:
|
||||
# Commands can be called multiple ways, this handles the following syntax:
|
||||
|
@ -160,7 +162,7 @@ class TransformProcessor(NOPProcessor):
|
|||
trusted = False
|
||||
if not self.context.trusted:
|
||||
trusted = False
|
||||
return self.create_Group(*includedDoc.content, new_context=Context(includedDoc, path, self.context, trusted=trusted))
|
||||
return self.create_Group(*includedDoc.content, replaced=e, new_context=Context(includedDoc, path, self.context, trusted=trusted))
|
||||
elif e.attributes["type"] in ["tex", "html"]:
|
||||
return RawBlock(text, e.attributes["type"])
|
||||
|
||||
|
@ -192,7 +194,7 @@ class TransformProcessor(NOPProcessor):
|
|||
new_context = Context(Doc(), self.context.path, self.context, trusted=self.context.trusted)
|
||||
for attribute, value in e.attributes.items():
|
||||
new_context.set_metadata(attribute, value)
|
||||
return self.create_Group(*e.content, new_context=new_context, inline=True)
|
||||
return self.create_Group(*e.content, replaced=e, new_context=new_context, inline=True)
|
||||
|
||||
if "c" in e.attributes:
|
||||
# Commands can be called multiple ways, this handles the following syntax:
|
||||
|
@ -253,7 +255,7 @@ class TransformProcessor(NOPProcessor):
|
|||
def transform_CodeBlock(self, e: CodeBlock) -> Union[CodeBlock, Div, Null]:
|
||||
if "markdown" in e.classes and "group" in e.classes:
|
||||
includedDoc = import_md(e.text)
|
||||
return self.create_Group(*includedDoc.content, new_context=Context(includedDoc, self.context.path, self.context, self.context.trusted))
|
||||
return self.create_Group(*includedDoc.content, replaced=e, new_context=Context(includedDoc, self.context.path, self.context, self.context.trusted))
|
||||
|
||||
if "python" in e.classes and "run" in e.classes:
|
||||
if not self.context.trusted:
|
||||
|
|
Loading…
Reference in a new issue