Muse reader: don't allow emphasis to be preceded by letter
This commit is contained in:
parent
12789fd42a
commit
3ae359721d
2 changed files with 16 additions and 2 deletions
|
@ -136,6 +136,13 @@ commonPrefix (x:xs) (y:ys)
|
||||||
| x == y = x : commonPrefix xs ys
|
| x == y = x : commonPrefix xs ys
|
||||||
| otherwise = []
|
| 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
|
-- directive parsers
|
||||||
--
|
--
|
||||||
|
@ -668,7 +675,7 @@ enclosedInlines :: (PandocMonad m, Show a, Show b)
|
||||||
-> MuseParser m b
|
-> MuseParser m b
|
||||||
-> MuseParser m (F Inlines)
|
-> MuseParser m (F Inlines)
|
||||||
enclosedInlines start end = try $
|
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
|
inlineTag :: PandocMonad m
|
||||||
=> (Inlines -> Inlines)
|
=> (Inlines -> Inlines)
|
||||||
|
@ -745,7 +752,10 @@ inlineLiteralTag = do
|
||||||
rawInline (attrs, content) = B.rawInline (format attrs) content
|
rawInline (attrs, content) = B.rawInline (format attrs) content
|
||||||
|
|
||||||
str :: PandocMonad m => MuseParser m (F Inlines)
|
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 :: PandocMonad m => MuseParser m (F Inlines)
|
||||||
symbol = return . B.str <$> count 1 nonspaceChar
|
symbol = return . B.str <$> count 1 nonspaceChar
|
||||||
|
|
|
@ -70,6 +70,10 @@ tests =
|
||||||
"Foo *bar*x baz" =?>
|
"Foo *bar*x baz" =?>
|
||||||
para "Foo *bar*x baz"
|
para "Foo *bar*x baz"
|
||||||
|
|
||||||
|
, "Letter before opening *" =:
|
||||||
|
"Foo x*bar* baz" =?>
|
||||||
|
para "Foo x*bar* baz"
|
||||||
|
|
||||||
, "Emphasis tag" =:
|
, "Emphasis tag" =:
|
||||||
"<em>Foo bar</em>" =?>
|
"<em>Foo bar</em>" =?>
|
||||||
para (emph . spcSep $ ["Foo", "bar"])
|
para (emph . spcSep $ ["Foo", "bar"])
|
||||||
|
|
Loading…
Add table
Reference in a new issue