Skip to content

Commit 64be73b

Browse files
fixed all the tests
Signed-off-by: Peter Staar <[email protected]>
1 parent 455ca41 commit 64be73b

File tree

3 files changed

+14
-8
lines changed

3 files changed

+14
-8
lines changed

docling_core/transforms/serializer/latex.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -656,7 +656,9 @@ def serialize_doc(
656656
# Build optional preamble
657657
preamble_lines: list[str] = []
658658
if params.document_class:
659-
preamble_lines.append(params.document_class + "\n")
659+
# Add document class and a blank line after it
660+
preamble_lines.append(params.document_class)
661+
preamble_lines.append("")
660662
for pkg in params.packages:
661663
line = pkg.strip()
662664
if not line:
@@ -671,7 +673,7 @@ def serialize_doc(
671673
preamble_lines.append(title_cmd)
672674

673675
header = (
674-
"\n".join(preamble_lines + ["\n\\begin{document}"])
676+
"\n".join(preamble_lines + ["", "\\begin{document}"])
675677
if preamble_lines
676678
else "\\begin{document}"
677679
)

test/data/doc/inline_and_formatting.gt.tex

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,12 @@ \section{\textit{Partially formatted} heading to\_escape \texttt{not_to_escape}
4545

4646
\textit{Partially formatted} heading to\_escape \texttt{not_to_escape} $E=mc^2$ \& ampersand
4747

48+
A hyperlink on \texttt{code in a line}
49+
50+
\begin{verbatim}
51+
A hyperlink on code as paragraph
52+
\end{verbatim}
53+
4854
The end.
4955

5056
\end{document}

test/test_latex_serialization.py

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,6 @@
1313
from docling_core.types.doc.base import ImageRefMode
1414
from docling_core.types.doc.document import DoclingDocument
1515

16-
from .conftest import _construct_doc
17-
from .conftest import _rich_table_doc as _construct_rich_table_doc
1816
from .test_data_gen_flag import GEN_TEST_DATA
1917

2018

@@ -81,8 +79,8 @@ def test_dummy_doc():
8179
verify_or_update(exp_file=src.with_suffix(".gt.tex"), actual=actual)
8280

8381

84-
def test_constructed_doc():
85-
doc = _construct_doc()
82+
def test_constructed_doc(sample_doc: DoclingDocument):
83+
doc = sample_doc
8684

8785
ser = LaTeXDocSerializer(
8886
doc=doc,
@@ -96,8 +94,8 @@ def test_constructed_doc():
9694
verify_or_update(exp_file=src.with_suffix(".gt.tex"), actual=actual)
9795

9896

99-
def test_constructed_rich_table_doc():
100-
doc = _construct_rich_table_doc()
97+
def test_constructed_rich_table_doc(rich_table_doc: DoclingDocument):
98+
doc = rich_table_doc
10199

102100
ser = LaTeXDocSerializer(
103101
doc=doc,

0 commit comments

Comments
 (0)