git.iko.soy/typeable/pandoc
on master help sign in
Muse writer: improve span writing
4a8993fAlexander Krotov
src/Text/Pandoc/Writers/Muse.hs+5−3
@@ -441,6 +441,8 @@ inlineToMuse (Span (anchor,names,_) inlines) = do
441 let anchorDoc = if null anchor
441 let anchorDoc = if null anchor
442 then mempty
442 then mempty
443 else text ('#':anchor) <> space
443 else text ('#':anchor) <> space
444+ return $ anchorDoc <> (if null inlines && not (null anchor)
445+ then mempty
444− return $ anchorDoc <> if null names
446+ else (if null names
445− then contents
447+ then "<class>"
446− else "<class name=\"" <> text (head names) <> "\">" <> contents <> "</class>"
448+ else "<class name=\"" <> text (head names) <> "\">") <> contents <> "</class>")
test/Tests/Writers/Muse.hs+8−2
@@ -400,9 +400,15 @@ tests = [ testGroup "block elements"
400 , "[1] Foo"
400 , "[1] Foo"
401 ]
401 ]
402 , "span with class" =: spanWith ("",["foobar"],[]) (text "Some text")
402 , "span with class" =: spanWith ("",["foobar"],[]) (text "Some text")
403− =?> "<class name=\"foobar\">Some text</class>"
403+ =?> "<class name=\"foobar\">Some text</class>"
404+ , "span without class" =: spanWith ("",[],[]) (text "Some text")
405+ =?> "<class>Some text</class>"
404− , "span with anchor" =: spanWith ("anchor", [], []) (text "Foo bar")
406+ , "span with anchor" =: spanWith ("anchor", [], []) (mempty) <> (text "Foo bar")
405 =?> "#anchor Foo bar"
407 =?> "#anchor Foo bar"
408+ , "empty span with anchor" =: spanWith ("anchor", [], []) (mempty)
409+ =?> "#anchor"
410+ , "empty span without class and anchor" =: spanWith ("", [], []) (mempty)
411+ =?> "<class><verbatim></verbatim></class>"
406 , "span with class and anchor" =: spanWith ("anchor", ["foo"], []) (text "bar")
412 , "span with class and anchor" =: spanWith ("anchor", ["foo"], []) (text "bar")
407 =?> "#anchor <class name=\"foo\">bar</class>"
413 =?> "#anchor <class name=\"foo\">bar</class>"
408 , "adjacent spans" =: spanWith ("", ["syllable"], []) (str "wa") <>
414 , "adjacent spans" =: spanWith ("", ["syllable"], []) (str "wa") <>