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)
|
self._latex = self.process_children(element)
|
||||||
|
|
||||||
def __str__(self):
|
def __str__(self):
|
||||||
return self.latex
|
return self.latex.replace(" ", " ")
|
||||||
|
|
||||||
def __unicode__(self):
|
def __unicode__(self):
|
||||||
return self.__str__(self)
|
return self.__str__(self)
|
||||||
@ -231,20 +231,13 @@ class oMath2Latex(Tag2Method):
|
|||||||
pr = c_dict["dPr"]
|
pr = c_dict["dPr"]
|
||||||
null = D_DEFAULT.get("null")
|
null = D_DEFAULT.get("null")
|
||||||
|
|
||||||
print(pr.text)
|
|
||||||
s_val = get_val(pr.begChr, default=D_DEFAULT.get("left"), store=T)
|
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)
|
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(
|
delim = pr.text + D.format(
|
||||||
left=null if not s_val else escape_latex(s_val),
|
left=null if not s_val else escape_latex(s_val),
|
||||||
text=c_dict["e"],
|
text=c_dict["e"],
|
||||||
right=null if not e_val else escape_latex(e_val),
|
right=null if not e_val else escape_latex(e_val),
|
||||||
)
|
)
|
||||||
print(delim)
|
|
||||||
print()
|
|
||||||
return delim
|
return delim
|
||||||
|
|
||||||
def do_spre(self, elm):
|
def do_spre(self, elm):
|
||||||
@ -355,7 +348,7 @@ class oMath2Latex(Tag2Method):
|
|||||||
"""
|
"""
|
||||||
rows = []
|
rows = []
|
||||||
for stag, t, e in self.process_children_list(elm):
|
for stag, t, e in self.process_children_list(elm):
|
||||||
if stag is "mPr":
|
if stag == "mPr":
|
||||||
pass
|
pass
|
||||||
elif stag == "mr":
|
elif stag == "mr":
|
||||||
rows.append(t)
|
rows.append(t)
|
||||||
|
@ -27,12 +27,7 @@ _log = logging.getLogger(__name__)
|
|||||||
|
|
||||||
|
|
||||||
class MsWordDocumentBackend(DeclarativeDocumentBackend):
|
class MsWordDocumentBackend(DeclarativeDocumentBackend):
|
||||||
def __init__(
|
def __init__(self, in_doc: "InputDocument", path_or_stream: Union[BytesIO, Path]):
|
||||||
self,
|
|
||||||
in_doc: "InputDocument",
|
|
||||||
path_or_stream: Union[BytesIO, Path],
|
|
||||||
get_latex=False,
|
|
||||||
):
|
|
||||||
super().__init__(in_doc, path_or_stream)
|
super().__init__(in_doc, path_or_stream)
|
||||||
self.XML_KEY = (
|
self.XML_KEY = (
|
||||||
"{http://schemas.openxmlformats.org/wordprocessingml/2006/main}val"
|
"{http://schemas.openxmlformats.org/wordprocessingml/2006/main}val"
|
||||||
@ -54,9 +49,6 @@ class MsWordDocumentBackend(DeclarativeDocumentBackend):
|
|||||||
self.level = 0
|
self.level = 0
|
||||||
self.listIter = 0
|
self.listIter = 0
|
||||||
|
|
||||||
# Transform MSWord equations to latex
|
|
||||||
self.get_latex = get_latex
|
|
||||||
|
|
||||||
self.history = {
|
self.history = {
|
||||||
"names": [None],
|
"names": [None],
|
||||||
"levels": [None],
|
"levels": [None],
|
||||||
@ -248,7 +240,6 @@ class MsWordDocumentBackend(DeclarativeDocumentBackend):
|
|||||||
paragraph = docx.text.paragraph.Paragraph(element, docx_obj)
|
paragraph = docx.text.paragraph.Paragraph(element, docx_obj)
|
||||||
|
|
||||||
text = paragraph.text
|
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:
|
if text is None:
|
||||||
|
Loading…
Reference in New Issue
Block a user