diff options
author | Alexander Krotov <ilabdsf@gmail.com> | 2018-09-11 00:38:55 +0300 |
---|---|---|
committer | Alexander Krotov <ilabdsf@gmail.com> | 2018-09-11 00:39:37 +0300 |
commit | c2b97c4b8026694d9c59d7b9f6d333d204f669ce (patch) | |
tree | c0a1275fcd3be3b14a0692df16878e1710ab0620 /src/Text | |
parent | 7b52d43877d0351dcf0fd645127867a43978bc08 (diff) | |
download | pandoc-c2b97c4b8026694d9c59d7b9f6d333d204f669ce.tar.gz |
Muse writer: use tags instead of lightweight markup for empty strings
Diffstat (limited to 'src/Text')
-rw-r--r-- | src/Text/Pandoc/Writers/Muse.hs | 13 |
1 files changed, 9 insertions, 4 deletions
diff --git a/src/Text/Pandoc/Writers/Muse.hs b/src/Text/Pandoc/Writers/Muse.hs index 627358839..87c6c58da 100644 --- a/src/Text/Pandoc/Writers/Muse.hs +++ b/src/Text/Pandoc/Writers/Muse.hs @@ -420,6 +420,11 @@ 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 @@ -517,7 +522,7 @@ inlineToMuse (Emph [Strong lst]) = do then do contents <- local (\env -> env { envInsideAsterisks = True }) $ inlineListToMuse lst modify $ \st -> st { stUseTags = False } return $ "<em>**" <> contents <> "**</em>" - else if null lst || startsWithSpace lst || endsWithSpace lst + else if emptyInlines lst || startsWithSpace lst || endsWithSpace lst then do contents <- local (\env -> env { envInsideAsterisks = False }) $ inlineListToMuse lst modify $ \st -> st { stUseTags = True } @@ -528,7 +533,7 @@ inlineToMuse (Emph [Strong lst]) = do return $ "***" <> contents <> "***" inlineToMuse (Emph lst) = do useTags <- gets stUseTags - if useTags || null lst || startsWithSpace lst || endsWithSpace lst + if useTags || emptyInlines lst || startsWithSpace lst || endsWithSpace lst then do contents <- inlineListToMuse lst return $ "<em>" <> contents <> "</em>" else do contents <- local (\env -> env { envInsideAsterisks = True }) $ inlineListToMuse lst @@ -540,7 +545,7 @@ inlineToMuse (Strong [Emph lst]) = do then do contents <- local (\env -> env { envInsideAsterisks = True }) $ inlineListToMuse lst modify $ \st -> st { stUseTags = False } return $ "<strong>*" <> contents <> "*</strong>" - else if null lst || startsWithSpace lst || endsWithSpace lst + else if emptyInlines lst || startsWithSpace lst || endsWithSpace lst then do contents <- local (\env -> env { envInsideAsterisks = False }) $ inlineListToMuse lst modify $ \st -> st { stUseTags = True } @@ -551,7 +556,7 @@ inlineToMuse (Strong [Emph lst]) = do return $ "***" <> contents <> "***" inlineToMuse (Strong lst) = do useTags <- gets stUseTags - if useTags || null lst || startsWithSpace lst || endsWithSpace lst + if useTags || emptyInlines lst || startsWithSpace lst || endsWithSpace lst then do contents <- inlineListToMuse lst modify $ \st -> st { stUseTags = False } return $ "<strong>" <> contents <> "</strong>" |