Parse linebreaks as a backslash before a newline

usingMegaparsec
Aadhavan Srinivasan 3 weeks ago
parent 57cb3e68fa
commit d074b0131c

@ -58,7 +58,7 @@ instance Show MdToken where
show (Header level token) = "<h" ++ show level ++ ">" ++ show token ++ "</h" ++ show level ++ ">" show (Header level token) = "<h" ++ show level ++ ">" ++ show token ++ "</h" ++ show level ++ ">"
show (Para token) = "<p>" ++ show token ++ "</p>" show (Para token) = "<p>" ++ show token ++ "</p>"
show (Line tokens) = concatMap show tokens show (Line tokens) = concatMap show tokens
show Linebreak = "<br>" show Linebreak = "<br />\n"
show SingleNewline = " " show SingleNewline = " "
show HorizontalRule = "<hr>" show HorizontalRule = "<hr>"
show (Blockquote tokens) = "<blockquote>" ++ concatMap show tokens ++ "</blockquote>" show (Blockquote tokens) = "<blockquote>" ++ concatMap show tokens ++ "</blockquote>"
@ -224,11 +224,17 @@ parseLink = do
-- Parse a linebreak character -- Parse a linebreak character
parseLinebreak :: Parser MdToken parseLinebreak :: Parser MdToken
parseLinebreak = do parseLinebreak = parseLinebreakSpace <|> parseLinebreakBackslash
where
parseLinebreakSpace = do
char ' ' char ' '
some (char ' ') some (char ' ')
char '\n' char '\n'
return Linebreak return Linebreak
parseLinebreakBackslash = try $ do
char '\\'
char '\n'
return Linebreak
parseTableRow :: Parser [MdToken] parseTableRow :: Parser [MdToken]
parseTableRow = do parseTableRow = do

Loading…
Cancel
Save