aboutsummaryrefslogtreecommitdiff
path: root/src/Text/Pandoc/Readers/Org
diff options
context:
space:
mode:
authorJohn MacFarlane <jgm@berkeley.edu>2017-05-29 09:25:07 +0200
committerGitHub <noreply@github.com>2017-05-29 09:25:07 +0200
commit345bf8b6156938e60562f1f0f6b6e3354575cfcd (patch)
tree51c9011c4c1412c0f0bbc7b85e06754d9f87ff78 /src/Text/Pandoc/Readers/Org
parentafb551429bb95332f0ccdf882d0dbe8a59aa652a (diff)
parentbfd5c6b172b7b4cc471b1ed80673bac545604f62 (diff)
downloadpandoc-345bf8b6156938e60562f1f0f6b6e3354575cfcd.tar.gz
Merge pull request #3699 from herwigstuetz/org-ref-cites
Org: Fix reading of citations before punctuation
Diffstat (limited to 'src/Text/Pandoc/Readers/Org')
-rw-r--r--src/Text/Pandoc/Readers/Org/Inlines.hs16
1 files changed, 12 insertions, 4 deletions
diff --git a/src/Text/Pandoc/Readers/Org/Inlines.hs b/src/Text/Pandoc/Readers/Org/Inlines.hs
index aa376fe25..dcea61222 100644
--- a/src/Text/Pandoc/Readers/Org/Inlines.hs
+++ b/src/Text/Pandoc/Readers/Org/Inlines.hs
@@ -339,8 +339,16 @@ linkLikeOrgRefCite = try $ do
-- | Read a citation key. The characters allowed in citation keys are taken
-- from the `org-ref-cite-re` variable in `org-ref.el`.
orgRefCiteKey :: PandocMonad m => OrgParser m String
-orgRefCiteKey = try . many1 . satisfy $ \c ->
- isAlphaNum c || c `elem` ("-_:\\./"::String)
+orgRefCiteKey =
+ let citeKeySpecialChars = "-_:\\./," :: String
+ isCiteKeySpecialChar c = c `elem` citeKeySpecialChars
+ isCiteKeyChar c = isAlphaNum c || isCiteKeySpecialChar c
+
+ in try $ many1Till (satisfy $ isCiteKeyChar)
+ $ try . lookAhead $ do
+ many . satisfy $ isCiteKeySpecialChar
+ satisfy $ not . isCiteKeyChar
+
-- | Supported citation types. Only a small subset of org-ref types is
-- supported for now. TODO: rewrite this, use LaTeX reader as template.
@@ -687,13 +695,13 @@ mathEnd c = try $ do
return res
-enclosedInlines :: PandocMonad m => OrgParser m a
+enclosedInlines :: (PandocMonad m, Show b) => OrgParser m a
-> OrgParser m b
-> OrgParser m (F Inlines)
enclosedInlines start end = try $
trimInlinesF . mconcat <$> enclosed start end inline
-enclosedRaw :: PandocMonad m => OrgParser m a
+enclosedRaw :: (PandocMonad m, Show b) => OrgParser m a
-> OrgParser m b
-> OrgParser m String
enclosedRaw start end = try $