Skip to content

Commit

Permalink
Fix error with delimiters
Browse files Browse the repository at this point in the history
  • Loading branch information
VikParuchuri committed Jan 3, 2025
1 parent e11f294 commit 45b856c
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 2 deletions.
8 changes: 8 additions & 0 deletions marker/schema/blocks/equation.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,14 @@ class Equation(Block):
def assemble_html(self, child_blocks, parent_structure=None):
if self.latex:
html_out = f"<p block-type='{self.block_type}'>"
try:
latex = self.latex(html.escape(self.latex))
except ValueError as e:
# If we have mismatched delimiters, we'll treat it as a single block
# Strip the $'s from the latex
latex = [
{"class": "block", "content": self.latex.replace("$", "")}
]
for el in self.parse_latex(html.escape(self.latex)):
if el["class"] == "block":
html_out += f'<math display="block">{el["content"]}</math>'
Expand Down
1 change: 0 additions & 1 deletion marker/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@ class Settings(BaseSettings):

# General models
TORCH_DEVICE: Optional[str] = None # Note: MPS device does not work for text detection, and will default to CPU
GOOGLE_API_KEY: Optional[str] = None

@computed_field
@property
Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[tool.poetry]
name = "marker-pdf"
version = "1.2.2"
version = "1.2.3"
description = "Convert PDF to markdown with high speed and accuracy."
authors = ["Vik Paruchuri <github@vikas.sh>"]
readme = "README.md"
Expand Down

0 comments on commit 45b856c

Please sign in to comment.