Markdown reader: Slight rewrite of enclosure/emphOrStrong code.

Semantics should be the same.
This commit is contained in:
John MacFarlane 2014-07-10 14:37:10 -07:00
parent ff86702a95
commit ee522be94f

View file

@ -1436,9 +1436,15 @@ math = (return . B.displayMath <$> (mathDisplay >>= applyMacros'))
enclosure :: Char
-> MarkdownParser (F Inlines)
enclosure c = do
-- we can't start an enclosure with _ if after a string and
-- the intraword_underscores extension is enabled:
guardDisabled Ext_intraword_underscores
<|> guard (c == '*')
<|> (guard =<< notAfterString)
cs <- many1 (char c)
(return (B.str cs) <>) <$> whitespace
<|> case length cs of
<|> do
case length cs of
3 -> three c
2 -> two c mempty
1 -> one c mempty
@ -1477,11 +1483,7 @@ one c prefix' = do
<|> return (return (B.str [c]) <> (prefix' <> contents))
strongOrEmph :: MarkdownParser (F Inlines)
strongOrEmph = enclosure '*' <|> (checkIntraword >> enclosure '_')
where checkIntraword = do
exts <- getOption readerExtensions
when (Ext_intraword_underscores `Set.member` exts) $ do
guard =<< notAfterString
strongOrEmph = enclosure '*' <|> enclosure '_'
-- | Parses a list of inlines between start and end delimiters.
inlinesBetween :: (Show b)