git.iko.soy/typeable/pandoc
on master help sign in
Muse writer: replace smallcaps with emphasis before normalization
commit1884ee60838ffeac090cafc9cf7fe2e44ad33636 authorAlexander Krotov <ilabdsf@gmail.com> dateWed 7 Mar 2018, 20:10 (9 years ago) parentff8e59a
2 files changed+8−2
src/Text/Pandoc/Writers/Muse.hs+7−2 test/Tests/Writers/Muse.hs+1
src/Text/Pandoc/Writers/Muse.hs+7−2
@@ -305,6 +305,10 @@ preprocessInlineList (Cite _ lst:xs) = (lst ++) <$> preprocessInlineList xs
305305preprocessInlineList (x:xs) = (x:) <$> preprocessInlineList xs
306306preprocessInlineList [] = return []
307307
308+replaceSmallCaps :: Inline -> Inline
309+replaceSmallCaps (SmallCaps lst) = Emph lst
310+replaceSmallCaps x = x
311+
308312normalizeInlineList :: [Inline] -> [Inline]
309313normalizeInlineList (Str "" : xs)
310314 = normalizeInlineList xs
@@ -344,7 +348,7 @@ inlineListToMuse :: PandocMonad m
344348 => [Inline]
345349 -> StateT WriterState m Doc
346350inlineListToMuse lst = do
347− lst' <- normalizeInlineList <$> preprocessInlineList lst
351+ lst' <- normalizeInlineList <$> preprocessInlineList (map replaceSmallCaps lst)
348352 if null lst'
349353 then pure "<verbatim></verbatim>"
350354 else hcat <$> mapM inlineToMuse (fixNotes lst')
@@ -369,7 +373,8 @@ inlineToMuse (Superscript lst) = do
369373inlineToMuse (Subscript lst) = do
370374 contents <- inlineListToMuse lst
371375 return $ "<sub>" <> contents <> "</sub>"
372−inlineToMuse (SmallCaps lst) = inlineToMuse (Emph lst)
376+inlineToMuse (SmallCaps {}) =
377+ fail "SmallCaps should be expanded before normalization"
373378inlineToMuse (Quoted SingleQuote lst) = do
374379 contents <- inlineListToMuse lst
375380 return $ "‘" <> contents <> "’"
test/Tests/Writers/Muse.hs+1
@@ -328,6 +328,7 @@ tests = [ testGroup "block elements"
328328 , "superscript" =: superscript (text "foo") =?> "<sup>foo</sup>"
329329 , "subscript" =: subscript (text "foo") =?> "<sub>foo</sub>"
330330 , "smallcaps" =: smallcaps (text "foo") =?> "<em>foo</em>"
331+ , "smallcaps near emphasis" =: emph (str "foo") <> smallcaps (str "bar") =?> "<em>foobar</em>"
331332 , "single quoted" =: singleQuoted (text "foo") =?> "‘foo’"
332333 , "double quoted" =: doubleQuoted (text "foo") =?> "“foo”"
333334 -- Cite is trivial