diff options
-rw-r--r-- | src/Text/Pandoc/Writers/ConTeXt.hs | 13 | ||||
-rw-r--r-- | test/command/3968.md | 9 |
2 files changed, 16 insertions, 6 deletions
diff --git a/src/Text/Pandoc/Writers/ConTeXt.hs b/src/Text/Pandoc/Writers/ConTeXt.hs index 6f2cb2b9e..0a399197d 100644 --- a/src/Text/Pandoc/Writers/ConTeXt.hs +++ b/src/Text/Pandoc/Writers/ConTeXt.hs @@ -449,19 +449,20 @@ sectionHeader (ident,classes,_) hdrLevel lst = do TopLevelChapter -> hdrLevel - 1 TopLevelSection -> hdrLevel TopLevelDefault -> hdrLevel - let ident' = toLabel ident + let ident' = if null ident + then empty + else brackets (text (toLabel ident)) let (section, chapter) = if "unnumbered" `elem` classes then (text "subject", text "title") else (text "section", text "chapter") return $ case level' of - -1 -> text "\\part" <> braces contents - 0 -> char '\\' <> chapter <> braces contents + -1 -> text "\\part" <> ident' <> braces contents + 0 -> char '\\' <> chapter <> ident' <> + braces contents n | n >= 1 && n <= 5 -> char '\\' <> text (concat (replicate (n - 1) "sub")) <> section - <> (if (not . null) ident' - then brackets (text ident') - else empty) + <> ident' <> braces contents <> blankline _ -> contents <> blankline diff --git a/test/command/3968.md b/test/command/3968.md new file mode 100644 index 000000000..24f0900a9 --- /dev/null +++ b/test/command/3968.md @@ -0,0 +1,9 @@ +``` +% pandoc --top-level-division=chapter -t context +# Chapter + +## Section +^D +\chapter[chapter]{Chapter} +\section[section]{Section} +``` |