From c48b8c5ae850f73ff392ecfb34cfdbcb78739d88 Mon Sep 17 00:00:00 2001 From: Aadhavan Srinivasan Date: Tue, 10 Jun 2025 09:05:31 -0400 Subject: [PATCH] Images and figures now support CSS classes --- src/MdToHTML.hs | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/src/MdToHTML.hs b/src/MdToHTML.hs index b819607..0b5604e 100644 --- a/src/MdToHTML.hs +++ b/src/MdToHTML.hs @@ -22,6 +22,8 @@ type Parser = Parsec Void T.Text type HeaderLevel = Int +type CssClass = String + newtype URL = URL {getUrl :: String} deriving (Eq) newtype ImgPath = ImgPath {getPath :: String} deriving (Eq) @@ -40,8 +42,8 @@ data MdToken | Code MdToken | Codeblock String | Link MdToken URL - | Image MdToken URL - | Figure MdToken URL + | Image MdToken URL (Maybe [CssClass]) + | Figure MdToken URL (Maybe [CssClass]) | Bold MdToken | Italic MdToken | Strikethrough MdToken @@ -63,8 +65,8 @@ instance Show MdToken where show (Code code) = "" ++ show code ++ "" show (Codeblock code) = show code show (Link txt url) = "" ++ show txt ++ "" - show (Image txt url) = "\""" - show (Figure txt url) = "
\""
" ++ show txt ++ "
" + show (Image txt url cssClasses) = "\"" " class=\"" ++ unwords classes ++ "\"") cssClasses ++ "/>" + show (Figure txt url cssClasses) = "
\"" " class=\"" ++ unwords classes ++ "\"") cssClasses ++ "/>
" ++ show txt ++ "
" show (Bold token) = "" ++ show token ++ "" show (Italic token) = "" ++ show token ++ "" show (Strikethrough token) = "" ++ show token ++ ""