Skip to content

Commit

Permalink
Escape hyphens in number fields when converting to CSL
Browse files Browse the repository at this point in the history
  • Loading branch information
zepinglee committed Jul 27, 2024
1 parent 45dfe32 commit b515fbe
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 4 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- BibTeX parser: Fix hyphen in family name.
- Fix a bug in EDTF parsing.
- Bib2csl: Fix a sentence case conversion bug that words after colons are not capitalized.
- Bib2csl: The hyphens in `number` fields are correctly escaped when converted to CSL-JSON.

## [0.5.1] - 2024-07-10

Expand Down
2 changes: 1 addition & 1 deletion citeproc/citeproc-bibtex2csl.lua
Original file line number Diff line number Diff line change
Expand Up @@ -488,7 +488,7 @@ function bibtex2csl.post_process_special_fields(item, entry)
elseif item["collection-title"] and not item["collection-number"] then
item["collection-number"] = bib_fields.number
elseif not item.number then
item.number = bib_fields.number
item.number = string.gsub(bib_fields.number, "([^-])%-([^-])", "%1\\-%2")
end
end

Expand Down
6 changes: 3 additions & 3 deletions tests/bibtex/biblatex-examples.json
Original file line number Diff line number Diff line change
Expand Up @@ -2434,7 +2434,7 @@
},
"language": "de-DE",
"note": "This is a <code>\\texttt{</code><span class=\"nocase\">patent</span><code>}</code> entry with a <code>\\texttt{</code><span class=\"nocase\">location</span><code>}</code> field. The number is given in the <code>\\texttt{</code><span class=\"nocase\">number</span><code>}</code> field. Note the format of the <code>\\texttt{</code><span class=\"nocase\">location</span><code>}</code> field in the database file. Compare <code>\\texttt{</code><span class=\"nocase\">laufenberg</span><code>}</code>, <code>\\texttt{</code><span class=\"nocase\">sorace</span><code>}</code>, and <code>\\texttt{</code><span class=\"nocase\">kowalik</span><code>}</code>",
"number": "EU-29702195U",
"number": "EU\\-29702195U",
"publisher-place": "countryfr and countryuk and countryde",
"title": "Elektromagnetisches Signalhorn"
},
Expand Down Expand Up @@ -2607,7 +2607,7 @@
},
"language": "en-US",
"note": "This is a <code>\\texttt{</code><span class=\"nocase\">report</span><code>}</code> entry for a research report. Note the format of the <code>\\texttt{</code><span class=\"nocase\">type</span><code>}</code> field in the database file which uses a localization key. The number of the report is given in the <code>\\texttt{</code><span class=\"nocase\">number</span><code>}</code> field. Also note the <code>\\texttt{</code><span class=\"nocase\">sorttitle</span><code>}</code> and <code>\\texttt{</code><span class=\"nocase\">indextitle</span><code>}</code> fields",
"number": "RC-6947",
"number": "RC\\-6947",
"publisher": "IBM",
"title": "A hybrid hierarchical model of a <span class=\"nocase\">Multiple Virtual Storage</span> (<span class=\"nocase\">MVS</span>) operating system"
},
Expand Down Expand Up @@ -2639,7 +2639,7 @@
},
"language": "en-US",
"note": "This is a <code>\\texttt{</code><span class=\"nocase\">report</span><code>}</code> entry for a technical report. Note the format of the <code>\\texttt{</code><span class=\"nocase\">type</span><code>}</code> field in the database file which uses a localization key. The number of the report is given in the <code>\\texttt{</code><span class=\"nocase\">number</span><code>}</code> field. Also note the <code>\\texttt{</code><span class=\"nocase\">sorttitle</span><code>}</code> and <code>\\texttt{</code><span class=\"nocase\">indextitle</span><code>}</code> fields",
"number": "99-02",
"number": "99\\-02",
"publisher": "University of Massachusetts",
"publisher-place": "Amherst, Mass.",
"title": "A stochastic model of <span class=\"nocase\">TCP Reno</span> congestion avoidance and control"
Expand Down

0 comments on commit b515fbe

Please sign in to comment.