aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorJohn MacFarlane <jgm@berkeley.edu>2021-02-01 08:43:26 -0800
committerJohn MacFarlane <jgm@berkeley.edu>2021-02-01 11:23:07 -0800
commitb239c89a82b66abc55bf7c08e37492938c817c56 (patch)
treeccbcc4f8c74ca6152b3974be711f2d5864edccaf /src
parent22faea15c249c1f84257d289ed6904f3abe64330 (diff)
downloadpandoc-b239c89a82b66abc55bf7c08e37492938c817c56.tar.gz
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.
Diffstat (limited to 'src')
-rw-r--r--src/Text/Pandoc/Citeproc/BibTeX.hs21
1 files changed, 15 insertions, 6 deletions
diff --git a/src/Text/Pandoc/Citeproc/BibTeX.hs b/src/Text/Pandoc/Citeproc/BibTeX.hs
index 5b9068378..2b43fffb6 100644
--- a/src/Text/Pandoc/Citeproc/BibTeX.hs
+++ b/src/Text/Pandoc/Citeproc/BibTeX.hs
@@ -115,7 +115,7 @@ writeBibtexString opts variant mblang ref =
"motion_picture" | variant == Biblatex -> "movie"
"review" | variant == Biblatex -> "review"
_ -> "misc"
-
+
mbSubtype =
case referenceType ref of
"article-magazine" -> Just "magazine"
@@ -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
-
- titlecase' = addTextCase mblang TitleCase .
+ _ ->
+ 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 .
(\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