git.iko.soy/typeable/pandoc
on master help sign in
Muse writer: support spans with anchors
commit19fd98e452ee1f7be902735ac76500306672f2e7 authorAlexander Krotov <ilabdsf@gmail.com> dateMon 12 Mar 2018, 01:40 (9 years ago) parent9bcd090
2 files changed+12−4
src/Text/Pandoc/Writers/Muse.hs+7−3 test/Tests/Writers/Muse.hs+5−1
src/Text/Pandoc/Writers/Muse.hs+7−3
@@ -424,7 +424,11 @@ inlineToMuse (Note contents) = do
424424 modify $ \st -> st { stNotes = contents:notes }
425425 let ref = show $ length notes + 1
426426 return $ "[" <> text ref <> "]"
427−inlineToMuse (Span (_,name:_,_) inlines) = do
427+inlineToMuse (Span (anchor,names,_) inlines) = do
428428 contents <- inlineListToMuse inlines
429− return $ "<class name=\"" <> text name <> "\">" <> contents <> "</class>"
430−inlineToMuse (Span _ lst) = inlineListToMuse lst
429+ let anchorDoc = if null anchor
430+ then mempty
431+ else text ('#':anchor) <> space
432+ return $ anchorDoc <> if null names
433+ then contents
434+ else "<class name=\"" <> text (head names) <> "\">" <> contents <> "</class>"
test/Tests/Writers/Muse.hs+5−1
@@ -380,8 +380,12 @@ tests = [ testGroup "block elements"
380380 , ""
381381 , "[1] Foo"
382382 ]
383− , "span" =: spanWith ("",["foobar"],[]) (str "Some text")
383+ , "span with class" =: spanWith ("",["foobar"],[]) (text "Some text")
384384 =?> "<class name=\"foobar\">Some text</class>"
385+ , "span with anchor" =: spanWith ("anchor", [], []) (text "Foo bar")
386+ =?> "#anchor Foo bar"
387+ , "span with class and anchor" =: spanWith ("anchor", ["foo"], []) (text "bar")
388+ =?> "#anchor <class name=\"foo\">bar</class>"
385389 , testGroup "combined"
386390 [ "emph word before" =:
387391 para (text "foo" <> emph (text "bar")) =?>