git.iko.soy/typeable/pandoc
on master help sign in
Citation changes.

* Citations will work in markdown even if `--biblio` isn't specified. Note: this may cause unexpected behavior for people who use strings of the form `@foo` that are not citations! * If `--biblio` isn't used, the markdown writer will write markdown citations rather than CSL-rendered citations. * This means, for example, that you can do `pandoc -f latex -t markdown` and convert biblatex or natbib citations into pandoc citations.

commitd46f434d4b8906ae3b983e568549213de94fd1a2 authorJohn MacFarlane <fiddlosopher@gmail.com> dateSun 3 Feb 2013, 10:30 (14 years ago) parente148fd7
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
@@ -1247,6 +1247,7 @@ inline = choice [ whitespace
12471247 , emph
12481248 , note
12491249 , cite
1250+ , textCite
12501251 , link
12511252 , image
12521253 , math
@@ -1625,12 +1626,12 @@ rawHtmlInline = do
16251626cite :: MarkdownParser (F Inlines)
16261627cite = do
16271628 guardEnabled Ext_citations
1628− getOption readerReferences >>= guard . not . null
1629− citations <- textualCite <|> normalCite
1629+ citations <- normalCite
16301630 return $ flip B.cite mempty <$> citations
16311631
1632−textualCite :: MarkdownParser (F [Citation])
1633−textualCite = try $ do
1632+textCite :: MarkdownParser (F Inlines)
1633+textCite = try $ do
1634+ guardEnabled Ext_citations
16341635 (_, key) <- citeKey
16351636 let first = Citation{ citationId = key
16361637 , citationPrefix = []
@@ -1641,8 +1642,15 @@ textualCite = try $ do
16411642 }
16421643 mbrest <- option Nothing $ try $ spnl >> Just <$> normalCite
16431644 case mbrest of
1644− Just rest -> return $ (first:) <$> rest
1645− Nothing -> option (return [first]) $ bareloc first
1645+ Just rest -> return $ (flip B.cite mempty . (first:)) <$> rest
1646+ Nothing -> (do cites <- bareloc first
1647+ return $ flip B.cite mempty <$> cites)
1648+ <|> (do guardEnabled Ext_example_lists
1649+ st <- getState
1650+ case M.lookup key (stateExamples st) of
1651+ Just n -> return $ return $ B.str (show n)
1652+ Nothing -> mzero)
1653+ <|> (return $ return $ flip B.cite mempty [first])
16461654
16471655bareloc :: Citation -> MarkdownParser (F [Citation])
16481656bareloc c = try $ do
@@ -1674,8 +1682,6 @@ citeKey = try $ do
16741682 let internal p = try $ p >>~ lookAhead (letter <|> digit)
16751683 rest <- many $ letter <|> digit <|> internal (oneOf ":.#$%&-_?<>~/")
16761684 let key = first:rest
1677− citations' <- map CSL.refId <$> getOption readerReferences
1678− guard $ key `elem` citations'
16791685 return (suppress_author, key)
16801686
16811687suffix :: 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