Skip to content

Commit

Permalink
Remove prints and backend flag
Browse files Browse the repository at this point in the history
  • Loading branch information
rateixei committed Jan 28, 2025
1 parent e3fd60d commit 6e6267b
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 20 deletions.
11 changes: 2 additions & 9 deletions docling/backend/docx_latex/omml.py
Original file line number Diff line number Diff line change
Expand Up @@ -187,7 +187,7 @@ def __init__(self, element):
self._latex = self.process_children(element)

def __str__(self):
return self.latex
return self.latex.replace(" ", " ")

def __unicode__(self):
return self.__str__(self)
Expand Down Expand Up @@ -231,20 +231,13 @@ def do_d(self, elm):
pr = c_dict["dPr"]
null = D_DEFAULT.get("null")

print(pr.text)
s_val = get_val(pr.begChr, default=D_DEFAULT.get("left"), store=T)
print(pr.begChr, D_DEFAULT.get("left"), s_val)

e_val = get_val(pr.endChr, default=D_DEFAULT.get("right"), store=T)
print(pr.endChr, D_DEFAULT.get("right"), s_val)

delim = pr.text + D.format(
left=null if not s_val else escape_latex(s_val),
text=c_dict["e"],
right=null if not e_val else escape_latex(e_val),
)
print(delim)
print()
return delim

def do_spre(self, elm):
Expand Down Expand Up @@ -355,7 +348,7 @@ def do_m(self, elm):
"""
rows = []
for stag, t, e in self.process_children_list(elm):
if stag is "mPr":
if stag == "mPr":
pass
elif stag == "mr":
rows.append(t)
Expand Down
13 changes: 2 additions & 11 deletions docling/backend/msword_backend.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,12 +27,7 @@


class MsWordDocumentBackend(DeclarativeDocumentBackend):
def __init__(
self,
in_doc: "InputDocument",
path_or_stream: Union[BytesIO, Path],
get_latex=False,
):
def __init__(self, in_doc: "InputDocument", path_or_stream: Union[BytesIO, Path]):
super().__init__(in_doc, path_or_stream)
self.XML_KEY = (
"{http://schemas.openxmlformats.org/wordprocessingml/2006/main}val"
Expand All @@ -54,9 +49,6 @@ def __init__(
self.level = 0
self.listIter = 0

# Transform MSWord equations to latex
self.get_latex = get_latex

self.history = {
"names": [None],
"levels": [None],
Expand Down Expand Up @@ -248,8 +240,7 @@ def handle_text_elements(self, element, docx_obj, doc):
paragraph = docx.text.paragraph.Paragraph(element, docx_obj)

text = paragraph.text
if self.get_latex:
text = self.handle_equations_in_text(element=element, text=text)
text = self.handle_equations_in_text(element=element, text=text)

if text is None:
return
Expand Down

0 comments on commit 6e6267b

Please sign in to comment.