From f607b40fc36328339835a43504713d71c4f2a4b0 Mon Sep 17 00:00:00 2001 From: Iavor Diatchki Date: Tue, 14 May 2019 15:25:30 -0700 Subject: [PATCH] More flexible "start of code block" in Markdown mode. This should fix #595. --- src/Cryptol/Parser/Unlit.hs | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/src/Cryptol/Parser/Unlit.hs b/src/Cryptol/Parser/Unlit.hs index 4110efad9..517faae5c 100644 --- a/src/Cryptol/Parser/Unlit.hs +++ b/src/Cryptol/Parser/Unlit.hs @@ -99,12 +99,17 @@ markdown = blanks [] | otherwise = fenced op (l : current) ls - isOpenFence l | "```cryptol" == l' = Just Code - | "```" == l' = Just Code - | "```" `Text.isPrefixOf` l' = Just Comment - | otherwise = Nothing + isOpenFence l + | "```" `Text.isPrefixOf` l' = + Just $ case Text.drop 3 l' of + l'' | "cryptol" `Text.isPrefixOf` l'' -> Code + | isBlank l'' -> Code + | otherwise -> Comment + + | otherwise = Nothing where l' = Text.dropWhile isSpace l + isCloseFence l = "```" `Text.isPrefixOf` l isBlank l = Text.all isSpace l isCodeLine l = "\t" `Text.isPrefixOf` l || " " `Text.isPrefixOf` l