From 2cbd8a3351accb11fa937bb2ea571c569cf6da1f Mon Sep 17 00:00:00 2001 From: Jesse Rosenthal Date: Mon, 10 Dec 2018 16:38:49 -0500 Subject: Docx writer: Make Level into a real type. It had previously been an alias for a tuple. --- src/Text/Pandoc/Readers/Docx.hs | 2 +- src/Text/Pandoc/Readers/Docx/Parse.hs | 8 +++++--- 2 files changed, 6 insertions(+), 4 deletions(-) (limited to 'src/Text/Pandoc') diff --git a/src/Text/Pandoc/Readers/Docx.hs b/src/Text/Pandoc/Readers/Docx.hs index 621239bc7..31f332c89 100644 --- a/src/Text/Pandoc/Readers/Docx.hs +++ b/src/Text/Pandoc/Readers/Docx.hs @@ -655,7 +655,7 @@ bodyPartToBlocks (ListItem pPr numId lvl (Just levelInfo) parparts) = do -- since Docx expects us to pick up where we left off. listState <- gets docxListState let startFromState = M.lookup (numId, lvl) listState - (_, fmt,txt, startFromLevelInfo) = levelInfo + Level _ fmt txt startFromLevelInfo = levelInfo start = case startFromState of Just n -> n + 1 Nothing -> fromMaybe 1 startFromLevelInfo diff --git a/src/Text/Pandoc/Readers/Docx/Parse.hs b/src/Text/Pandoc/Readers/Docx/Parse.hs index b4e52de14..358c7bf42 100644 --- a/src/Text/Pandoc/Readers/Docx/Parse.hs +++ b/src/Text/Pandoc/Readers/Docx/Parse.hs @@ -56,6 +56,7 @@ module Text.Pandoc.Readers.Docx.Parse ( Docx(..) , ChangeType(..) , ChangeInfo(..) , FieldInfo(..) + , Level(..) , archiveToDocx , archiveToDocxWithWarnings ) where @@ -195,7 +196,8 @@ data AbstractNumb = AbstractNumb String [Level] deriving Show -- (ilvl, format, string, start) -type Level = (String, String, String, Maybe Integer) +data Level = Level String String String (Maybe Integer) + deriving Show data DocumentLocation = InDocument | InFootnote | InEndnote deriving (Eq,Show) @@ -505,7 +507,7 @@ lookupLevel :: String -> String -> Numbering -> Maybe Level lookupLevel numId ilvl (Numbering _ numbs absNumbs) = do absNumId <- lookup numId $ map (\(Numb nid absnumid) -> (nid, absnumid)) numbs lvls <- lookup absNumId $ map (\(AbstractNumb aid ls) -> (aid, ls)) absNumbs - lookup ilvl $ map (\l@(i, _, _, _) -> (i, l)) lvls + lookup ilvl $ map (\l@(Level i _ _ _) -> (i, l)) lvls numElemToNum :: NameSpaces -> Element -> Maybe Numb @@ -537,7 +539,7 @@ levelElemToLevel ns element let start = findChildByName ns "w" "start" element >>= findAttrByName ns "w" "val" >>= (\s -> listToMaybe (map fst (reads s :: [(Integer, String)]))) - return (ilvl, fmt, txt, start) + return (Level ilvl fmt txt start) levelElemToLevel _ _ = Nothing archiveToNumbering' :: Archive -> Maybe Numbering -- cgit v1.2.3