From f6db991695c5709871ae3da3787ec1a8373e25be Mon Sep 17 00:00:00 2001 From: yunyv <62236062+yunyv@users.noreply.github.com> Date: Fri, 13 Nov 2026 13:00:03 -0700 Subject: [PATCH 1/2] fix(utils): preserve whitespace in concatenated BibTeX values --- deeptutor/utils/bibtex_converter.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/deeptutor/utils/bibtex_converter.py b/deeptutor/utils/bibtex_converter.py index fab5d0848..79aa430b5 100644 --- a/deeptutor/utils/bibtex_converter.py +++ b/deeptutor/utils/bibtex_converter.py @@ -204,7 +204,10 @@ def _read_fields(body: str) -> dict[str, str]: raise ValueError("empty BibTeX value") value = body[index:end] index = end - parts.append(value.strip()) + # Whitespace inside a quoted/braced fragment belongs to the value: + # trimming before concatenation would turn "Jane " # "Doe" into + # "JaneDoe". Display formatting normalizes the completed value. + parts.append(value) index = _skip_whitespace(body, index) if index < len(body) and body[index] == "#": index = _skip_whitespace(body, index + 1) From 2e1014df88a5471f70eedac75779b4de32810ea5 Mon Sep 17 00:00:00 2001 From: yunyv <62236062+yunyv@users.noreply.github.com> Date: Fri, 13 Nov 2026 13:00:56 -0700 Subject: [PATCH 2/2] test(utils): cover BibTeX fragment whitespace --- tests/utils/test_bibtex_converter.py | 34 ++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) diff --git a/tests/utils/test_bibtex_converter.py b/tests/utils/test_bibtex_converter.py index 6e50f394b..3cf3387eb 100644 --- a/tests/utils/test_bibtex_converter.py +++ b/tests/utils/test_bibtex_converter.py @@ -122,3 +122,37 @@ def test_bibtex_to_markdown_formats_jr_and_braced_author_names() -> None: result = bibtex_to_markdown(text) assert "**Authors:** Martin Luther King Jr., Food and Agriculture Organization" in result + + +def test_bibtex_to_markdown_preserves_spaces_in_concatenated_values() -> None: + text = """ + @article{joined, + title = "Attention " # {Is All } # "You Need", + author = "Doe, " # {Jane and } # "Smith, John", + abstract = {First sentence.} # " " # {Second sentence.}, + year = 20 # 26 + } + """ + + result = bibtex_to_markdown(text) + + assert "## 1. Attention Is All You Need" in result + assert "**Authors:** Jane Doe, John Smith" in result + assert "**Abstract:** First sentence. Second sentence." in result + assert "**Year:** 2026" in result + + +def test_bibtex_to_markdown_does_not_insert_spaces_between_joined_values() -> None: + text = """ + @article{joined, + title = "Sub" # {word}, + doi = "10.1000/" # "example", + year = 20 # 26 + } + """ + + result = bibtex_to_markdown(text) + + assert "## 1. Subword" in result + assert "**DOI:** 10.1000/example" in result + assert "**Year:** 2026" in result