diff options
author | John MacFarlane <jgm@berkeley.edu> | 2018-02-16 15:59:03 -0800 |
---|---|---|
committer | John MacFarlane <jgm@berkeley.edu> | 2018-02-16 15:59:03 -0800 |
commit | 3535af019722fc5086e968cc485ab8b94b76f1fd (patch) | |
tree | 64fc13b1f61bc8cfb2a3258b4945db62b06bc1be /src/Text/Pandoc | |
parent | c75740e22ce35165108e020be174ebe9f35ea667 (diff) | |
download | pandoc-3535af019722fc5086e968cc485ab8b94b76f1fd.tar.gz |
Markdown writer: properly escape @ to avoid capture as citation.
Closes #4366.
Diffstat (limited to 'src/Text/Pandoc')
-rw-r--r-- | src/Text/Pandoc/Writers/Markdown.hs | 8 |
1 files changed, 7 insertions, 1 deletions
diff --git a/src/Text/Pandoc/Writers/Markdown.hs b/src/Text/Pandoc/Writers/Markdown.hs index c8b3a1526..cdd8f3b66 100644 --- a/src/Text/Pandoc/Writers/Markdown.hs +++ b/src/Text/Pandoc/Writers/Markdown.hs @@ -36,7 +36,7 @@ Markdown: <http://daringfireball.net/projects/markdown/> module Text.Pandoc.Writers.Markdown (writeMarkdown, writePlain) where import Control.Monad.Reader import Control.Monad.State.Strict -import Data.Char (chr, isPunctuation, isSpace, ord) +import Data.Char (chr, isPunctuation, isSpace, ord, isAlphaNum) import Data.Default import qualified Data.HashMap.Strict as H import Data.List (find, group, intersperse, sortBy, stripPrefix, transpose) @@ -286,6 +286,12 @@ escapeString opts (c:cs) = '>' | isEnabled Ext_all_symbols_escapable opts -> '\\' : '>' : escapeString opts cs | otherwise -> ">" ++ escapeString opts cs + '@' | isEnabled Ext_citations opts -> + case cs of + (d:_) + | isAlphaNum d || d == '_' + -> '\\':'@':escapeString opts cs + _ -> '@':escapeString opts cs _ | c `elem` ['\\','`','*','_','[',']','#'] -> '\\':c:escapeString opts cs '|' | isEnabled Ext_pipe_tables opts -> '\\':'|':escapeString opts cs |