aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJohn MacFarlane <jgm@berkeley.edu>2021-05-27 10:49:45 -0700
committerJohn MacFarlane <jgm@berkeley.edu>2021-05-27 10:49:45 -0700
commitcbe16b2866abd8d0e4c15f027562b4b2bed3f01e (patch)
tree64db92ea488edcc5949e57657b0c8c91f4a92bcb
parent834da53058069fe50da510fa86e0807a7ff7868f (diff)
downloadpandoc-cbe16b2866abd8d0e4c15f027562b4b2bed3f01e.tar.gz
Citeproc: Don't detect math elements as locators.
Closes #7321.
-rw-r--r--MANUAL.txt2
-rw-r--r--src/Text/Pandoc/Citeproc/Locator.hs7
-rw-r--r--test/command/7321.md24
3 files changed, 32 insertions, 1 deletions
diff --git a/MANUAL.txt b/MANUAL.txt
index 48bf60d6e..2ca50e44a 100644
--- a/MANUAL.txt
+++ b/MANUAL.txt
@@ -5015,7 +5015,7 @@ the suffix as locator by prepending curly braces:
[@smith{ii, A, D-Z}, with a suffix]
[@smith, {pp. iv, vi-xi, (xv)-(xvii)} with suffix here]
- [@smith{}, $a^2$ and following]
+ [@smith{}, 99 years later]
A minus sign (`-`) before the `@` will suppress mention of
the author in the citation. This can be useful when the
diff --git a/src/Text/Pandoc/Citeproc/Locator.hs b/src/Text/Pandoc/Citeproc/Locator.hs
index 44416ca12..dbedc08d9 100644
--- a/src/Text/Pandoc/Citeproc/Locator.hs
+++ b/src/Text/Pandoc/Citeproc/Locator.hs
@@ -181,6 +181,7 @@ pPageUnit = roman <|> plainUnit
plainUnit = do
ts <- many1 (notFollowedBy pSpace >>
notFollowedBy pLocatorPunct >>
+ notFollowedBy pMath >>
anyToken)
let s = stringify ts
-- otherwise look for actual digits or -s
@@ -211,6 +212,12 @@ pMatchChar msg f = satisfyTok f' <?> msg
pSpace :: LocatorParser Inline
pSpace = satisfyTok (\t -> isSpacey t || t == Str "\160") <?> "space"
+pMath :: LocatorParser Inline
+pMath = satisfyTok isMath
+ where
+ isMath (Math{}) = True
+ isMath _ = False
+
satisfyTok :: (Inline -> Bool) -> LocatorParser Inline
satisfyTok f = tokenPrim show (\sp _ _ -> sp) (\tok -> if f tok
then Just tok
diff --git a/test/command/7321.md b/test/command/7321.md
new file mode 100644
index 000000000..f5e644bee
--- /dev/null
+++ b/test/command/7321.md
@@ -0,0 +1,24 @@
+```
+% pandoc -t plain --citeproc --wrap=none
+---
+references:
+- id: fenner2012a
+ title: One-click science marketing
+ author:
+ - family: Fenner
+ given: Martin
+ container-title: Nature Materials
+ volume: 11
+ issue: 4
+ publisher: Nature Publishing Group
+ type: article-journal
+ issued:
+ year: 2012
+---
+
+[@fenner2012a, $a^2+b^2=c^2$]
+^D
+(Fenner 2012, a² + b² = c²)
+
+Fenner, Martin. 2012. “One-Click Science Marketing.” Nature Materials 11 (4).
+```