git.iko.soy/typeable/pandoc
on master help sign in
ConTeXt writer: Use identifiers for chapters.

Closes #3968.

commit75d8c99c73d2a725c6753170050fa77469c803d1 authorJohn MacFarlane <jgm@berkeley.edu> dateWed 11 Oct 2017, 20:21 (9 years ago) parent71e4543
2 files changed+16−6
src/Text/Pandoc/Writers/ConTeXt.hs+7−6 test/command/3968.md+9
src/Text/Pandoc/Writers/ConTeXt.hs+7−6
@@ -449,19 +449,20 @@ sectionHeader (ident,classes,_) hdrLevel lst = do
449449 TopLevelChapter -> hdrLevel - 1
450450 TopLevelSection -> hdrLevel
451451 TopLevelDefault -> hdrLevel
452− let ident' = toLabel ident
452+ let ident' = if null ident
453+ then empty
454+ else brackets (text (toLabel ident))
453455 let (section, chapter) = if "unnumbered" `elem` classes
454456 then (text "subject", text "title")
455457 else (text "section", text "chapter")
456458 return $ case level' of
457− -1 -> text "\\part" <> braces contents
458− 0 -> char '\\' <> chapter <> braces contents
459+ -1 -> text "\\part" <> ident' <> braces contents
460+ 0 -> char '\\' <> chapter <> ident' <>
461+ braces contents
459462 n | n >= 1 && n <= 5 -> char '\\'
460463 <> text (concat (replicate (n - 1) "sub"))
461464 <> section
462− <> (if (not . null) ident'
463− then brackets (text ident')
464− else empty)
465+ <> ident'
465466 <> braces contents
466467 <> blankline
467468 _ -> contents <> blankline
test/command/3968.mdnew file+9
@@ -0,0 +1,9 @@
1+```
2+% pandoc --top-level-division=chapter -t context
3+# Chapter
4+
5+## Section
6+^D
7+\chapter[chapter]{Chapter}
8+\section[section]{Section}
9+```