diff options
author | Alexander Krotov <ilabdsf@gmail.com> | 2017-12-06 19:04:35 +0300 |
---|---|---|
committer | Alexander Krotov <ilabdsf@gmail.com> | 2017-12-06 19:04:35 +0300 |
commit | 3ae359721d174205582cd5bd3b13525493e10619 (patch) | |
tree | e47b42be729295f17de474da800c2dde4598f903 | |
parent | 12789fd42a15126751018f7a392d08a05c68c210 (diff) | |
download | pandoc-3ae359721d174205582cd5bd3b13525493e10619.tar.gz |
Muse reader: don't allow emphasis to be preceded by letter
-rw-r--r-- | src/Text/Pandoc/Readers/Muse.hs | 14 | ||||
-rw-r--r-- | test/Tests/Readers/Muse.hs | 4 |
2 files changed, 16 insertions, 2 deletions
diff --git a/src/Text/Pandoc/Readers/Muse.hs b/src/Text/Pandoc/Readers/Muse.hs index 39aa67f82..72344bfe0 100644 --- a/src/Text/Pandoc/Readers/Muse.hs +++ b/src/Text/Pandoc/Readers/Muse.hs @@ -136,6 +136,13 @@ commonPrefix (x:xs) (y:ys) | x == y = x : commonPrefix xs ys | otherwise = [] +atStart :: PandocMonad m => MuseParser m a -> MuseParser m a +atStart p = do + pos <- getPosition + st <- getState + guard $ stateLastStrPos st /= Just pos + p + -- -- directive parsers -- @@ -668,7 +675,7 @@ enclosedInlines :: (PandocMonad m, Show a, Show b) -> MuseParser m b -> MuseParser m (F Inlines) enclosedInlines start end = try $ - trimInlinesF . mconcat <$> (enclosed start end inline <* notFollowedBy (satisfy isLetter)) + trimInlinesF . mconcat <$> (enclosed (atStart start) end inline <* notFollowedBy (satisfy isLetter)) inlineTag :: PandocMonad m => (Inlines -> Inlines) @@ -745,7 +752,10 @@ inlineLiteralTag = do rawInline (attrs, content) = B.rawInline (format attrs) content str :: PandocMonad m => MuseParser m (F Inlines) -str = return . B.str <$> many1 alphaNum +str = do + result <- many1 alphaNum + updateLastStrPos + return $ return $ B.str result symbol :: PandocMonad m => MuseParser m (F Inlines) symbol = return . B.str <$> count 1 nonspaceChar diff --git a/test/Tests/Readers/Muse.hs b/test/Tests/Readers/Muse.hs index 3a3d7d864..51e249fb4 100644 --- a/test/Tests/Readers/Muse.hs +++ b/test/Tests/Readers/Muse.hs @@ -70,6 +70,10 @@ tests = "Foo *bar*x baz" =?> para "Foo *bar*x baz" + , "Letter before opening *" =: + "Foo x*bar* baz" =?> + para "Foo x*bar* baz" + , "Emphasis tag" =: "<em>Foo bar</em>" =?> para (emph . spcSep $ ["Foo", "bar"]) |