diff options
author | Joost Kremers <joostkremers@fastmail.fm> | 2022-07-31 01:36:26 +0200 |
---|---|---|
committer | Joost Kremers <joostkremers@fastmail.fm> | 2022-07-31 01:40:58 +0200 |
commit | 994b658b56113914f9ebfbd1e1084c47c353bc76 (patch) | |
tree | 30ed673ad9b6e08cb22906b5494e694e674d6009 | |
parent | 1ec276bb26371b686d6c57ffd38ca222cf42e8db (diff) |
Exclude certain fields when cleaning TeX markup.
Some fields, such as `file`, `url` and `doi`, should never be modified by
`parsebib-clean-TeX-markup`.
-rw-r--r-- | parsebib.el | 13 |
1 files changed, 10 insertions, 3 deletions
diff --git a/parsebib.el b/parsebib.el index 056d7d5..632ff31 100644 --- a/parsebib.el +++ b/parsebib.el @@ -357,6 +357,11 @@ string). Earlier elements are evaluated before later ones, so if one string is a subpattern of another, the second must appear later (e.g. \"''\" is before \"'\").") +(defvar parsebib-clean-TeX-markup-excluded-fields '("file" + "url" + "doi") + "List of fields that should not be passed to `parsebib-clean-TeX-markup'.") + (defun parsebib-clean-TeX-markup (string) "Return STRING without TeX markup. Any substring matching the car of a cell in @@ -735,10 +740,12 @@ ASCII/Unicode characters. See the variable (unless (>= (point) limit) ; If we haven't reached the end of the entry. (let ((beg (point))) (if (parsebib--looking-at-goto-end (concat "\\(" parsebib--bibtex-identifier "\\)[[:space:]]*=[[:space:]]*") 1) - (let ((field-type (buffer-substring-no-properties beg (point)))) + (let* ((field (buffer-substring-no-properties beg (point))) + (replace-TeX (and replace-TeX + (not (member-ignore-case field parsebib-clean-TeX-markup-excluded-fields))))) (if (or (not fields) - (member-ignore-case field-type fields)) - (cons field-type (parsebib--parse-bib-value limit strings replace-TeX)) + (member-ignore-case field fields)) + (cons field (parsebib--parse-bib-value limit strings replace-TeX)) (parsebib--parse-bib-value limit) ; Skip over the field value. :ignore)))))) ; Ignore this field but keep the `cl-loop' in `parsebib-read-entry' going. |