git.iko.soy/typeable/pandoc
on master help sign in
Muse reader: do not allow code markup to be followed by digit
dd5d234Alexander Krotov
src/Text/Pandoc/Readers/Muse.hs+2−2
@@ -43,7 +43,7 @@ import Prelude
43import Control.Monad
43import Control.Monad
44import Control.Monad.Except (throwError)
44import Control.Monad.Except (throwError)
45import Data.Bifunctor
45import Data.Bifunctor
46−import Data.Char (isLetter, isDigit)
46+import Data.Char (isLetter, isDigit, isAlphaNum)
47import Data.Default
47import Data.Default
48import Data.List (intercalate)
48import Data.List (intercalate)
49import Data.List.Split (splitOn)
49import Data.List.Split (splitOn)
@@ -913,7 +913,7 @@ code = try $ do
913 guard $ not $ null contents
913 guard $ not $ null contents
914 guard $ head contents `notElem` " \t\n"
914 guard $ head contents `notElem` " \t\n"
915 guard $ last contents `notElem` " \t\n"
915 guard $ last contents `notElem` " \t\n"
916− notFollowedBy $ satisfy isLetter
916+ notFollowedBy $ satisfy isAlphaNum
917 return $ return $ B.code contents
917 return $ return $ B.code contents
918
918
919-- | Parse @\<code>@ tag.
919-- | Parse @\<code>@ tag.
test/Tests/Readers/Muse.hs+4
@@ -150,6 +150,10 @@ tests =
150 "Foo =bar=, baz" =?>
150 "Foo =bar=, baz" =?>
151 para (text "Foo " <> code "bar" <> text ", baz")
151 para (text "Foo " <> code "bar" <> text ", baz")
152
152
153+ , "Not code if followed by digit" =:
154+ "Foo =bar=0 baz" =?>
155+ para (text "Foo =bar=0 baz")
156+
153 , "One character code" =: "=c=" =?> para (code "c")
157 , "One character code" =: "=c=" =?> para (code "c")
154
158
155 , "Three = characters is not a code" =: "===" =?> para "==="
159 , "Three = characters is not a code" =: "===" =?> para "==="