@@ -111,7 +111,7 @@ headline lvl = try $ do
112 properties <- option mempty propertiesDrawer
112 properties <- option mempty propertiesDrawer
113 contents <- blocks
113 contents <- blocks
114− children <- many (headline (lvl + 1))
114+ children <- many (headline (level + 1))
115 return $ do
115 return $ do
116 title' <- title
116 title' <- title
117 contents' <- contents
117 contents' <- contents
@@ -135,12 +135,14 @@ headline lvl = try $ do
136-- | Convert an Org mode headline (i.e. a document tree) into pandoc's Blocks
136-- | Convert an Org mode headline (i.e. a document tree) into pandoc's Blocks
137headlineToBlocks :: Headline -> OrgParser Blocks
137headlineToBlocks :: Headline -> OrgParser Blocks
138−headlineToBlocks hdln@(Headline {..}) =
138+headlineToBlocks hdln@(Headline {..}) = do
139+ maxHeadlineLevels <- getExportSetting exportHeadlineLevels
139 case () of
140 case () of
140− _ | any isNoExportTag headlineTags -> return mempty
141+ _ | any isNoExportTag headlineTags -> return mempty
141− _ | any isArchiveTag headlineTags -> archivedHeadlineToBlocks hdln
142+ _ | any isArchiveTag headlineTags -> archivedHeadlineToBlocks hdln
142− _ | isCommentTitle headlineText -> return mempty
143+ _ | isCommentTitle headlineText -> return mempty
144+ _ | headlineLevel >= maxHeadlineLevels -> headlineToHeaderWithList hdln
143− _ -> headlineToHeaderWithContents hdln
145+ _ -> headlineToHeaderWithContents hdln
145isNoExportTag :: Tag -> Bool
147isNoExportTag :: Tag -> Bool
146isNoExportTag = (== toTag "noexport")
148isNoExportTag = (== toTag "noexport")
@@ -163,6 +165,25 @@ archivedHeadlineToBlocks hdln = do
163 ArchivedTreesExport -> headlineToHeaderWithContents hdln
165 ArchivedTreesExport -> headlineToHeaderWithContents hdln
164 ArchivedTreesHeadlineOnly -> headlineToHeader hdln
166 ArchivedTreesHeadlineOnly -> headlineToHeader hdln
168+headlineToHeaderWithList :: Headline -> OrgParser Blocks
169+headlineToHeaderWithList hdln@(Headline {..}) = do
170+ maxHeadlineLevels <- getExportSetting exportHeadlineLevels
171+ header <- headlineToHeader hdln
172+ listElements <- sequence (map headlineToBlocks headlineChildren)
173+ let listBlock = if null listElements
175+ else B.orderedList listElements
176+ let headerText = if maxHeadlineLevels == headlineLevel
178+ else flattenHeader header
179+ return $ headerText <> headlineContents <> listBlock
181+ flattenHeader :: Blocks -> Blocks
182+ flattenHeader blks =
183+ case B.toList blks of
184+ (Header _ _ inlns:_) -> B.para (B.fromList inlns)
166headlineToHeaderWithContents :: Headline -> OrgParser Blocks
187headlineToHeaderWithContents :: Headline -> OrgParser Blocks
167headlineToHeaderWithContents hdln@(Headline {..}) = do
188headlineToHeaderWithContents hdln@(Headline {..}) = do
168 header <- headlineToHeader hdln
189 header <- headlineToHeader hdln