git.iko.soy/typeable/pandoc
on master help sign in
Muse writer: remove key-value pairs from attributes before normalization
bc0025dAlexander Krotov
src/Text/Pandoc/Writers/Muse.hs+8−1
@@ -312,6 +312,13 @@ replaceSmallCaps :: Inline -> Inline
312replaceSmallCaps (SmallCaps lst) = Emph lst
312replaceSmallCaps (SmallCaps lst) = Emph lst
313replaceSmallCaps x = x
313replaceSmallCaps x = x
314
314
315+removeKeyValues :: Inline -> Inline
316+removeKeyValues (Code (i, cls, _) xs) = Code (i, cls, []) xs
317+-- Do not remove attributes from Link
318+-- Do not remove attributes, such as "width", from Image
319+removeKeyValues (Span (i, cls, _) xs) = Span (i, cls, []) xs
320+removeKeyValues x = x
321+
315normalizeInlineList :: [Inline] -> [Inline]
322normalizeInlineList :: [Inline] -> [Inline]
316normalizeInlineList (Str "" : xs)
323normalizeInlineList (Str "" : xs)
317 = normalizeInlineList xs
324 = normalizeInlineList xs
@@ -356,7 +363,7 @@ inlineListToMuse :: PandocMonad m
356 => [Inline]
363 => [Inline]
357 -> StateT WriterState m Doc
364 -> StateT WriterState m Doc
358inlineListToMuse lst = do
365inlineListToMuse lst = do
359− lst' <- normalizeInlineList <$> preprocessInlineList (map replaceSmallCaps lst)
366+ lst' <- normalizeInlineList <$> preprocessInlineList (map (removeKeyValues . replaceSmallCaps) lst)
360 if null lst'
367 if null lst'
361 then pure "<verbatim></verbatim>"
368 then pure "<verbatim></verbatim>"
362 else hcat <$> mapM inlineToMuse (fixNotes lst')
369 else hcat <$> mapM inlineToMuse (fixNotes lst')