From 7da6e4390cb6d812b67dca6720bb56f3963c05d5 Mon Sep 17 00:00:00 2001 From: Alexander Krotov Date: Mon, 5 Mar 2018 19:38:11 +0300 Subject: Muse writer: expand math before inline list normalization --- src/Text/Pandoc/Writers/Muse.hs | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) (limited to 'src/Text/Pandoc') diff --git a/src/Text/Pandoc/Writers/Muse.hs b/src/Text/Pandoc/Writers/Muse.hs index ad67e489d..1f6006b2e 100644 --- a/src/Text/Pandoc/Writers/Muse.hs +++ b/src/Text/Pandoc/Writers/Muse.hs @@ -291,6 +291,14 @@ conditionalEscapeString s = then escapeString s else s +-- Expand Math before normalizing inline list +preprocessInlineList :: PandocMonad m + => [Inline] + -> m [Inline] +preprocessInlineList (Math t str:xs) = (++ xs) <$> texMathToInlines t str +preprocessInlineList (x:xs) = (x:) <$> preprocessInlineList xs +preprocessInlineList [] = return [] + normalizeInlineList :: [Inline] -> [Inline] normalizeInlineList (x : Str "" : xs) = normalizeInlineList (x:xs) @@ -327,7 +335,9 @@ fixNotes (x:xs) = x : fixNotes xs inlineListToMuse :: PandocMonad m => [Inline] -> StateT WriterState m Doc -inlineListToMuse lst = hcat <$> mapM inlineToMuse (fixNotes $ normalizeInlineList lst) +inlineListToMuse lst = do + lst' <- preprocessInlineList lst + hcat <$> mapM inlineToMuse (fixNotes $ normalizeInlineList lst') -- | Convert Pandoc inline element to Muse. inlineToMuse :: PandocMonad m @@ -363,8 +373,8 @@ inlineToMuse (Quoted DoubleQuote lst) = do inlineToMuse (Cite _ lst) = inlineListToMuse lst inlineToMuse (Code _ str) = return $ "" <> text (substitute "" "</code>" str) <> "" -inlineToMuse (Math t str) = - lift (texMathToInlines t str) >>= inlineListToMuse +inlineToMuse Math{} = + fail "Math should be expanded before normalization" inlineToMuse (RawInline (Format f) str) = return $ " text f <> "\">" <> text str <> "" inlineToMuse LineBreak = return $ "
" <> cr -- cgit v1.2.3