From 1b0f4c8ab301ef0fd0e564c3c574c49687953a2b Mon Sep 17 00:00:00 2001 From: GloamXun Date: Wed, 28 Oct 2026 00:54:05 +0800 Subject: [PATCH] Append DOI fields to project bibliography entries .format_bib_entry ignored the doi field, so the arXiv first reference lost its doi:10.1109/... suffix. Append doi: when present and extend the server bib test fixture/assertions. Test count stays 1078. --- docs/WEB_ROUTE_D_EXPERIMENT.md | 2 +- src/main.rs | 4 ++++ tests/server.rs | 3 ++- 3 files changed, 7 insertions(+), 2 deletions(-) diff --git a/docs/WEB_ROUTE_D_EXPERIMENT.md b/docs/WEB_ROUTE_D_EXPERIMENT.md index 2d9767e..ab3553c 100644 --- a/docs/WEB_ROUTE_D_EXPERIMENT.md +++ b/docs/WEB_ROUTE_D_EXPERIMENT.md @@ -149,7 +149,7 @@ PDF was rendered page-by-page next to the route-D output. | Table | booktabs rules, `Size (µm)`, `~100`, `10^6` | centred with rules; `Size (µm)`, `~100`, `10⁶` | | Figure | framed rule box above the caption | centred framed rule body (raster) on page 3 | | Display equation | fully typeset fraction/product/sum | approximate body; fraction box uses full extents, subscripts attach even after a space, and the tag sits at the right margin | -| References | author-year, italic venue, DOI link | author-year entries; plain venue text, no DOI | +| References | author-year, italic venue, DOI link | author-year entries; DOI appended when present in the .bib | | Float order | figure/table on page 3 with section 3.4 | figure/table on page 3 above 3.3/3.4 | After this comparison, the PDF page origin was fixed: the PDF writer had diff --git a/src/main.rs b/src/main.rs index dece3e7..354e7b3 100644 --- a/src/main.rs +++ b/src/main.rs @@ -1471,6 +1471,10 @@ fn format_bib_entry(fields: &[(String, String)]) -> Option { entry.push_str(", "); entry.push_str(publisher); } + if let Some(doi) = field("doi") { + entry.push_str(". doi:"); + entry.push_str(doi); + } Some(entry) } diff --git a/tests/server.rs b/tests/server.rs index 8d01985..c429d89 100644 --- a/tests/server.rs +++ b/tests/server.rs @@ -1223,7 +1223,7 @@ fn project_preview_resolves_bibtex() { "text/plain; charset=utf-8", ); assert_eq!(put.status, 200, "{}", put.text()); - let bib = "@article{alpha,\n title={Alpha entry},\n author={Doe, Jane},\n year={2024}\n}\n"; + let bib = "@article{alpha,\n title={Alpha entry},\n author={Doe, Jane},\n year={2024},\n doi={10.1000/test}\n}\n"; let put = server.request( "PUT", "/api/projects/hello/file?path=refs.bib", @@ -1255,6 +1255,7 @@ fn project_preview_resolves_bibtex() { assert!(text.contains("References"), "{text}"); assert!(text.contains("Doe,2024"), "{text}"); assert!(text.contains("Alphaentry"), "{text}"); + assert!(text.contains("doi:10.1000/test"), "{text}"); assert!(!text.contains("[?]"), "{text}"); }