Improved parser for horizontal rule and codeblock
This commit is contained in:
@@ -542,11 +542,15 @@ doubleNewlineText :: T.Text
|
||||
doubleNewlineText = T.pack "\n\n"
|
||||
|
||||
parseHorizontalRule :: Parser MdToken
|
||||
parseHorizontalRule = string horizontalRuleText *> (void (string doubleNewlineText) <|> eof) *> return HorizontalRule
|
||||
parseHorizontalRule = parseHorizontalRuleLine *> (void (string doubleNewlineText) <|> eof) *> return HorizontalRule
|
||||
where
|
||||
parseHorizontalRuleLine = fallthroughParser (map (string . T.pack) ["---", "***", "___", "- - -", "* * *", "_ _ _"])
|
||||
|
||||
parseCodeblock :: Parser MdToken
|
||||
parseCodeblock = do
|
||||
string (T.pack "```\n")
|
||||
string (T.pack "```")
|
||||
_ <- many $ satisfy (/= '\n') -- Language name
|
||||
char '\n'
|
||||
inside <- someTill anySingle (string (T.pack "\n```"))
|
||||
return $ Codeblock (Unit (concatMap escapeChar inside))
|
||||
|
||||
|
Reference in New Issue
Block a user