Started working on blockquote parser
This commit is contained in:
@@ -48,7 +48,7 @@ instance Show MdToken where
|
||||
show Linebreak = "<br>"
|
||||
show SingleNewline = " "
|
||||
show HorizontalRule = "---------"
|
||||
show (Blockquote token) = "BLOCK" ++ show token
|
||||
show (Blockquote token) = "<blockquote>" ++ show token ++ "</blockquote>"
|
||||
show (UnordList tokens) = "UNORD" ++ concatMap show tokens
|
||||
show (OrdList tokens) = "ORD" ++ concatMap show tokens
|
||||
show (Code code) = show code
|
||||
@@ -148,7 +148,7 @@ parseSingleNewline = do
|
||||
parseEscapedChar :: ReadP MdToken
|
||||
parseEscapedChar = do
|
||||
char '\\'
|
||||
escapedChar <- choice (map char specialChars)
|
||||
escapedChar <- choice (map char specialChars) -- Parse any of the special chars.
|
||||
return (Unit [escapedChar])
|
||||
|
||||
-- Parse a regular string as a Unit.
|
||||
@@ -196,8 +196,14 @@ parsePara = do
|
||||
let parsedText = fst $ leftmostLongestParse parseLine text -- Parse a line
|
||||
return (Para parsedText)
|
||||
|
||||
-- Parse a blockquote, which is a greater-than sign followed by a paragraph.
|
||||
parseBlockquote :: ReadP MdToken
|
||||
parseBlockquote = do
|
||||
char '>'
|
||||
Blockquote <$> (parseBlockquote <++ parsePara) -- Parse another blockquote or a regular paragraph, wrap it in a blockquote.
|
||||
|
||||
-- Parse a document, which is multiple paragraphs.
|
||||
parseDocument :: ReadP MdToken
|
||||
parseDocument = do
|
||||
res <- manyTill (parseHeader <++ parsePara) eof
|
||||
res <- manyTill (parseHeader <++ parseBlockquote <++ parsePara) eof
|
||||
return (Document res)
|
||||
|
Reference in New Issue
Block a user