summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlbert Krewinkel <albert@zeitkraut.de>2022-12-16 14:06:52 +0100
committerAlbert Krewinkel <albert@zeitkraut.de>2022-12-16 14:09:09 +0100
commit0d6c2e3e22290a7e29abbb7449c2f3c49ce12af4 (patch)
treed28964a94966e058056040ab4a1dcd8d339133ce
parentda2d7ce6f5729bbd0fb34f28065882c98a5bcd1c (diff)
ConTeXt writer: fix previous commit for some unlisted sections
Unlist sections even if `--top-level-division` is not defined.
-rw-r--r--src/Text/Pandoc/Writers/ConTeXt.hs13
-rw-r--r--test/command/8486.md18
2 files changed, 23 insertions, 8 deletions
diff --git a/src/Text/Pandoc/Writers/ConTeXt.hs b/src/Text/Pandoc/Writers/ConTeXt.hs
index 652c4471d..a5940e1e4 100644
--- a/src/Text/Pandoc/Writers/ConTeXt.hs
+++ b/src/Text/Pandoc/Writers/ConTeXt.hs
@@ -690,8 +690,9 @@ sectionLevelToText :: PandocMonad m
=> WriterOptions -> Attr -> Int -> HeadingType
-> WM m (Doc Text)
sectionLevelToText opts (_,classes,_) hdrLevel headingType = do
+ let unlisted = "unlisted" `elem` classes
let semanticSection shift = do
- let (section, chapter) = if "unlisted" `elem` classes
+ let (section, chapter) = if unlisted
then (literal "subject", literal "title")
else (literal "section", literal "chapter")
return $ case hdrLevel + shift of
@@ -705,10 +706,12 @@ sectionLevelToText opts (_,classes,_) hdrLevel headingType = do
TopLevelPart -> semanticSection (-2)
TopLevelChapter -> semanticSection (-1)
TopLevelSection -> semanticSection 0
- TopLevelDefault -> return . literal $
- case headingType of
- SectionHeading -> "sectionlevel"
- NonSectionHeading -> ""
+ TopLevelDefault -> if unlisted
+ then semanticSection 0
+ else return . literal $
+ case headingType of
+ SectionHeading -> "sectionlevel"
+ NonSectionHeading -> ""
fromBCP47 :: PandocMonad m => Maybe Text -> WM m (Maybe Text)
fromBCP47 mbs = fromBCP47' <$> toLang mbs
diff --git a/test/command/8486.md b/test/command/8486.md
index c62f2909b..4e0950e00 100644
--- a/test/command/8486.md
+++ b/test/command/8486.md
@@ -2,7 +2,6 @@
```
% pandoc --to=context
-
# Preface {.unlisted -}
Nullam rutrum.
@@ -18,11 +17,11 @@ vestibulum accumsan nisl. Nam vestibulum accumsan nisl.
# References {-}
^D
-\startsectionlevel[title={Preface},reference={preface},number=no,incrementnumber=no]
+\startsubject[title={Preface},reference={preface},number=no,incrementnumber=no]
Nullam rutrum.
-\stopsectionlevel
+\stopsubject
\startsectionlevel[title={Introduction},reference={introduction}]
@@ -41,3 +40,16 @@ vestibulum accumsan nisl. Nam vestibulum accumsan nisl.
\stopsectionlevel
```
+
+## Semantic Headings with `--top-level-division`
+```
+% pandoc --to=context --top-level-division=chapter
+# Bibliography {-}
+None
+^D
+\startchapter[title={Bibliography},reference={bibliography},number=no,incrementnumber=no]
+
+None
+
+\stopchapter
+```