aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--pandoc.cabal2
-rw-r--r--src/Text/Pandoc/Citeproc/BibTeX.hs21
-rw-r--r--stack.yaml4
-rw-r--r--test/command/7067.md90
4 files changed, 108 insertions, 9 deletions
diff --git a/pandoc.cabal b/pandoc.cabal
index 0890318e3..1bdd2a6b3 100644
--- a/pandoc.cabal
+++ b/pandoc.cabal
@@ -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,
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
diff --git a/stack.yaml b/stack.yaml
index 6c8c39fa7..dc6fa6517 100644
--- a/stack.yaml
+++ b/stack.yaml
@@ -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
diff --git a/test/command/7067.md b/test/command/7067.md
new file mode 100644
index 000000000..a66e3aa1f
--- /dev/null
+++ b/test/command/7067.md
@@ -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}
+}
+```
+