Images and figures now support CSS classes
This commit is contained in:
@@ -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) = "<code>" ++ show code ++ "</code>"
|
||||
show (Codeblock code) = show code
|
||||
show (Link txt url) = "<a href=\"" ++ getUrl url ++ "\">" ++ show txt ++ "</a>"
|
||||
show (Image txt url) = "<img src=\"" ++ getUrl url ++ "\"" ++ " alt=\"" ++ show txt ++ "\" />"
|
||||
show (Figure txt url) = "<figure><img src=\"" ++ getUrl url ++ "\" alt=\"" ++ show txt ++ "\"/><figcaption aria-hidden=\"true\">" ++ show txt ++ "</figcaption></figure>"
|
||||
show (Image txt url cssClasses) = "<img src=\"" ++ getUrl url ++ "\"" ++ " alt=\"" ++ show txt ++ "\"" ++ maybe "" (\classes -> " class=\"" ++ unwords classes ++ "\"") cssClasses ++ "/>"
|
||||
show (Figure txt url cssClasses) = "<figure><img src=\"" ++ getUrl url ++ "\" alt=\"" ++ show txt ++ "\"" ++ maybe "" (\classes -> " class=\"" ++ unwords classes ++ "\"") cssClasses ++ "/><figcaption aria-hidden=\"true\">" ++ show txt ++ "</figcaption></figure>"
|
||||
show (Bold token) = "<b>" ++ show token ++ "</b>"
|
||||
show (Italic token) = "<i>" ++ show token ++ "</i>"
|
||||
show (Strikethrough token) = "<s>" ++ show token ++ "</s>"
|
||||
|
Reference in New Issue
Block a user