diff options
| author | John MacFarlane <[email protected]> | 2024-07-27 21:40:47 +0300 |
|---|---|---|
| committer | John MacFarlane <[email protected]> | 2024-07-27 21:01:00 -0700 |
| commit | 6c43c033981dbdf7d859e7eb87962c5531e1d29a (patch) | |
| tree | 0bdf121fcbc2b3f69a1f2e799dfdfe27f8608119 /src/Text | |
| parent | 9cdc99cb7d748b5edf8f0aeb091bebc66ac77ebe (diff) | |
Docx writer: fix regression with nested lists.
Closes #9994. The bug affects e.g. ordered lists with bullet
sublists; after the sublist the top-level list reverts to bullets
instead of being properly numbered.
This regression was introduced in version 3.2.1 and was caused by
commit f5531f1.
Diffstat (limited to 'src/Text')
| -rw-r--r-- | src/Text/Pandoc/Writers/Docx/OpenXML.hs | 32 |
1 files changed, 13 insertions, 19 deletions
diff --git a/src/Text/Pandoc/Writers/Docx/OpenXML.hs b/src/Text/Pandoc/Writers/Docx/OpenXML.hs index f93ffc940..fadaedb5c 100644 --- a/src/Text/Pandoc/Writers/Docx/OpenXML.hs +++ b/src/Text/Pandoc/Writers/Docx/OpenXML.hs @@ -25,7 +25,6 @@ import Control.Applicative ((<|>)) import Control.Monad.Except (catchError) import qualified Data.ByteString.Lazy as BL import Data.Char (isLetter, isSpace) -import Data.Bifunctor (first) import Text.Pandoc.Char (isCJK) import Data.Ord (comparing) import Data.String (fromString) @@ -391,26 +390,21 @@ blockToOpenXML' opts (Table attr caption colspecs thead tbodies tfoot) = do wrapBookmark tableId content blockToOpenXML' opts el | BulletList lst <- el - = case mapM toTaskListItem lst of - Just items -> addOpenXMLList (map (first (Just . CheckboxMarker)) items) - Nothing -> addOpenXMLList $ zip (Just BulletMarker : repeat Nothing) lst + = case mapM toTaskListItem lst of + Just items -> mconcat <$> + mapM (\(checked, bs) -> addOpenXMLList (CheckboxMarker checked) [bs]) items + Nothing -> addOpenXMLList BulletMarker lst | OrderedList (start, numstyle, numdelim) lst <- el - = addOpenXMLList $ - zip (Just (NumberMarker numstyle numdelim start) : repeat Nothing) lst + = addOpenXMLList (NumberMarker numstyle numdelim start) lst where - addOpenXMLList items = do - exampleid <- case items of - (Just (NumberMarker Example _ _),_) : _ -> gets stExampleId - _ -> return Nothing - l <- asList $ mconcat <$> - mapM (\(mbmarker, bs) -> do - numid <- case mbmarker of - Nothing -> getNumId - Just marker -> do - addList marker - getNumId - listItemToOpenXML opts (fromMaybe numid exampleid) bs) - items + addOpenXMLList marker items = do + addList marker + numid <- getNumId + exampleid <- case marker of + NumberMarker Example _ _ -> gets stExampleId + _ -> return Nothing + l <- asList $ concat <$> + mapM (listItemToOpenXML opts $ fromMaybe numid exampleid) items setFirstPara return l blockToOpenXML' opts (DefinitionList items) = do |
