git.iko.soy/typeable/pandoc
on master help sign in
Citation changes.
d46f434John MacFarlane
src/Text/Pandoc/Readers/Markdown.hs+14−8
@@ -1247,6 +1247,7 @@ inline = choice [ whitespace
1247 , emph
1247 , emph
1248 , note
1248 , note
1249 , cite
1249 , cite
1250+ , textCite
1250 , link
1251 , link
1251 , image
1252 , image
1252 , math
1253 , math
@@ -1625,12 +1626,12 @@ rawHtmlInline = do
1625cite :: MarkdownParser (F Inlines)
1626cite :: MarkdownParser (F Inlines)
1626cite = do
1627cite = do
1627 guardEnabled Ext_citations
1628 guardEnabled Ext_citations
1628− getOption readerReferences >>= guard . not . null
1629− citations <- textualCite <|> normalCite
1629+ citations <- normalCite
1630 return $ flip B.cite mempty <$> citations
1630 return $ flip B.cite mempty <$> citations
1631
1631
1632−textualCite :: MarkdownParser (F [Citation])
1632+textCite :: MarkdownParser (F Inlines)
1633−textualCite = try $ do
1633+textCite = try $ do
1634+ guardEnabled Ext_citations
1634 (_, key) <- citeKey
1635 (_, key) <- citeKey
1635 let first = Citation{ citationId = key
1636 let first = Citation{ citationId = key
1636 , citationPrefix = []
1637 , citationPrefix = []
@@ -1641,8 +1642,15 @@ textualCite = try $ do
1641 }
1642 }
1642 mbrest <- option Nothing $ try $ spnl >> Just <$> normalCite
1643 mbrest <- option Nothing $ try $ spnl >> Just <$> normalCite
1643 case mbrest of
1644 case mbrest of
1644− Just rest -> return $ (first:) <$> rest
1645+ Just rest -> return $ (flip B.cite mempty . (first:)) <$> rest
1645− Nothing -> option (return [first]) $ bareloc first
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])
1646
1654
1647bareloc :: Citation -> MarkdownParser (F [Citation])
1655bareloc :: Citation -> MarkdownParser (F [Citation])
1648bareloc c = try $ do
1656bareloc c = try $ do
@@ -1674,8 +1682,6 @@ citeKey = try $ do
1674 let internal p = try $ p >>~ lookAhead (letter <|> digit)
1682 let internal p = try $ p >>~ lookAhead (letter <|> digit)
1675 rest <- many $ letter <|> digit <|> internal (oneOf ":.#$%&-_?<>~/")
1683 rest <- many $ letter <|> digit <|> internal (oneOf ":.#$%&-_?<>~/")
1676 let key = first:rest
1684 let key = first:rest
1677− citations' <- map CSL.refId <$> getOption readerReferences
1678− guard $ key `elem` citations'
1679 return (suppress_author, key)
1685 return (suppress_author, key)
1680
1686
1681suffix :: MarkdownParser (F Inlines)
1687suffix :: MarkdownParser (F Inlines)
src/Text/Pandoc/Writers/Markdown.hs+3−1
@@ -614,7 +614,9 @@ inlineToMarkdown opts (LineBreak)
614 | otherwise = return $ " " <> cr
614 | otherwise = return $ " " <> cr
615inlineToMarkdown _ Space = return space
615inlineToMarkdown _ Space = return space
616inlineToMarkdown opts (Cite (c:cs) lst)
616inlineToMarkdown opts (Cite (c:cs) lst)
617+ | writerCiteMethod opts == Citeproc && not (null lst) &&
618+ case lst of { RawInline "latex" _ : _ -> False; _ -> True} =
617− | writerCiteMethod opts == Citeproc = inlineListToMarkdown opts lst
619+ inlineListToMarkdown opts lst
618 | citationMode c == AuthorInText = do
620 | citationMode c == AuthorInText = do
619 suffs <- inlineListToMarkdown opts $ citationSuffix c
621 suffs <- inlineListToMarkdown opts $ citationSuffix c
620 rest <- mapM convertOne cs
622 rest <- mapM convertOne cs