From 69eba7f2e13978a1a1c76352944b0281236e69b6 Mon Sep 17 00:00:00 2001 From: Nikolay Yakimov Date: Sat, 31 Aug 2024 22:31:05 +0300 Subject: [PATCH] Amend inefficiency in splitMath Closes #445 --- lib-internal/Text/Pandoc/CrossRef/References/Blocks/Math.hs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/lib-internal/Text/Pandoc/CrossRef/References/Blocks/Math.hs b/lib-internal/Text/Pandoc/CrossRef/References/Blocks/Math.hs index bb8e8ef..dfed6da 100644 --- a/lib-internal/Text/Pandoc/CrossRef/References/Blocks/Math.hs +++ b/lib-internal/Text/Pandoc/CrossRef/References/Blocks/Math.hs @@ -81,7 +81,8 @@ replaceEqn eqTemplate (label, _, attrs) eq = do splitMath :: [Block] -> [Block] splitMath (Para ils:xs) - | length ils > 1 = map Para (split [] [] ils) <> xs + | _:_:_ <- ils -- at least two elements + = map Para (split [] [] ils) <> xs where split res acc [] = reverse (reverse acc : res) split res acc (x@(Span _ [Math DisplayMath _]):ys) =