Add --atx-headers support to asciidoc and dont print empty identifier blocks ([[]]) on headers

This commit is contained in:
Max Rydahl Andersen 2013-05-31 00:09:33 +02:00
parent 7998587810
commit 2e868c8251

View file

@ -131,13 +131,22 @@ blockToAsciiDoc _ HorizontalRule =
blockToAsciiDoc opts (Header level (ident,_,_) inlines) = do
contents <- inlineListToAsciiDoc opts inlines
let len = offset contents
return $ ("[[" <> text ident <> "]]") $$ contents $$
-- ident seem to be empty most of the time and asciidoc will generate them automatically
-- so lets make them not show up when null
let identifier = if (null ident) then empty else ("[[" <> text ident <> "]]")
let setext = writerSetextHeaders opts
return $
(if setext
then
identifier $$ contents $$
(case level of
1 -> text $ replicate len '-'
2 -> text $ replicate len '~'
3 -> text $ replicate len '^'
4 -> text $ replicate len '+'
_ -> empty) <> blankline
else
identifier $$ text (replicate level '=') <> space <> contents <> blankline)
blockToAsciiDoc _ (CodeBlock (_,classes,_) str) = return $
flush (attrs <> dashes <> space <> attrs <> cr <> text str <>
cr <> dashes) <> blankline