git.iko.soy/typeable/pandoc
on master help sign in
Muse writer: improve span writing

Test more cases when span has or hasn't anchor, class and contents in different combinations.

commit4a8993f9b008a0ff223b5a1e283ae9e21a66c5c0 authorAlexander Krotov <ilabdsf@gmail.com> dateSun 25 Mar 2018, 01:18 (9 years ago) parentd58b961
2 files changed+13−5
src/Text/Pandoc/Writers/Muse.hs+5−3 test/Tests/Writers/Muse.hs+8−2
src/Text/Pandoc/Writers/Muse.hs+5−3
@@ -441,6 +441,8 @@ inlineToMuse (Span (anchor,names,_) inlines) = do
441441 let anchorDoc = if null anchor
442442 then mempty
443443 else text ('#':anchor) <> space
444− return $ anchorDoc <> if null names
445− then contents
446− else "<class name=\"" <> text (head names) <> "\">" <> contents <> "</class>"
444+ return $ anchorDoc <> (if null inlines && not (null anchor)
445+ then mempty
446+ else (if null names
447+ then "<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"
400400 , "[1] Foo"
401401 ]
402402 , "span with class" =: spanWith ("",["foobar"],[]) (text "Some text")
403− =?> "<class name=\"foobar\">Some text</class>"
404− , "span with anchor" =: spanWith ("anchor", [], []) (text "Foo bar")
403+ =?> "<class name=\"foobar\">Some text</class>"
404+ , "span without class" =: spanWith ("",[],[]) (text "Some text")
405+ =?> "<class>Some text</class>"
406+ , "span with anchor" =: spanWith ("anchor", [], []) (mempty) <> (text "Foo bar")
405407 =?> "#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>"
406412 , "span with class and anchor" =: spanWith ("anchor", ["foo"], []) (text "bar")
407413 =?> "#anchor <class name=\"foo\">bar</class>"
408414 , "adjacent spans" =: spanWith ("", ["syllable"], []) (str "wa") <>