Skip to content

DeepTutor: Lifelong Personalized Tutoring. https://deeptutor.info/.

fix: keep BibTeX entries with accented author names

Mohammad Hijjawiec79b4099652
diff --git a/deeptutor/utils/bibtex_converter.py b/deeptutor/utils/bibtex_converter.py
index 12cf69d9f..1727365a2 100644
--- a/deeptutor/utils/bibtex_converter.py
+++ b/deeptutor/utils/bibtex_converter.py
@@ -194,6 +194,9 @@ def _scan_entry(text: str, match: re.Match[str]) -> tuple[_Entry | None, int] |
index = match.end()
brace_depth = 1 if opener == "{" else 0
paren_depth = 1 if opener == "(" else 0
+ # A double quote only delimits a value at the entry's top level; inside
+ # braces it is literal text, as in the umlaut accent ``{\"u}``.
+ top_level_depth = brace_depth
quoted = False
escaped = False
@@ -208,7 +211,7 @@ def _scan_entry(text: str, match: re.Match[str]) -> tuple[_Entry | None, int] |
quoted = False
index += 1
continue
- if char == '"':
+ if char == '"' and brace_depth == top_level_depth:
quoted = True
elif char == "{":
brace_depth += 1
diff --git a/tests/utils/test_bibtex_converter.py b/tests/utils/test_bibtex_converter.py
index 1068e6a0d..63f9a0e2c 100644
--- a/tests/utils/test_bibtex_converter.py
+++ b/tests/utils/test_bibtex_converter.py
@@ -70,3 +70,25 @@ def test_bibtex_to_markdown_skips_entry_with_unterminated_value() -> None:
def test_bibtex_to_markdown_passes_non_bibtex_through() -> None:
assert bibtex_to_markdown("not a bibliography") == "not a bibliography"
+
+
+def test_bibtex_to_markdown_keeps_entry_with_accent_quote_in_braces() -> None:
+ text = r"""
+ @article{mueller2020,
+ author = {M{\"u}ller, Hans and Smith, Jane},
+ title = {Deep Learning},
+ year = {2020}
+ }
+
+ @article{second2021,
+ title = {Second Paper},
+ year = {2021}
+ }
+ """
+
+ result = bibtex_to_markdown(text)
+
+ assert "Total entries: 2" in result
+ assert "## 1. Deep Learning" in result
+ assert "mueller2020" in result
+ assert "## 2. Second Paper" in result