diff options
author | Max Rydahl Andersen <max@jboss.org> | 2013-05-31 00:09:33 +0200 |
---|---|---|
committer | Max Rydahl Andersen <max@jboss.org> | 2013-05-31 01:34:46 +0200 |
commit | 2e868c82518a2cff5eaf3b843875befa86bc3bfb (patch) | |
tree | 9dfceeb17af541ec8ca313739d4f33fb27895f7a /src/Text/Pandoc | |
parent | 7998587810cea2db2970a544b316bad7932eae38 (diff) | |
download | pandoc-2e868c82518a2cff5eaf3b843875befa86bc3bfb.tar.gz |
Add --atx-headers support to asciidoc and dont print empty identifier blocks ([[]]) on headers
Diffstat (limited to 'src/Text/Pandoc')
-rw-r--r-- | src/Text/Pandoc/Writers/AsciiDoc.hs | 13 |
1 files changed, 11 insertions, 2 deletions
diff --git a/src/Text/Pandoc/Writers/AsciiDoc.hs b/src/Text/Pandoc/Writers/AsciiDoc.hs index 3718431e2..16ce452ef 100644 --- a/src/Text/Pandoc/Writers/AsciiDoc.hs +++ b/src/Text/Pandoc/Writers/AsciiDoc.hs @@ -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 $$ - (case level of + -- 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 |