diff options
author | John MacFarlane <jgm@berkeley.edu> | 2013-05-30 17:01:14 -0700 |
---|---|---|
committer | John MacFarlane <jgm@berkeley.edu> | 2013-05-30 17:01:14 -0700 |
commit | 4c8fda30e6257e0f7edeef11c161c4a8257f6706 (patch) | |
tree | 9dfceeb17af541ec8ca313739d4f33fb27895f7a /src/Text | |
parent | 7998587810cea2db2970a544b316bad7932eae38 (diff) | |
parent | 2e868c82518a2cff5eaf3b843875befa86bc3bfb (diff) | |
download | pandoc-4c8fda30e6257e0f7edeef11c161c4a8257f6706.tar.gz |
Merge pull request #868 from maxandersen/atxasciidoc
Add support for --atx-headers in asciidoc and remove unnecessary [[]] generation for headers.
Diffstat (limited to 'src/Text')
-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 |