ConTeXt writer: Use identifiers for chapters.

Closes #3968.
This commit is contained in:
John MacFarlane 2017-10-11 20:21:55 -07:00
parent 71e4543cc0
commit 75d8c99c73
2 changed files with 16 additions and 6 deletions

View file

@ -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

9
test/command/3968.md Normal file
View file

@ -0,0 +1,9 @@
```
% pandoc --top-level-division=chapter -t context
# Chapter
## Section
^D
\chapter[chapter]{Chapter}
\section[section]{Section}
```