diff options
author | Herwig Stuetz <herwig@herwigstuetz.com> | 2017-05-23 21:30:31 +0200 |
---|---|---|
committer | Herwig Stuetz <herwig@herwigstuetz.com> | 2017-05-28 18:08:11 +0200 |
commit | bfd5c6b172b7b4cc471b1ed80673bac545604f62 (patch) | |
tree | 51c9011c4c1412c0f0bbc7b85e06754d9f87ff78 /src | |
parent | 5a71632d11f86cb6ed700fe3a4d717a56bad1b9e (diff) | |
download | pandoc-bfd5c6b172b7b4cc471b1ed80673bac545604f62.tar.gz |
Org reader: Fix cite parsing behaviour
Until now, org-ref cite keys included special characters also at the
end. This caused problems when citations occur right before colons or
at the end of a sentence.
With this change, all non alphanumeric characters at the end of a cite
key are ignored.
This also adds `,` to the list of special characters that are legal
in cite keys to better mirror the behaviour of org-export.
Diffstat (limited to 'src')
-rw-r--r-- | src/Text/Pandoc/Readers/Org/Inlines.hs | 12 |
1 files changed, 10 insertions, 2 deletions
diff --git a/src/Text/Pandoc/Readers/Org/Inlines.hs b/src/Text/Pandoc/Readers/Org/Inlines.hs index 6946e8379..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. |