diff options
| author | John MacFarlane <[email protected]> | 2024-08-06 15:16:24 -0700 |
|---|---|---|
| committer | John MacFarlane <[email protected]> | 2024-08-06 15:16:24 -0700 |
| commit | 9bf112b9af3bfea1af9d29227dd291fcf4dfe236 (patch) | |
| tree | d3fa4e4a342f0449e87853eadcb77f1628fe3744 /src/Text | |
| parent | f31c065cc15667dc20087b2fd3ab168704f5ccb7 (diff) | |
LaTeX writer: preserve locator labels with `--natbib`.
In #9275 we made pandoc strip off locator labels (e.g. `p.`)
for natbib and biblatex output. In fact, this is only desirable
for biblatex. natbib needs the locators to be preserved.
Closes #10057.
Diffstat (limited to 'src/Text')
| -rw-r--r-- | src/Text/Pandoc/Writers/LaTeX/Citation.hs | 13 |
1 files changed, 8 insertions, 5 deletions
diff --git a/src/Text/Pandoc/Writers/LaTeX/Citation.hs b/src/Text/Pandoc/Writers/LaTeX/Citation.hs index b12b86bb1..03d3c1c8f 100644 --- a/src/Text/Pandoc/Writers/LaTeX/Citation.hs +++ b/src/Text/Pandoc/Writers/LaTeX/Citation.hs @@ -18,13 +18,14 @@ import Data.Char (isPunctuation) import Control.Monad.State (gets) import Data.Maybe (fromMaybe) import qualified Data.Text as T +import Text.Pandoc.Options import Text.Pandoc.Class.PandocMonad (PandocMonad) import Text.Pandoc.Definition import Data.List (foldl') import Text.DocLayout (Doc, brackets, empty, (<+>), text, isEmpty, literal, braces) import Text.Pandoc.Walk -import Text.Pandoc.Writers.LaTeX.Types ( LW, WriterState(stLang) ) +import Text.Pandoc.Writers.LaTeX.Types ( LW, WriterState(stLang, stOptions) ) import Text.Pandoc.Citeproc.Locator (parseLocator, LocatorInfo(..), toLocatorMap) import Citeproc.Types (Lang(..)) @@ -107,8 +108,13 @@ citeArgumentsList :: PandocMonad m -> LW m (Doc Text) citeArgumentsList _inlineListToLaTeX (CiteGroup _ _ []) = return empty citeArgumentsList inlineListToLaTeX (CiteGroup pfxs sfxs ids) = do + opts <- gets stOptions mblang <- gets stLang - let sfxs' = removePageLabel mblang $ + let sfxs' = (case writerCiteMethod opts of + -- In biblatex, the label p. or pp. can be omitted; + -- ranges are treated as page ranges by default. See #9275. + Biblatex -> removePageLabel mblang + _ -> id) $ stripLocatorBraces $ case sfxs of (Str t : r) -> case T.uncons t of Just (x, xs) @@ -189,9 +195,6 @@ citationsToBiblatex inlineListToLaTeX (c:cs) citationsToBiblatex _ _ = return empty --- | In natbib and biblatex, the label p. or pp. can be --- omitted; ranges will be treated as page ranges by default. --- See #9275. removePageLabel :: Maybe Lang -> [Inline] -> [Inline] removePageLabel mblang ils = case mbLocinfo of |
