git.iko.soy/typeable/pandoc
on master help sign in
[Docx Reader] Get rid of unused NullModifier in Readers.Docx.Combine
commit76c765a38b6d1c50443374532d3645d76abde261 authorNikolay Yakimov <root@livid.pp.ru> dateTue 7 Jul 2020, 11:32 (6 years ago) parentf4baf54
1 file changed+15−18
src/Text/Pandoc/Readers/Docx/Combine.hs+15−18
src/Text/Pandoc/Readers/Docx/Combine.hs+15−18
@@ -68,7 +68,6 @@ import Text.Pandoc.Builder
6868
6969data Modifier a = Modifier (a -> a)
7070 | AttrModifier (Attr -> a -> a) Attr
71− | NullModifier
7271
7372spaceOutInlinesL :: Inlines -> (Inlines, Inlines)
7473spaceOutInlinesL ms = (l, stackInlines fs (m' <> r))
@@ -94,7 +93,6 @@ isSpace _ = False
9493
9594stackInlines :: [Modifier Inlines] -> Inlines -> Inlines
9695stackInlines [] ms = ms
97−stackInlines (NullModifier : fs) ms = stackInlines fs ms
9896stackInlines (Modifier f : fs) ms =
9997 if isEmpty ms
10098 then stackInlines fs ms
@@ -103,23 +101,23 @@ stackInlines (AttrModifier f attr : fs) ms = f attr $ stackInlines fs ms
103101
104102unstackInlines :: Inlines -> ([Modifier Inlines], Inlines)
105103unstackInlines ms = case ilModifierAndInnards ms of
106− (NullModifier, _) -> ([], ms)
107− (f, innards ) -> first (f :) $ unstackInlines innards
104+ Nothing -> ([], ms)
105+ Just (f, inner) -> first (f :) $ unstackInlines inner
108106
109−ilModifierAndInnards :: Inlines -> (Modifier Inlines, Inlines)
107+ilModifierAndInnards :: Inlines -> Maybe (Modifier Inlines, Inlines)
110108ilModifierAndInnards ils = case viewl $ unMany ils of
111− x :< xs | Seq.null xs -> case x of
112− Emph lst -> (Modifier emph, fromList lst)
113− Strong lst -> (Modifier strong, fromList lst)
114− SmallCaps lst -> (Modifier smallcaps, fromList lst)
115− Strikeout lst -> (Modifier strikeout, fromList lst)
116− Underline lst -> (Modifier underline, fromList lst)
117− Superscript lst -> (Modifier superscript, fromList lst)
118− Subscript lst -> (Modifier subscript, fromList lst)
119− Link attr lst tgt -> (Modifier $ linkWith attr (fst tgt) (snd tgt), fromList lst)
120− Span attr lst -> (AttrModifier spanWith attr, fromList lst)
121− _ -> (NullModifier, ils)
122− _ -> (NullModifier, ils)
109+ x :< xs | Seq.null xs -> second fromList <$> case x of
110+ Emph lst -> Just (Modifier emph, lst)
111+ Strong lst -> Just (Modifier strong, lst)
112+ SmallCaps lst -> Just (Modifier smallcaps, lst)
113+ Strikeout lst -> Just (Modifier strikeout, lst)
114+ Underline lst -> Just (Modifier underline, lst)
115+ Superscript lst -> Just (Modifier superscript, lst)
116+ Subscript lst -> Just (Modifier subscript, lst)
117+ Link attr lst tgt -> Just (Modifier $ linkWith attr (fst tgt) (snd tgt), lst)
118+ Span attr lst -> Just (AttrModifier spanWith attr, lst)
119+ _ -> Nothing
120+ _ -> Nothing
123121
124122inlinesL :: Inlines -> (Inlines, Inlines)
125123inlinesL ils = case viewl $ unMany ils of
@@ -181,7 +179,6 @@ combineBlocks bs cs = bs <> cs
181179instance (Monoid a, Eq a) => Eq (Modifier a) where
182180 (Modifier f) == (Modifier g) = f mempty == g mempty
183181 (AttrModifier f attr) == (AttrModifier g attr') = f attr mempty == g attr' mempty
184− NullModifier == NullModifier = True
185182 _ == _ = False
186183
187184isEmpty :: (Monoid a, Eq a) => a -> Bool