summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorJohn MacFarlane <jgm@berkeley.edu>2016-11-27 15:33:44 +0100
committerJohn MacFarlane <jgm@berkeley.edu>2017-01-25 17:07:39 +0100
commit22ffbad9e8e99a59f24997d09d04b28c87d5ecba (patch)
tree0c89918d7cd70b18393e4647109cf4543d22e5d5 /src
parent1673bda95e83aa124241ffdf14d25282d4cad055 (diff)
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.
Diffstat (limited to 'src')
-rw-r--r--src/Text/Pandoc/Writers/Texinfo.hs40
1 files changed, 21 insertions, 19 deletions
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