diff options
author | John MacFarlane <fiddlosopher@gmail.com> | 2013-02-05 22:04:53 -0800 |
---|---|---|
committer | John MacFarlane <fiddlosopher@gmail.com> | 2013-02-05 22:04:53 -0800 |
commit | 1a2eea23a19aeb838bfdb9f7c2fa4ef9e83e72f1 (patch) | |
tree | 60ba26e5c729bd66a4896a80e490d36234b9d4da /src/Text/Pandoc/Readers | |
parent | c5f1a8ad2d2f7972e2c3e8bd22686bb99e84356d (diff) | |
parent | d46f434d4b8906ae3b983e568549213de94fd1a2 (diff) | |
download | pandoc-1a2eea23a19aeb838bfdb9f7c2fa4ef9e83e72f1.tar.gz |
Merge branch 'citations'
Diffstat (limited to 'src/Text/Pandoc/Readers')
-rw-r--r-- | src/Text/Pandoc/Readers/Markdown.hs | 22 |
1 files changed, 14 insertions, 8 deletions
diff --git a/src/Text/Pandoc/Readers/Markdown.hs b/src/Text/Pandoc/Readers/Markdown.hs index 6b144f35e..e198586d6 100644 --- a/src/Text/Pandoc/Readers/Markdown.hs +++ b/src/Text/Pandoc/Readers/Markdown.hs @@ -1248,6 +1248,7 @@ inline = choice [ whitespace , emph , note , cite + , textCite , link , image , math @@ -1630,12 +1631,12 @@ rawHtmlInline = do cite :: MarkdownParser (F Inlines) cite = do guardEnabled Ext_citations - getOption readerReferences >>= guard . not . null - citations <- textualCite <|> normalCite + citations <- normalCite return $ flip B.cite mempty <$> citations -textualCite :: MarkdownParser (F [Citation]) -textualCite = try $ do +textCite :: MarkdownParser (F Inlines) +textCite = try $ do + guardEnabled Ext_citations (_, key) <- citeKey let first = Citation{ citationId = key , citationPrefix = [] @@ -1646,8 +1647,15 @@ textualCite = try $ do } mbrest <- option Nothing $ try $ spnl >> Just <$> normalCite case mbrest of - Just rest -> return $ (first:) <$> rest - Nothing -> option (return [first]) $ bareloc first + Just rest -> return $ (flip B.cite mempty . (first:)) <$> rest + Nothing -> (do cites <- bareloc first + return $ flip B.cite mempty <$> cites) + <|> (do guardEnabled Ext_example_lists + st <- getState + case M.lookup key (stateExamples st) of + Just n -> return $ return $ B.str (show n) + Nothing -> mzero) + <|> (return $ return $ flip B.cite mempty [first]) bareloc :: Citation -> MarkdownParser (F [Citation]) bareloc c = try $ do @@ -1679,8 +1687,6 @@ citeKey = try $ do let internal p = try $ p >>~ lookAhead (letter <|> digit) rest <- many $ letter <|> digit <|> internal (oneOf ":.#$%&-_?<>~/") let key = first:rest - citations' <- map CSL.refId <$> getOption readerReferences - guard $ key `elem` citations' return (suppress_author, key) suffix :: MarkdownParser (F Inlines) |