From a9a9a2c62a811d0e64062b0be628f55ba541dad7 Mon Sep 17 00:00:00 2001 From: Kolen Cheung Date: Fri, 10 Dec 2021 16:18:35 -0800 Subject: fix(IpynbOutput)!: rank always favors output format Previously, both `fmt == f` case and Image have a rank of 1. In the end, e.g. from ipynb to html conversion, if both html and image exists, it actually prefers the image. This commit changes this, so that fmt == f is always highest rank, and rank never collides. This is achieved by keeping fmt == f case having rank 1, and every other rank increased by 1. --- src/Text/Pandoc/Shared.hs | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) (limited to 'src') diff --git a/src/Text/Pandoc/Shared.hs b/src/Text/Pandoc/Shared.hs index 06fd052b9..eb0b4acbf 100644 --- a/src/Text/Pandoc/Shared.hs +++ b/src/Text/Pandoc/Shared.hs @@ -727,17 +727,17 @@ filterIpynbOutput mode = walk go where rank (RawBlock (Format "html") _) | fmt == Format "html" = 1 :: Int - | fmt == Format "markdown" = 2 - | otherwise = 3 + | fmt == Format "markdown" = 3 + | otherwise = 4 rank (RawBlock (Format "latex") _) | fmt == Format "latex" = 1 - | fmt == Format "markdown" = 2 - | otherwise = 3 + | fmt == Format "markdown" = 3 + | otherwise = 4 rank (RawBlock f _) | fmt == f = 1 - | otherwise = 3 - rank (Para [Image{}]) = 1 - rank _ = 2 + | otherwise = 4 + rank (Para [Image{}]) = 2 + rank _ = 3 removeANSI (CodeBlock attr code) = CodeBlock attr (removeANSIEscapes code) removeANSI x = x -- cgit v1.2.3