Skip to content

Commit

Permalink
render block mode the same way
Browse files Browse the repository at this point in the history
  • Loading branch information
iammosespaulr committed Dec 20, 2024
1 parent e48364c commit 32f8095
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 7 deletions.
9 changes: 4 additions & 5 deletions marker/renderers/markdown.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,11 +44,10 @@ def convert_p(self, el, text, convert_as_inline):
return f"{text}\n\n" if text else "" # default convert_p behavior

def convert_math(self, el, text, convert_as_inline):
block = el.has_attr('display') and el['display'] == 'block'
if block:
return text # TODO: Fix block math handling

return f"${text}$"
inline = el.has_attr('display') and el['display'] == 'inline'
if inline:
return f"${text}$"
return f"\n$${text}$$\n\n"


class MarkdownOutput(BaseModel):
Expand Down
2 changes: 1 addition & 1 deletion marker/schema/blocks/equation.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ class Equation(Block):

def assemble_html(self, child_blocks, parent_structure=None):
if self.latex:
return f"\n<p><math display=\"block\">{html.escape(self.latex)}</math></p>\n"
return f"<math display=\"block\">{html.escape(self.latex.strip('$'))}</math>"
else:
template = super().assemble_html(child_blocks, parent_structure)
return f"<p>{template}</p>"
2 changes: 1 addition & 1 deletion marker/schema/text/span.py
Original file line number Diff line number Diff line change
Expand Up @@ -63,5 +63,5 @@ def assemble_html(self, child_blocks, parent_structure):
elif self.bold:
return f"<b>{text}</b>"
elif self.math:
return f"<math>{text}</math>"
return f"<math display='inline'>{text}</math>"
return text

0 comments on commit 32f8095

Please sign in to comment.