mirror of
https://github.com/DS4SD/docling.git
synced 2025-07-27 12:34:22 +00:00
Remove prints and backend flag
Signed-off-by: Rafael Teixeira de Lima <Rafael.td.lima@gmail.com>
This commit is contained in:
parent
31e30a2cb7
commit
b3b7c387ca
@ -187,7 +187,7 @@ class oMath2Latex(Tag2Method):
|
||||
self._latex = self.process_children(element)
|
||||
|
||||
def __str__(self):
|
||||
return self.latex
|
||||
return self.latex.replace(" ", " ")
|
||||
|
||||
def __unicode__(self):
|
||||
return self.__str__(self)
|
||||
@ -231,20 +231,13 @@ class oMath2Latex(Tag2Method):
|
||||
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):
|
||||
@ -355,7 +348,7 @@ class oMath2Latex(Tag2Method):
|
||||
"""
|
||||
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)
|
||||
|
@ -27,12 +27,7 @@ _log = logging.getLogger(__name__)
|
||||
|
||||
|
||||
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"
|
||||
@ -54,9 +49,6 @@ class MsWordDocumentBackend(DeclarativeDocumentBackend):
|
||||
self.level = 0
|
||||
self.listIter = 0
|
||||
|
||||
# Transform MSWord equations to latex
|
||||
self.get_latex = get_latex
|
||||
|
||||
self.history = {
|
||||
"names": [None],
|
||||
"levels": [None],
|
||||
@ -248,8 +240,7 @@ class MsWordDocumentBackend(DeclarativeDocumentBackend):
|
||||
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
|
||||
|
Loading…
Reference in New Issue
Block a user