aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/Text/Pandoc/Writers/Muse.hs37
-rw-r--r--test/Tests/Writers/Muse.hs1
2 files changed, 19 insertions, 19 deletions
diff --git a/src/Text/Pandoc/Writers/Muse.hs b/src/Text/Pandoc/Writers/Muse.hs
index 87c6c58da..7dbe3a53f 100644
--- a/src/Text/Pandoc/Writers/Muse.hs
+++ b/src/Text/Pandoc/Writers/Muse.hs
@@ -420,11 +420,6 @@ endsWithSpace [SoftBreak] = True
endsWithSpace (_:xs) = endsWithSpace xs
endsWithSpace [] = False
-emptyInlines :: [Inline] -> Bool
-emptyInlines [] = True
-emptyInlines (Str "":xs) = emptyInlines xs
-emptyInlines _ = False
-
urlEscapeBrackets :: String -> String
urlEscapeBrackets (']':xs) = '%':'5':'D':urlEscapeBrackets xs
urlEscapeBrackets (x:xs) = x:urlEscapeBrackets xs
@@ -518,49 +513,53 @@ inlineToMuse (Str str) = do
return $ text escapedStr
inlineToMuse (Emph [Strong lst]) = do
useTags <- gets stUseTags
+ let lst' = normalizeInlineList lst
if useTags
- then do contents <- local (\env -> env { envInsideAsterisks = True }) $ inlineListToMuse lst
+ then do contents <- local (\env -> env { envInsideAsterisks = True }) $ inlineListToMuse lst'
modify $ \st -> st { stUseTags = False }
return $ "<em>**" <> contents <> "**</em>"
- else if emptyInlines lst || startsWithSpace lst || endsWithSpace lst
+ else if null lst' || startsWithSpace lst' || endsWithSpace lst'
then do
- contents <- local (\env -> env { envInsideAsterisks = False }) $ inlineListToMuse lst
+ contents <- local (\env -> env { envInsideAsterisks = False }) $ inlineListToMuse lst'
modify $ \st -> st { stUseTags = True }
return $ "*<strong>" <> contents <> "</strong>*"
else do
- contents <- local (\env -> env { envInsideAsterisks = True }) $ inlineListToMuse lst
+ contents <- local (\env -> env { envInsideAsterisks = True }) $ inlineListToMuse lst'
modify $ \st -> st { stUseTags = True }
return $ "***" <> contents <> "***"
inlineToMuse (Emph lst) = do
useTags <- gets stUseTags
- if useTags || emptyInlines lst || startsWithSpace lst || endsWithSpace lst
- then do contents <- inlineListToMuse lst
+ let lst' = normalizeInlineList lst
+ if useTags || null lst' || startsWithSpace lst' || endsWithSpace lst'
+ then do contents <- inlineListToMuse lst'
return $ "<em>" <> contents <> "</em>"
- else do contents <- local (\env -> env { envInsideAsterisks = True }) $ inlineListToMuse lst
+ else do contents <- local (\env -> env { envInsideAsterisks = True }) $ inlineListToMuse lst'
modify $ \st -> st { stUseTags = True }
return $ "*" <> contents <> "*"
inlineToMuse (Strong [Emph lst]) = do
useTags <- gets stUseTags
+ let lst' = normalizeInlineList lst
if useTags
- then do contents <- local (\env -> env { envInsideAsterisks = True }) $ inlineListToMuse lst
+ then do contents <- local (\env -> env { envInsideAsterisks = True }) $ inlineListToMuse lst'
modify $ \st -> st { stUseTags = False }
return $ "<strong>*" <> contents <> "*</strong>"
- else if emptyInlines lst || startsWithSpace lst || endsWithSpace lst
+ else if null lst' || startsWithSpace lst' || endsWithSpace lst'
then do
- contents <- local (\env -> env { envInsideAsterisks = False }) $ inlineListToMuse lst
+ contents <- local (\env -> env { envInsideAsterisks = False }) $ inlineListToMuse lst'
modify $ \st -> st { stUseTags = True }
return $ "**<em>" <> contents <> "</em>**"
else do
- contents <- local (\env -> env { envInsideAsterisks = True }) $ inlineListToMuse lst
+ contents <- local (\env -> env { envInsideAsterisks = True }) $ inlineListToMuse lst'
modify $ \st -> st { stUseTags = True }
return $ "***" <> contents <> "***"
inlineToMuse (Strong lst) = do
useTags <- gets stUseTags
- if useTags || emptyInlines lst || startsWithSpace lst || endsWithSpace lst
- then do contents <- inlineListToMuse lst
+ let lst' = normalizeInlineList lst
+ if useTags || null lst' || startsWithSpace lst' || endsWithSpace lst'
+ then do contents <- inlineListToMuse lst'
modify $ \st -> st { stUseTags = False }
return $ "<strong>" <> contents <> "</strong>"
- else do contents <- local (\env -> env { envInsideAsterisks = True }) $ inlineListToMuse lst
+ else do contents <- local (\env -> env { envInsideAsterisks = True }) $ inlineListToMuse lst'
modify $ \st -> st { stUseTags = True }
return $ "**" <> contents <> "**"
inlineToMuse (Strikeout lst) = do
diff --git a/test/Tests/Writers/Muse.hs b/test/Tests/Writers/Muse.hs
index c747578bf..776884760 100644
--- a/test/Tests/Writers/Muse.hs
+++ b/test/Tests/Writers/Muse.hs
@@ -366,6 +366,7 @@ tests = [ testGroup "block elements"
, "strong empty string" =: strong (str "") =?> "<strong></strong>"
, "strong emphasized empty string" =: strong (emph (str "")) =?> "**<em></em>**"
, "emphasized strong empty string" =: emph (strong (str "")) =?> "*<strong></strong>*"
+ , "emphasized space between empty strings" =: emph (str "" <> space <> str "") =?> "<em> </em>"
, "strong" =: strong (text "foo") =?> "**foo**"
, "strong inside word" =: text "foo" <> strong (text "bar") <> text "baz" =?> "foo<strong>bar</strong>baz"
, "strong emphasis" =: strong (emph (text "foo")) =?> "***foo***"