git.iko.soy/typeable/pandoc
on master help sign in
Citeproc: Don't detect math elements as locators.

Closes #7321.

commitcbe16b2866abd8d0e4c15f027562b4b2bed3f01e authorJohn MacFarlane <jgm@berkeley.edu> dateThu 27 May 2021, 10:49 (5 years ago) parent834da53
3 files changed+32−1
MANUAL.txt+1−1 src/Text/Pandoc/Citeproc/Locator.hs+7 test/command/7321.md+24
MANUAL.txt+1−1
@@ -5015,7 +5015,7 @@ the suffix as locator by prepending curly braces:
50155015
50165016 [@smith{ii, A, D-Z}, with a suffix]
50175017 [@smith, {pp. iv, vi-xi, (xv)-(xvii)} with suffix here]
5018− [@smith{}, $a^2$ and following]
5018+ [@smith{}, 99 years later]
50195019
50205020A minus sign (`-`) before the `@` will suppress mention of
50215021the author in the citation. This can be useful when the
src/Text/Pandoc/Citeproc/Locator.hs+7
@@ -181,6 +181,7 @@ pPageUnit = roman <|> plainUnit
181181 plainUnit = do
182182 ts <- many1 (notFollowedBy pSpace >>
183183 notFollowedBy pLocatorPunct >>
184+ notFollowedBy pMath >>
184185 anyToken)
185186 let s = stringify ts
186187 -- otherwise look for actual digits or -s
@@ -211,6 +212,12 @@ pMatchChar msg f = satisfyTok f' <?> msg
211212pSpace :: LocatorParser Inline
212213pSpace = satisfyTok (\t -> isSpacey t || t == Str "\160") <?> "space"
213214
215+pMath :: LocatorParser Inline
216+pMath = satisfyTok isMath
217+ where
218+ isMath (Math{}) = True
219+ isMath _ = False
220+
214221satisfyTok :: (Inline -> Bool) -> LocatorParser Inline
215222satisfyTok f = tokenPrim show (\sp _ _ -> sp) (\tok -> if f tok
216223 then Just tok
test/command/7321.mdnew file+24
@@ -0,0 +1,24 @@
1+```
2+% pandoc -t plain --citeproc --wrap=none
3+---
4+references:
5+- id: fenner2012a
6+ title: One-click science marketing
7+ author:
8+ - family: Fenner
9+ given: Martin
10+ container-title: Nature Materials
11+ volume: 11
12+ issue: 4
13+ publisher: Nature Publishing Group
14+ type: article-journal
15+ issued:
16+ year: 2012
17+---
18+
19+[@fenner2012a, $a^2+b^2=c^2$]
20+^D
21+(Fenner 2012, a² + b² = c²)
22+
23+Fenner, Martin. 2012. “One-Click Science Marketing.” Nature Materials 11 (4).
24+```