BibTeX parser: fix expansion of special strings in series...
e.g. `newseries` or `library`. Expansion should not happen when these strings are protected in braces, or when they're capitalized. Closes #7591.
This commit is contained in:
parent
aa89f6be18
commit
665e6d3d94
4 changed files with 13 additions and 10 deletions
|
@ -54,7 +54,6 @@ import Safe (readMay)
|
|||
import Text.Printf (printf)
|
||||
import Text.DocLayout (literal, hsep, nest, hang, Doc(..),
|
||||
braces, ($$), cr)
|
||||
|
||||
data Variant = Bibtex | Biblatex
|
||||
deriving (Show, Eq, Ord)
|
||||
|
||||
|
@ -527,9 +526,9 @@ itemToReference locale variant item = do
|
|||
let fixSeriesTitle [Str xs] | isNumber xs =
|
||||
[Str (ordinalize locale xs), Space, Str (resolveKey' lang "jourser")]
|
||||
fixSeriesTitle xs = xs
|
||||
seriesTitle' <- (Just . B.fromList . fixSeriesTitle .
|
||||
B.toList . resolveKey lang <$>
|
||||
getTitle "series") <|>
|
||||
|
||||
seriesTitle' <- (Just . B.fromList . fixSeriesTitle . B.toList
|
||||
<$> getTitle "series") <|>
|
||||
return Nothing
|
||||
shortTitle' <- (Just <$> (guard (not hasMaintitle || isChapterlike) >>
|
||||
getTitle "shorttitle"))
|
||||
|
@ -984,8 +983,12 @@ getTitle f = do
|
|||
ils <- getField f
|
||||
utc <- gets untitlecase
|
||||
lang <- gets localeLang
|
||||
let ils' =
|
||||
if f == "series"
|
||||
then resolveKey lang $ ils
|
||||
else ils
|
||||
let processTitle = if utc then unTitlecase (Just lang) else id
|
||||
return $ processTitle ils
|
||||
return $ processTitle ils'
|
||||
|
||||
getShortTitle :: Bool -> Text -> Bib (Maybe Inlines)
|
||||
getShortTitle requireColon f = do
|
||||
|
@ -1460,14 +1463,14 @@ bookTrans z =
|
|||
_ -> [z]
|
||||
|
||||
resolveKey :: Lang -> Inlines -> Inlines
|
||||
resolveKey lang ils = Walk.walk go ils
|
||||
resolveKey lang (Many ils) = Many $ fmap go ils
|
||||
where go (Str s) = Str $ resolveKey' lang s
|
||||
go x = x
|
||||
|
||||
resolveKey' :: Lang -> Text -> Text
|
||||
resolveKey' lang k =
|
||||
case Map.lookup (langLanguage lang) biblatexStringMap >>=
|
||||
Map.lookup (T.toLower k) of
|
||||
Map.lookup k of
|
||||
Nothing -> k
|
||||
Just (x, _) -> either (const k) stringify $ parseLaTeX lang x
|
||||
|
||||
|
|
|
@ -97,7 +97,7 @@ references:
|
|||
- family: Author
|
||||
given: Ann A.
|
||||
suffix: Jr.
|
||||
collection-title: new series
|
||||
collection-title: New series
|
||||
container-title: "The Journaltitle: The Journalsubtitle"
|
||||
doi: 10.1086/520976
|
||||
editor:
|
||||
|
|
|
@ -54,7 +54,7 @@ references:
|
|||
author:
|
||||
- family: Gillies
|
||||
given: Alexander
|
||||
collection-title: new series
|
||||
collection-title: New series
|
||||
container-title: Publications of the English Goethe Society
|
||||
id: gillies
|
||||
issued: 1933
|
||||
|
|
|
@ -49,7 +49,7 @@ references:
|
|||
author:
|
||||
- family: Shore
|
||||
given: Bradd
|
||||
collection-title: new series
|
||||
collection-title: New series
|
||||
container-title: American Anthropologist
|
||||
id: shore
|
||||
issue: 1
|
||||
|
|
Loading…
Add table
Reference in a new issue