From 22ffbad9e8e99a59f24997d09d04b28c87d5ecba Mon Sep 17 00:00:00 2001 From: John MacFarlane Date: Sun, 27 Nov 2016 15:33:44 +0100 Subject: 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. --- src/Text/Pandoc/Writers/Texinfo.hs | 40 ++++++++++++++++++++------------------ 1 file changed, 21 insertions(+), 19 deletions(-) (limited to 'src/Text/Pandoc') diff --git a/src/Text/Pandoc/Writers/Texinfo.hs b/src/Text/Pandoc/Writers/Texinfo.hs index dd5d5ee5d..9d5c80534 100644 --- a/src/Text/Pandoc/Writers/Texinfo.hs +++ b/src/Text/Pandoc/Writers/Texinfo.hs @@ -219,25 +219,27 @@ blockToTexinfo (Header 0 _ lst) = do return $ text "@node Top" $$ text "@top " <> txt <> blankline -blockToTexinfo (Header level _ lst) = do - node <- inlineListForNode lst - txt <- inlineListToTexinfo lst - idsUsed <- gets stIdentifiers - let id' = uniqueIdent lst idsUsed - modify $ \st -> st{ stIdentifiers = Set.insert id' idsUsed } - sec <- seccmd level - return $ if (level > 0) && (level <= 4) - then blankline <> text "@node " <> node $$ - text sec <> txt $$ - text "@anchor" <> braces (text $ '#':id') - else txt - where - seccmd :: PandocMonad m => Int -> TI m String - seccmd 1 = return "@chapter " - seccmd 2 = return "@section " - seccmd 3 = return "@subsection " - seccmd 4 = return "@subsubsection " - seccmd _ = throwError $ PandocSomeError "illegal seccmd level" +blockToTexinfo (Header level _ lst) + | level < 1 || level > 4 = blockToTexinfo (Para lst) + | otherwise = do + node <- inlineListForNode lst + txt <- inlineListToTexinfo lst + idsUsed <- gets stIdentifiers + let id' = uniqueIdent lst idsUsed + modify $ \st -> st{ stIdentifiers = Set.insert id' idsUsed } + sec <- seccmd level + return $ if (level > 0) && (level <= 4) + then blankline <> text "@node " <> node $$ + text sec <> txt $$ + text "@anchor" <> braces (text $ '#':id') + else txt + where + seccmd :: PandocMonad m => Int -> TI m String + seccmd 1 = return "@chapter " + seccmd 2 = return "@section " + seccmd 3 = return "@subsection " + seccmd 4 = return "@subsubsection " + seccmd _ = throwError $ PandocSomeError "illegal seccmd level" blockToTexinfo (Table caption aligns widths heads rows) = do headers <- if all null heads -- cgit v1.2.3