Markdown reader: fix regression with example list references.

This affects example list references followed by dashes.
Introduced by commit b8d17f7.
Closes #6855.
This commit is contained in:
John MacFarlane 2020-11-17 20:36:59 -08:00
parent d464757132
commit bf3fea0a8c
3 changed files with 22 additions and 2 deletions

View file

@ -798,7 +798,11 @@ exampleNum :: Stream s m Char
=> ParserT s ParserState m (ListNumberStyle, Int)
exampleNum = do
char '@'
lab <- T.pack <$> many (alphaNum <|> satisfy (\c -> c == '_' || c == '-'))
lab <- mconcat . map T.pack <$>
many (many1 alphaNum <|>
try (do c <- char '_' <|> char '-'
cs <- many1 alphaNum
return (c:cs)))
st <- getState
let num = stateNextExample st
let newlabels = if T.null lab

View file

@ -1544,7 +1544,11 @@ exampleRef :: PandocMonad m => MarkdownParser m (F Inlines)
exampleRef = try $ do
guardEnabled Ext_example_lists
char '@'
lab <- many1Char (alphaNum <|> oneOf "-_")
lab <- mconcat . map T.pack <$>
many (many1 alphaNum <|>
try (do c <- char '_' <|> char '-'
cs <- many1 alphaNum
return (c:cs)))
return $ do
st <- askF
return $ case M.lookup lab (stateExamples st) of

12
test/command/6855.md Normal file
View file

@ -0,0 +1,12 @@
```
% pandoc -t markdown
(@a) one
(@b) two
See (@a--@b)
^D
(1) one
(2) two
See (1--2)
```