AsciiDoc writer: prevent illegal nestings.
In asciidoc you can only have level n+1 headers directly under level n headers.
This commit is contained in:
parent
2f65263851
commit
7ac9c39996
1 changed files with 9 additions and 1 deletions
|
@ -90,7 +90,7 @@ pandocToAsciiDoc opts (Pandoc meta blocks) = do
|
|||
(fmap render' . blockListToAsciiDoc opts)
|
||||
(fmap render' . inlineListToAsciiDoc opts)
|
||||
meta
|
||||
body <- blockListToAsciiDoc opts blocks
|
||||
body <- vcat <$> mapM (elementToAsciiDoc 1 opts) (hierarchicalize blocks)
|
||||
let main = render colwidth body
|
||||
let context = defField "body" main
|
||||
$ defField "toc"
|
||||
|
@ -101,6 +101,14 @@ pandocToAsciiDoc opts (Pandoc meta blocks) = do
|
|||
Nothing -> return main
|
||||
Just tpl -> renderTemplate' tpl context
|
||||
|
||||
elementToAsciiDoc :: PandocMonad m
|
||||
=> Int -> WriterOptions -> Element -> ADW m Doc
|
||||
elementToAsciiDoc _ opts (Blk b) = blockToAsciiDoc opts b
|
||||
elementToAsciiDoc nestlevel opts (Sec _lvl _num attr label children) = do
|
||||
hdr <- blockToAsciiDoc opts (Header nestlevel attr label)
|
||||
rest <- vcat <$> mapM (elementToAsciiDoc (nestlevel + 1) opts) children
|
||||
return $ hdr $$ rest
|
||||
|
||||
-- | Escape special characters for AsciiDoc.
|
||||
escapeString :: String -> String
|
||||
escapeString = escapeStringUsing escs
|
||||
|
|
Loading…
Reference in a new issue