From a796b655cd2046c1297d800e328ed9ef58251405 Mon Sep 17 00:00:00 2001 From: John MacFarlane Date: Tue, 29 Oct 2019 21:24:58 -0700 Subject: Shared.makeSections: better behavior in some corner cases. When a div surrounds multiple sections at the same level, or a section of highre level followed by one of lower level, then we just leave it as a div and create a new div for the section. Closes #5846, closes #5761. --- src/Text/Pandoc/Shared.hs | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) (limited to 'src/Text') diff --git a/src/Text/Pandoc/Shared.hs b/src/Text/Pandoc/Shared.hs index 59e30feeb..ff97d16fb 100644 --- a/src/Text/Pandoc/Shared.hs +++ b/src/Text/Pandoc/Shared.hs @@ -1,12 +1,13 @@ -{-# LANGUAGE NoImplicitPrelude #-} +{-# LANGUAGE NoImplicitPrelude #-} {-# LANGUAGE CPP #-} {-# LANGUAGE DeriveDataTypeable #-} {-# LANGUAGE FlexibleContexts #-} {-# LANGUAGE MultiParamTypeClasses #-} {-# LANGUAGE ScopedTypeVariables #-} {-# LANGUAGE ViewPatterns #-} -{-# LANGUAGE FlexibleInstances #-} +{-# LANGUAGE FlexibleInstances #-} {-# LANGUAGE TypeSynonymInstances #-} +{-# LANGUAGE LambdaCase #-} {- | Module : Text.Pandoc.Shared Copyright : Copyright (C) 2006-2019 John MacFarlane @@ -533,7 +534,10 @@ makeSections numbering mbBaseLevel bs = return $ Div divattr (Header level' attr title' : sectionContents') : rest' go (Div (dident,dclasses,dkvs) - (Header level (ident,classes,kvs) title':ys) : xs) = do + (Header level (ident,classes,kvs) title':ys) : xs) + | all (\case + Header level' _ _ -> level' > level + _ -> True) ys = do inner <- go (Header level (ident,classes,kvs) title':ys) let inner' = case inner of -- cgit v1.2.3