git.iko.soy/typeable/pandoc
on master help sign in
Markdown reader: Fixed regression with intraword underscores.
83d4c27John MacFarlane
src/Text/Pandoc/Readers/Markdown.hs+16−10
@@ -1450,36 +1450,42 @@ enclosure c = do
1450 1 -> one c mempty
1450 1 -> one c mempty
1451 _ -> return (return $ B.str cs)
1451 _ -> return (return $ B.str cs)
1452
1452
1453+ender :: Char -> Int -> MarkdownParser ()
1454+ender c n = try $ do
1455+ count n (char c)
1456+ guard (c == '*')
1457+ <|> guardDisabled Ext_intraword_underscores
1458+ <|> notFollowedBy alphaNum
1459+
1453-- Parse inlines til you hit one c or a sequence of two cs.
1460-- Parse inlines til you hit one c or a sequence of two cs.
1454-- If one c, emit emph and then parse two.
1461-- If one c, emit emph and then parse two.
1455-- If two cs, emit strong and then parse one.
1462-- If two cs, emit strong and then parse one.
1456-- Otherwise, emit ccc then the results.
1463-- Otherwise, emit ccc then the results.
1457three :: Char -> MarkdownParser (F Inlines)
1464three :: Char -> MarkdownParser (F Inlines)
1458three c = do
1465three c = do
1459− contents <- mconcat <$> many (notFollowedBy (char c) >> inline)
1466+ contents <- mconcat <$> many (notFollowedBy (ender c 1) >> inline)
1460− (try (string [c,c,c]) >> return ((B.strong . B.emph) <$> contents))
1467+ (ender c 3 >> return ((B.strong . B.emph) <$> contents))
1461− <|> (try (string [c,c]) >> one c (B.strong <$> contents))
1468+ <|> (ender c 2 >> one c (B.strong <$> contents))
1462− <|> (char c >> two c (B.emph <$> contents))
1469+ <|> (ender c 1 >> two c (B.emph <$> contents))
1463 <|> return (return (B.str [c,c,c]) <> contents)
1470 <|> return (return (B.str [c,c,c]) <> contents)
1464
1471
1465-- Parse inlines til you hit two c's, and emit strong.
1472-- Parse inlines til you hit two c's, and emit strong.
1466-- If you never do hit two cs, emit ** plus inlines parsed.
1473-- If you never do hit two cs, emit ** plus inlines parsed.
1467two :: Char -> F Inlines -> MarkdownParser (F Inlines)
1474two :: Char -> F Inlines -> MarkdownParser (F Inlines)
1468two c prefix' = do
1475two c prefix' = do
1469− let ender = try $ string [c,c]
1470− contents <- mconcat <$> many (try $ notFollowedBy ender >> inline)
1476+ contents <- mconcat <$> many (try $ notFollowedBy (ender c 2) >> inline)
1471− (ender >> return (B.strong <$> (prefix' <> contents)))
1477+ (ender c 2 >> return (B.strong <$> (prefix' <> contents)))
1472 <|> return (return (B.str [c,c]) <> (prefix' <> contents))
1478 <|> return (return (B.str [c,c]) <> (prefix' <> contents))
1473
1479
1474-- Parse inlines til you hit a c, and emit emph.
1480-- Parse inlines til you hit a c, and emit emph.
1475-- If you never hit a c, emit * plus inlines parsed.
1481-- If you never hit a c, emit * plus inlines parsed.
1476one :: Char -> F Inlines -> MarkdownParser (F Inlines)
1482one :: Char -> F Inlines -> MarkdownParser (F Inlines)
1477one c prefix' = do
1483one c prefix' = do
1478− contents <- mconcat <$> many ( (notFollowedBy (char c) >> inline)
1484+ contents <- mconcat <$> many ( (notFollowedBy (ender c 1) >> inline)
1479 <|> try (string [c,c] >>
1485 <|> try (string [c,c] >>
1480− notFollowedBy (char c) >>
1486+ notFollowedBy (ender c 1) >>
1481 two c mempty) )
1487 two c mempty) )
1482− (char c >> return (B.emph <$> (prefix' <> contents)))
1488+ (ender c 1 >> return (B.emph <$> (prefix' <> contents)))
1483 <|> return (return (B.str [c]) <> (prefix' <> contents))
1489 <|> return (return (B.str [c]) <> (prefix' <> contents))
1484
1490
1485strongOrEmph :: MarkdownParser (F Inlines)
1491strongOrEmph :: MarkdownParser (F Inlines)