Docx writer: Make Level into a real type.

It had previously been an alias for a tuple.
This commit is contained in:
Jesse Rosenthal
2018-12-10 19:24:56 -05:00
parent 9366388c05
commit 2cbd8a3351
2 changed files with 6 additions and 4 deletions
+1 -1
View File
@@ -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
+5 -3
View File
@@ -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