Muse writer: improve span writing
Test more cases when span has or hasn't anchor, class and contents in different combinations.
This commit is contained in:
parent
d58b961a6d
commit
4a8993f9b0
2 changed files with 13 additions and 5 deletions
|
@ -441,6 +441,8 @@ inlineToMuse (Span (anchor,names,_) inlines) = do
|
||||||
let anchorDoc = if null anchor
|
let anchorDoc = if null anchor
|
||||||
then mempty
|
then mempty
|
||||||
else text ('#':anchor) <> space
|
else text ('#':anchor) <> space
|
||||||
return $ anchorDoc <> if null names
|
return $ anchorDoc <> (if null inlines && not (null anchor)
|
||||||
then contents
|
then mempty
|
||||||
else "<class name=\"" <> text (head names) <> "\">" <> contents <> "</class>"
|
else (if null names
|
||||||
|
then "<class>"
|
||||||
|
else "<class name=\"" <> text (head names) <> "\">") <> contents <> "</class>")
|
||||||
|
|
|
@ -400,9 +400,15 @@ tests = [ testGroup "block elements"
|
||||||
, "[1] Foo"
|
, "[1] Foo"
|
||||||
]
|
]
|
||||||
, "span with class" =: spanWith ("",["foobar"],[]) (text "Some text")
|
, "span with class" =: spanWith ("",["foobar"],[]) (text "Some text")
|
||||||
=?> "<class name=\"foobar\">Some text</class>"
|
=?> "<class name=\"foobar\">Some text</class>"
|
||||||
, "span with anchor" =: spanWith ("anchor", [], []) (text "Foo bar")
|
, "span without class" =: spanWith ("",[],[]) (text "Some text")
|
||||||
|
=?> "<class>Some text</class>"
|
||||||
|
, "span with anchor" =: spanWith ("anchor", [], []) (mempty) <> (text "Foo bar")
|
||||||
=?> "#anchor Foo bar"
|
=?> "#anchor Foo bar"
|
||||||
|
, "empty span with anchor" =: spanWith ("anchor", [], []) (mempty)
|
||||||
|
=?> "#anchor"
|
||||||
|
, "empty span without class and anchor" =: spanWith ("", [], []) (mempty)
|
||||||
|
=?> "<class><verbatim></verbatim></class>"
|
||||||
, "span with class and anchor" =: spanWith ("anchor", ["foo"], []) (text "bar")
|
, "span with class and anchor" =: spanWith ("anchor", ["foo"], []) (text "bar")
|
||||||
=?> "#anchor <class name=\"foo\">bar</class>"
|
=?> "#anchor <class name=\"foo\">bar</class>"
|
||||||
, "adjacent spans" =: spanWith ("", ["syllable"], []) (str "wa") <>
|
, "adjacent spans" =: spanWith ("", ["syllable"], []) (str "wa") <>
|
||||||
|
|
Loading…
Reference in a new issue