git.iko.soy/typeable/pandoc
on master help sign in
Texinfo writer: restore former behavior for headers level > 4.

The recent changes made the writer fail with an error if it encountered a header with level 5. Better to do as we did before and just print a paragraph in that case. Eventually we should emit a warning here.

commit22ffbad9e8e99a59f24997d09d04b28c87d5ecba authorJohn MacFarlane <jgm@berkeley.edu> dateSun 27 Nov 2016, 15:33 (10 years ago) parent1673bda
1 file changed+21−19
src/Text/Pandoc/Writers/Texinfo.hs+21−19
src/Text/Pandoc/Writers/Texinfo.hs+21−19
@@ -219,25 +219,27 @@ blockToTexinfo (Header 0 _ lst) = do
219219 return $ text "@node Top" $$
220220 text "@top " <> txt <> blankline
221221
222−blockToTexinfo (Header level _ lst) = do
223− node <- inlineListForNode lst
224− txt <- inlineListToTexinfo lst
225− idsUsed <- gets stIdentifiers
226− let id' = uniqueIdent lst idsUsed
227− modify $ \st -> st{ stIdentifiers = Set.insert id' idsUsed }
228− sec <- seccmd level
229− return $ if (level > 0) && (level <= 4)
230− then blankline <> text "@node " <> node $$
231− text sec <> txt $$
232− text "@anchor" <> braces (text $ '#':id')
233− else txt
234− where
235− seccmd :: PandocMonad m => Int -> TI m String
236− seccmd 1 = return "@chapter "
237− seccmd 2 = return "@section "
238− seccmd 3 = return "@subsection "
239− seccmd 4 = return "@subsubsection "
240− seccmd _ = throwError $ PandocSomeError "illegal seccmd level"
222+blockToTexinfo (Header level _ lst)
223+ | level < 1 || level > 4 = blockToTexinfo (Para lst)
224+ | otherwise = do
225+ node <- inlineListForNode lst
226+ txt <- inlineListToTexinfo lst
227+ idsUsed <- gets stIdentifiers
228+ let id' = uniqueIdent lst idsUsed
229+ modify $ \st -> st{ stIdentifiers = Set.insert id' idsUsed }
230+ sec <- seccmd level
231+ return $ if (level > 0) && (level <= 4)
232+ then blankline <> text "@node " <> node $$
233+ text sec <> txt $$
234+ text "@anchor" <> braces (text $ '#':id')
235+ else txt
236+ where
237+ seccmd :: PandocMonad m => Int -> TI m String
238+ seccmd 1 = return "@chapter "
239+ seccmd 2 = return "@section "
240+ seccmd 3 = return "@subsection "
241+ seccmd 4 = return "@subsubsection "
242+ seccmd _ = throwError $ PandocSomeError "illegal seccmd level"
241243
242244blockToTexinfo (Table caption aligns widths heads rows) = do
243245 headers <- if all null heads