@@ -50,6 +50,7 @@ module Text.Pandoc.Shared (
5050 linesToPara ,
5151 figureDiv ,
5252 makeSections ,
53+ combineAttr ,
5354 uniqueIdent ,
5455 inlineListToIdentifier ,
5556 textToIdentifier ,
@@ -562,13 +563,15 @@ makeSections numbering mbBaseLevel bs =
562563 go (x: xs) = (x : ) <$> go xs
563564 go [] = return []
564565
565- combineAttr :: Attr -> Attr -> Attr
566- combineAttr (id1, classes1, kvs1) (id2, classes2, kvs2) =
567- (if T. null id1 then id2 else id1,
568- nubOrd (classes1 ++ classes2),
569- foldr (\ (k,v) kvs -> case lookup k kvs of
570- Nothing -> (k,v): kvs
571- Just _ -> kvs) mempty (kvs1 ++ kvs2))
566+ -- | Combine two 'Attr'. Classes are concatenated. For the id and key-value
567+ -- attributes, the first one takes precedence in case of duplicates.
568+ combineAttr :: Attr -> Attr -> Attr
569+ combineAttr (id1, classes1, kvs1) (id2, classes2, kvs2) =
570+ (if T. null id1 then id2 else id1,
571+ nubOrd (classes1 ++ classes2),
572+ foldr (\ (k,v) kvs -> case lookup k kvs of
573+ Nothing -> (k,v): kvs
574+ Just _ -> kvs) kvs1 kvs2)
572575
573576headerLtEq :: Int -> Block -> Bool
574577headerLtEq level (Header l _ _) = l <= level
0 commit comments