Muse writer: do not escape empty line after <br>

This commit is contained in:
Alexander Krotov 2019-05-25 17:54:31 +03:00
parent 20144a205e
commit 19f9eed0bb
2 changed files with 6 additions and 4 deletions

View file

@ -510,9 +510,7 @@ inlineListStartsWithAlnum _ = return False
renderInlineList :: PandocMonad m
=> [Inline]
-> Muse m Doc
renderInlineList [] = do
start <- asks envInlineStart
pure $ if start then "<verbatim></verbatim>" else ""
renderInlineList [] = pure ""
renderInlineList (x:xs) = do
start <- asks envInlineStart
afterSpace <- asks envAfterSpace
@ -545,8 +543,11 @@ inlineListToMuse :: PandocMonad m
inlineListToMuse lst = do
lst' <- normalizeInlineList . fixNotes <$> preprocessInlineList (map (removeKeyValues . replaceSmallCaps) lst)
insideAsterisks <- asks envInsideAsterisks
start <- asks envInlineStart
modify $ \st -> st { stUseTags = False } -- Previous character is likely a '>' or some other markup
local (\env -> env { envNearAsterisks = insideAsterisks }) $ renderInlineList lst'
if start && null lst'
then pure "<verbatim></verbatim>"
else local (\env -> env { envNearAsterisks = insideAsterisks }) $ renderInlineList lst'
inlineListToMuse' :: PandocMonad m => [Inline] -> Muse m Doc
inlineListToMuse' lst = do

View file

@ -545,6 +545,7 @@ tests = [ testGroup "block elements"
"remove soft break" $ "a" <> softbreak <> "b"
=?> ("a b" :: String)
, "line break" =: "a" <> linebreak <> "b" =?> "a<br>\nb"
, "line break at the end" =: "a" <> linebreak =?> "a<br>"
, "no newline after line break in header" =: header 1 ("a" <> linebreak <> "b") =?> "* a<br>b"
, "no softbreak in header" =: header 1 ("a" <> softbreak <> "b") =?> "* a b"
]