diff options
-rw-r--r-- | src/Text/Pandoc/Writers/Muse.hs | 8 | ||||
-rw-r--r-- | test/Tests/Writers/Muse.hs | 10 |
2 files changed, 13 insertions, 5 deletions
diff --git a/src/Text/Pandoc/Writers/Muse.hs b/src/Text/Pandoc/Writers/Muse.hs index 6ecd826fa..128e2c6f9 100644 --- a/src/Text/Pandoc/Writers/Muse.hs +++ b/src/Text/Pandoc/Writers/Muse.hs @@ -441,6 +441,8 @@ inlineToMuse (Span (anchor,names,_) inlines) = do let anchorDoc = if null anchor then mempty else text ('#':anchor) <> space - return $ anchorDoc <> if null names - then contents - else "<class name=\"" <> text (head names) <> "\">" <> contents <> "</class>" + return $ anchorDoc <> (if null inlines && not (null anchor) + then mempty + else (if null names + then "<class>" + else "<class name=\"" <> text (head names) <> "\">") <> contents <> "</class>") diff --git a/test/Tests/Writers/Muse.hs b/test/Tests/Writers/Muse.hs index 1218bc7c9..c3a6a9d62 100644 --- a/test/Tests/Writers/Muse.hs +++ b/test/Tests/Writers/Muse.hs @@ -400,9 +400,15 @@ tests = [ testGroup "block elements" , "[1] Foo" ] , "span with class" =: spanWith ("",["foobar"],[]) (text "Some text") - =?> "<class name=\"foobar\">Some text</class>" - , "span with anchor" =: spanWith ("anchor", [], []) (text "Foo bar") + =?> "<class name=\"foobar\">Some text</class>" + , "span without class" =: spanWith ("",[],[]) (text "Some text") + =?> "<class>Some text</class>" + , "span with anchor" =: spanWith ("anchor", [], []) (mempty) <> (text "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") =?> "#anchor <class name=\"foo\">bar</class>" , "adjacent spans" =: spanWith ("", ["syllable"], []) (str "wa") <> |