Implemented inline code parsing
This commit is contained in:
@@ -33,7 +33,7 @@ data MdToken
|
||||
| Blockquote [MdToken]
|
||||
| UnordList [MdToken]
|
||||
| OrdList [MdToken]
|
||||
| Code String
|
||||
| Code MdToken
|
||||
| Codeblock String
|
||||
| Link MdToken URL
|
||||
| Image MdToken ImgPath
|
||||
@@ -55,7 +55,7 @@ instance Show MdToken where
|
||||
show (Blockquote tokens) = "<blockquote>" ++ concatMap show tokens ++ "</blockquote>"
|
||||
show (UnordList tokens) = "<ul>" ++ concatMap (prepend "<li>" . append "</li>" . show) tokens ++ "</ul>"
|
||||
show (OrdList tokens) = "<ol>" ++ concatMap (prepend "<li>" . append "</li>" . show) tokens ++ "</ol>"
|
||||
show (Code code) = show code
|
||||
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 imgPath) = "<img src=" ++ getPath imgPath ++ ">" ++ show txt ++ "</img>"
|
||||
@@ -163,6 +163,14 @@ parseStrikethrough = do
|
||||
string "~~"
|
||||
return (Strikethrough (Line inside))
|
||||
|
||||
-- Parse code
|
||||
parseCode :: ReadP MdToken
|
||||
parseCode = do
|
||||
string "`"
|
||||
inside <- many1 get
|
||||
string "`"
|
||||
return (Code (Unit inside))
|
||||
|
||||
-- Parse a link
|
||||
parseLink :: ReadP MdToken
|
||||
parseLink = do
|
||||
@@ -209,6 +217,7 @@ lineParsers =
|
||||
[ parseLinebreak,
|
||||
parseSingleNewline,
|
||||
parseEscapedChar,
|
||||
parseCode,
|
||||
parseBold,
|
||||
parseItalic,
|
||||
parseStrikethrough,
|
||||
|
Reference in New Issue
Block a user