BibTeX writer fixes. Closes #7067.
+ Require citeproc 0.3.0.7, which correctly titlecases when titles contain non-ASCII characters. + Correctly handle 'pages' (= 'page' in CSL). + Correctly handle BibLaTeX 'langid' (= 'language' in CSL). + In BibTeX output, protect foreign titles since there's no language field.
This commit is contained in:
parent
22faea15c2
commit
b239c89a82
4 changed files with 107 additions and 8 deletions
|
@ -410,7 +410,7 @@ library
|
|||
blaze-markup >= 0.8 && < 0.9,
|
||||
bytestring >= 0.9 && < 0.12,
|
||||
case-insensitive >= 1.2 && < 1.3,
|
||||
citeproc >= 0.3.0.6 && < 0.4,
|
||||
citeproc >= 0.3.0.7 && < 0.4,
|
||||
commonmark >= 0.1.1.3 && < 0.2,
|
||||
commonmark-extensions >= 0.2.0.4 && < 0.3,
|
||||
commonmark-pandoc >= 0.2 && < 0.3,
|
||||
|
|
|
@ -149,7 +149,7 @@ writeBibtexString opts variant mblang ref =
|
|||
, "type"
|
||||
, "entrysubtype"
|
||||
, "note"
|
||||
, "language"
|
||||
, "langid"
|
||||
, "abstract"
|
||||
, "keywords"
|
||||
]
|
||||
|
@ -202,12 +202,19 @@ writeBibtexString opts variant mblang ref =
|
|||
[ (", " <>) <$> nameGiven name,
|
||||
nameDroppingParticle name ]
|
||||
|
||||
titlecase = case mblang of
|
||||
mblang' = (parseLang <$> getVariableAsText "language") <|> mblang
|
||||
|
||||
titlecase = case mblang' of
|
||||
Just (Lang "en" _) -> titlecase'
|
||||
Nothing -> titlecase'
|
||||
_ -> id
|
||||
_ ->
|
||||
case variant of
|
||||
Bibtex -> B.spanWith nullAttr
|
||||
-- BibTex lacks a language field, so we wrap non-English
|
||||
-- titles in {} to protect case.
|
||||
Biblatex -> id
|
||||
|
||||
titlecase' = addTextCase mblang TitleCase .
|
||||
titlecase' = addTextCase mblang' TitleCase .
|
||||
(\ils -> B.fromList
|
||||
(case B.toList ils of
|
||||
Str t : xs -> Str t : Walk.walk spanAroundCapitalizedWords xs
|
||||
|
@ -299,6 +306,8 @@ writeBibtexString opts variant mblang ref =
|
|||
getContentsFor "urldate" = getVariable "accessed" >>= toLaTeX . valToInlines
|
||||
getContentsFor "year" = getVariable "issued" >>= getYear
|
||||
getContentsFor "month" = getVariable "issued" >>= getMonth
|
||||
getContentsFor "pages" = getVariable "page" >>= toLaTeX . valToInlines
|
||||
getContentsFor "langid" = getVariable "language" >>= toLaTeX . valToInlines
|
||||
getContentsFor "number" = (getVariable "number"
|
||||
<|> getVariable "collection-number"
|
||||
<|> getVariable "issue") >>= toLaTeX . valToInlines
|
||||
|
|
|
@ -19,10 +19,10 @@ extra-deps:
|
|||
- doctemplates-0.9
|
||||
- texmath-0.12.1
|
||||
- tasty-bench-0.1
|
||||
- citeproc-0.3.0.6
|
||||
- citeproc-0.3.0.7
|
||||
#- citeproc:
|
||||
# git: https://github.com/jgm/citeproc.git
|
||||
# commit: da1f9702fa70d7e1bad9a796f897e920e2d578f7
|
||||
# commit: feb3b7580c6738eec3b23921f7c1739cfba611aa
|
||||
ghc-options:
|
||||
"$locals": -fhide-source-paths -Wno-missing-home-modules
|
||||
resolver: lts-16.23
|
||||
|
|
90
test/command/7067.md
Normal file
90
test/command/7067.md
Normal file
|
@ -0,0 +1,90 @@
|
|||
```
|
||||
% pandoc -t biblatex
|
||||
---
|
||||
references:
|
||||
- id: garaud
|
||||
author:
|
||||
- family: Garaud
|
||||
given: Marcel
|
||||
container-title: Bulletin de la Societé des antiquaires de l’Ouest
|
||||
collection-title: 4
|
||||
issued:
|
||||
- year: 1967
|
||||
language: fr-FR
|
||||
page: 11-27
|
||||
title: Recherches sur les défrichements dans la Gâtine poitevine aux XI^e^ et XII^e^ siècles
|
||||
type: article-journal
|
||||
volume: 9
|
||||
...
|
||||
^D
|
||||
@article{garaud,
|
||||
author = {Garaud, Marcel},
|
||||
title = {Recherches sur les défrichements dans la Gâtine poitevine aux
|
||||
XI\textsuperscript{e} et XII\textsuperscript{e} siècles},
|
||||
journal = {Bulletin de la Societé des antiquaires de l’Ouest},
|
||||
series = {4},
|
||||
volume = {9},
|
||||
pages = {11-27},
|
||||
date = {1967},
|
||||
langid = {fr-FR}
|
||||
}
|
||||
```
|
||||
|
||||
```
|
||||
% pandoc -t bibtex
|
||||
---
|
||||
references:
|
||||
- id: garaud
|
||||
author:
|
||||
- family: Garaud
|
||||
given: Marcel
|
||||
container-title: Bulletin de la Société des antiquaires de l’Ouest
|
||||
collection-title: 4
|
||||
issued:
|
||||
- year: 1967
|
||||
language: fr-FR
|
||||
page: 11-27
|
||||
title: Recherches sur les défrichements dans la Gâtine poitevine aux XI^e^ et XII^e^ siècles
|
||||
type: article-journal
|
||||
volume: 9
|
||||
...
|
||||
^D
|
||||
@article{garaud,
|
||||
author = {Garaud, Marcel},
|
||||
title = {{Recherches sur les défrichements dans la Gâtine poitevine aux
|
||||
XI\textsuperscript{e} et XII\textsuperscript{e} siècles}},
|
||||
journal = {Bulletin de la Société des antiquaires de l’Ouest},
|
||||
series = {4},
|
||||
volume = {9},
|
||||
pages = {11-27},
|
||||
year = {1967}
|
||||
}
|
||||
```
|
||||
|
||||
This tests the titlecasing of a word with an accented second letter:
|
||||
```
|
||||
% pandoc -t bibtex
|
||||
---
|
||||
references:
|
||||
- id: garaud
|
||||
author:
|
||||
- family: Garaud
|
||||
given: Marcel
|
||||
container-title: English Journal
|
||||
issued:
|
||||
- year: 1967
|
||||
language: en-US
|
||||
title: Research on the défrichements in the Gâtine poitevine
|
||||
type: article-journal
|
||||
volume: 9
|
||||
...
|
||||
^D
|
||||
@article{garaud,
|
||||
author = {Garaud, Marcel},
|
||||
title = {Research on the Défrichements in the {Gâtine} Poitevine},
|
||||
journal = {English Journal},
|
||||
volume = {9},
|
||||
year = {1967}
|
||||
}
|
||||
```
|
||||
|
Loading…
Add table
Reference in a new issue