git.iko.soy/typeable/pandoc
on master help sign in
Merge branch 'citations'
commit1a2eea23a19aeb838bfdb9f7c2fa4ef9e83e72f1 authorJohn MacFarlane <fiddlosopher@gmail.com> dateTue 5 Feb 2013, 22:04 (14 years ago) parentc5f1a8ad46f434
2 files changed+17−9
src/Text/Pandoc/Readers/Markdown.hs+14−8 src/Text/Pandoc/Writers/Markdown.hs+3−1
src/Text/Pandoc/Readers/Markdown.hs+14−8
@@ -1248,6 +1248,7 @@ inline = choice [ whitespace
12481248 , emph
12491249 , note
12501250 , cite
1251+ , textCite
12511252 , link
12521253 , image
12531254 , math
@@ -1630,12 +1631,12 @@ rawHtmlInline = do
16301631cite :: MarkdownParser (F Inlines)
16311632cite = do
16321633 guardEnabled Ext_citations
1633− getOption readerReferences >>= guard . not . null
1634− citations <- textualCite <|> normalCite
1634+ citations <- normalCite
16351635 return $ flip B.cite mempty <$> citations
16361636
1637−textualCite :: MarkdownParser (F [Citation])
1638−textualCite = try $ do
1637+textCite :: MarkdownParser (F Inlines)
1638+textCite = try $ do
1639+ guardEnabled Ext_citations
16391640 (_, key) <- citeKey
16401641 let first = Citation{ citationId = key
16411642 , citationPrefix = []
@@ -1646,8 +1647,15 @@ textualCite = try $ do
16461647 }
16471648 mbrest <- option Nothing $ try $ spnl >> Just <$> normalCite
16481649 case mbrest of
1649− Just rest -> return $ (first:) <$> rest
1650− Nothing -> option (return [first]) $ bareloc first
1650+ Just rest -> return $ (flip B.cite mempty . (first:)) <$> rest
1651+ Nothing -> (do cites <- bareloc first
1652+ return $ flip B.cite mempty <$> cites)
1653+ <|> (do guardEnabled Ext_example_lists
1654+ st <- getState
1655+ case M.lookup key (stateExamples st) of
1656+ Just n -> return $ return $ B.str (show n)
1657+ Nothing -> mzero)
1658+ <|> (return $ return $ flip B.cite mempty [first])
16511659
16521660bareloc :: Citation -> MarkdownParser (F [Citation])
16531661bareloc c = try $ do
@@ -1679,8 +1687,6 @@ citeKey = try $ do
16791687 let internal p = try $ p >>~ lookAhead (letter <|> digit)
16801688 rest <- many $ letter <|> digit <|> internal (oneOf ":.#$%&-_?<>~/")
16811689 let key = first:rest
1682− citations' <- map CSL.refId <$> getOption readerReferences
1683− guard $ key `elem` citations'
16841690 return (suppress_author, key)
16851691
16861692suffix :: MarkdownParser (F Inlines)
src/Text/Pandoc/Writers/Markdown.hs+3−1
@@ -614,7 +614,9 @@ inlineToMarkdown opts (LineBreak)
614614 | otherwise = return $ " " <> cr
615615inlineToMarkdown _ Space = return space
616616inlineToMarkdown opts (Cite (c:cs) lst)
617− | writerCiteMethod opts == Citeproc = inlineListToMarkdown opts lst
617+ | writerCiteMethod opts == Citeproc && not (null lst) &&
618+ case lst of { RawInline "latex" _ : _ -> False; _ -> True} =
619+ inlineListToMarkdown opts lst
618620 | citationMode c == AuthorInText = do
619621 suffs <- inlineListToMarkdown opts $ citationSuffix c
620622 rest <- mapM convertOne cs