git.iko.soy/typeable/pandoc
on master help sign in
Merge pull request #3917 from labdsf/muse-reader-emphasis-word

Muse reader: allow inline markup to be followed by punctuation

commit1307b023af801d8eabeef7404478c4d923c82b0a authorJohn MacFarlane <jgm@berkeley.edu> dateMon 11 Sep 2017, 10:57 (9 years ago) parent7df095f8e4ee66
2 files changed+21−4
src/Text/Pandoc/Readers/Muse.hs+3−2 test/Tests/Readers/Muse.hs+18−2
src/Text/Pandoc/Readers/Muse.hs+3−2
@@ -45,6 +45,7 @@ module Text.Pandoc.Readers.Muse (readMuse) where
4545import Control.Monad
4646import Control.Monad.Except (throwError)
4747import qualified Data.Map as M
48+import Data.Char (isLetter)
4849import Data.Text (Text, unpack)
4950import Data.List (stripPrefix)
5051import Data.Maybe (fromMaybe)
@@ -582,7 +583,7 @@ enclosedInlines :: (PandocMonad m, Show a, Show b)
582583 -> MuseParser m b
583584 -> MuseParser m (F Inlines)
584585enclosedInlines start end = try $
585− trimInlinesF . mconcat <$> enclosed start end inline
586+ trimInlinesF . mconcat <$> (enclosed start end inline <* notFollowedBy (satisfy isLetter))
586587
587588inlineTag :: PandocMonad m
588589 => (Inlines -> Inlines)
@@ -629,7 +630,7 @@ code = try $ do
629630 guard $ not $ null contents
630631 guard $ head contents `notElem` " \t\n"
631632 guard $ last contents `notElem` " \t\n"
632− notFollowedBy nonspaceChar
633+ notFollowedBy $ satisfy isLetter
633634 return $ return (sp B.<> B.code contents)
634635
635636codeTag :: PandocMonad m => MuseParser m (F Inlines)
test/Tests/Readers/Muse.hs+18−2
@@ -34,9 +34,21 @@ tests =
3434 "Hello, World" =?>
3535 para "Hello, World"
3636
37− , "Emphasis" =: "*Foo bar*" =?> para (emph . spcSep $ ["Foo", "bar"])
37+ , "Emphasis" =:
38+ "*Foo bar*" =?>
39+ para (emph . spcSep $ ["Foo", "bar"])
3840
39− , "Emphasis tag" =: "<em>Foo bar</em>" =?> para (emph . spcSep $ ["Foo", "bar"])
41+ , "Comma after closing *" =:
42+ "Foo *bar*, baz" =?>
43+ para ("Foo " <> emph "bar" <> ", baz")
44+
45+ , "Letter after closing *" =:
46+ "Foo *bar*x baz" =?>
47+ para "Foo *bar*x baz"
48+
49+ , "Emphasis tag" =:
50+ "<em>Foo bar</em>" =?>
51+ para (emph . spcSep $ ["Foo", "bar"])
4052
4153 , "Strong" =:
4254 "**Cider**" =?>
@@ -82,6 +94,10 @@ tests =
8294
8395 , "Not code if opening = is detached" =: "= this is not a code=" =?> para "= this is not a code="
8496
97+ , "Code if followed by comma" =:
98+ "Foo =bar=, baz" =?>
99+ para (text "Foo " <> code "bar" <> text ", baz")
100+
85101 , "One character code" =: "=c=" =?> para (code "c")
86102
87103 , "Three = characters is not a code" =: "===" =?> para "==="