@@ -291,6 +291,14 @@ conditionalEscapeString s =
291 then escapeString s
291 then escapeString s
294+-- Expand Math before normalizing inline list
295+preprocessInlineList :: PandocMonad m
298+preprocessInlineList (Math t str:xs) = (++ xs) <$> texMathToInlines t str
299+preprocessInlineList (x:xs) = (x:) <$> preprocessInlineList xs
300+preprocessInlineList [] = return []
294normalizeInlineList :: [Inline] -> [Inline]
302normalizeInlineList :: [Inline] -> [Inline]
295normalizeInlineList (x : Str "" : xs)
303normalizeInlineList (x : Str "" : xs)
296 = normalizeInlineList (x:xs)
304 = normalizeInlineList (x:xs)
@@ -327,7 +335,9 @@ fixNotes (x:xs) = x : fixNotes xs
327inlineListToMuse :: PandocMonad m
335inlineListToMuse :: PandocMonad m
328 => [Inline]
336 => [Inline]
329 -> StateT WriterState m Doc
337 -> StateT WriterState m Doc
338+inlineListToMuse lst = do
339+ lst' <- preprocessInlineList lst
330−inlineListToMuse lst = hcat <$> mapM inlineToMuse (fixNotes $ normalizeInlineList lst)
340+ hcat <$> mapM inlineToMuse (fixNotes $ normalizeInlineList lst')
332-- | Convert Pandoc inline element to Muse.
342-- | Convert Pandoc inline element to Muse.
333inlineToMuse :: PandocMonad m
343inlineToMuse :: PandocMonad m
@@ -363,8 +373,8 @@ inlineToMuse (Quoted DoubleQuote lst) = do
363inlineToMuse (Cite _ lst) = inlineListToMuse lst
373inlineToMuse (Cite _ lst) = inlineListToMuse lst
364inlineToMuse (Code _ str) = return $
374inlineToMuse (Code _ str) = return $
365 "<code>" <> text (substitute "</code>" "<</code><code>/code>" str) <> "</code>"
375 "<code>" <> text (substitute "</code>" "<</code><code>/code>" str) <> "</code>"
366−inlineToMuse (Math t str) =
376+inlineToMuse Math{} =
367− lift (texMathToInlines t str) >>= inlineListToMuse
377+ fail "Math should be expanded before normalization"
368inlineToMuse (RawInline (Format f) str) =
378inlineToMuse (RawInline (Format f) str) =
369 return $ "<literal style=\"" <> text f <> "\">" <> text str <> "</literal>"
379 return $ "<literal style=\"" <> text f <> "\">" <> text str <> "</literal>"
370inlineToMuse LineBreak = return $ "<br>" <> cr
380inlineToMuse LineBreak = return $ "<br>" <> cr