git.iko.soy/typeable/pandoc
on master help sign in
Merge pull request #3917 from labdsf/muse-reader-emphasis-word
1307b02John MacFarlane
src/Text/Pandoc/Readers/Muse.hs+3−2
@@ -45,6 +45,7 @@ module Text.Pandoc.Readers.Muse (readMuse) where
45import Control.Monad
45import Control.Monad
46import Control.Monad.Except (throwError)
46import Control.Monad.Except (throwError)
47import qualified Data.Map as M
47import qualified Data.Map as M
48+import Data.Char (isLetter)
48import Data.Text (Text, unpack)
49import Data.Text (Text, unpack)
49import Data.List (stripPrefix)
50import Data.List (stripPrefix)
50import Data.Maybe (fromMaybe)
51import Data.Maybe (fromMaybe)
@@ -582,7 +583,7 @@ enclosedInlines :: (PandocMonad m, Show a, Show b)
582 -> MuseParser m b
583 -> MuseParser m b
583 -> MuseParser m (F Inlines)
584 -> MuseParser m (F Inlines)
584enclosedInlines start end = try $
585enclosedInlines start end = try $
585− trimInlinesF . mconcat <$> enclosed start end inline
586+ trimInlinesF . mconcat <$> (enclosed start end inline <* notFollowedBy (satisfy isLetter))
586
587
587inlineTag :: PandocMonad m
588inlineTag :: PandocMonad m
588 => (Inlines -> Inlines)
589 => (Inlines -> Inlines)
@@ -629,7 +630,7 @@ code = try $ do
629 guard $ not $ null contents
630 guard $ not $ null contents
630 guard $ head contents `notElem` " \t\n"
631 guard $ head contents `notElem` " \t\n"
631 guard $ last contents `notElem` " \t\n"
632 guard $ last contents `notElem` " \t\n"
632− notFollowedBy nonspaceChar
633+ notFollowedBy $ satisfy isLetter
633 return $ return (sp B.<> B.code contents)
634 return $ return (sp B.<> B.code contents)
634
635
635codeTag :: PandocMonad m => MuseParser m (F Inlines)
636codeTag :: PandocMonad m => MuseParser m (F Inlines)
test/Tests/Readers/Muse.hs+18−2
@@ -34,9 +34,21 @@ tests =
34 "Hello, World" =?>
34 "Hello, World" =?>
35 para "Hello, World"
35 para "Hello, World"
36
36
37+ , "Emphasis" =:
38+ "*Foo bar*" =?>
37− , "Emphasis" =: "*Foo bar*" =?> para (emph . spcSep $ ["Foo", "bar"])
39+ para (emph . spcSep $ ["Foo", "bar"])
38
40
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>" =?>
39− , "Emphasis tag" =: "<em>Foo bar</em>" =?> para (emph . spcSep $ ["Foo", "bar"])
51+ para (emph . spcSep $ ["Foo", "bar"])
40
52
41 , "Strong" =:
53 , "Strong" =:
42 "**Cider**" =?>
54 "**Cider**" =?>
@@ -82,6 +94,10 @@ tests =
82
94
83 , "Not code if opening = is detached" =: "= this is not a code=" =?> para "= this is not a code="
95 , "Not code if opening = is detached" =: "= this is not a code=" =?> para "= this is not a code="
84
96
97+ , "Code if followed by comma" =:
98+ "Foo =bar=, baz" =?>
99+ para (text "Foo " <> code "bar" <> text ", baz")
100+
85 , "One character code" =: "=c=" =?> para (code "c")
101 , "One character code" =: "=c=" =?> para (code "c")
86
102
87 , "Three = characters is not a code" =: "===" =?> para "==="
103 , "Three = characters is not a code" =: "===" =?> para "==="