From 57e4f5644f149c0ba326241f10afc1cfcdae443e Mon Sep 17 00:00:00 2001 From: John MacFarlane Date: Wed, 6 Feb 2013 13:14:37 -0800 Subject: [PATCH] Revert "Citation changes." This reverts commit d46f434d4b8906ae3b983e568549213de94fd1a2. --- src/Text/Pandoc/Readers/Markdown.hs | 22 ++++++++-------------- src/Text/Pandoc/Writers/Markdown.hs | 4 +--- 2 files changed, 9 insertions(+), 17 deletions(-) diff --git a/src/Text/Pandoc/Readers/Markdown.hs b/src/Text/Pandoc/Readers/Markdown.hs index e198586d6..6b144f35e 100644 --- a/src/Text/Pandoc/Readers/Markdown.hs +++ b/src/Text/Pandoc/Readers/Markdown.hs @@ -1248,7 +1248,6 @@ inline = choice [ whitespace , emph , note , cite - , textCite , link , image , math @@ -1631,12 +1630,12 @@ rawHtmlInline = do cite :: MarkdownParser (F Inlines) cite = do guardEnabled Ext_citations - citations <- normalCite + getOption readerReferences >>= guard . not . null + citations <- textualCite <|> normalCite return $ flip B.cite mempty <$> citations -textCite :: MarkdownParser (F Inlines) -textCite = try $ do - guardEnabled Ext_citations +textualCite :: MarkdownParser (F [Citation]) +textualCite = try $ do (_, key) <- citeKey let first = Citation{ citationId = key , citationPrefix = [] @@ -1647,15 +1646,8 @@ textCite = try $ do } mbrest <- option Nothing $ try $ spnl >> Just <$> normalCite case mbrest of - 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]) + Just rest -> return $ (first:) <$> rest + Nothing -> option (return [first]) $ bareloc first bareloc :: Citation -> MarkdownParser (F [Citation]) bareloc c = try $ do @@ -1687,6 +1679,8 @@ 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) diff --git a/src/Text/Pandoc/Writers/Markdown.hs b/src/Text/Pandoc/Writers/Markdown.hs index 8ff5ff9de..4d848d55b 100644 --- a/src/Text/Pandoc/Writers/Markdown.hs +++ b/src/Text/Pandoc/Writers/Markdown.hs @@ -614,9 +614,7 @@ inlineToMarkdown opts (LineBreak) | otherwise = return $ " " <> cr inlineToMarkdown _ Space = return space inlineToMarkdown opts (Cite (c:cs) lst) - | writerCiteMethod opts == Citeproc && not (null lst) && - case lst of { RawInline "latex" _ : _ -> False; _ -> True} = - inlineListToMarkdown opts lst + | writerCiteMethod opts == Citeproc = inlineListToMarkdown opts lst | citationMode c == AuthorInText = do suffs <- inlineListToMarkdown opts $ citationSuffix c rest <- mapM convertOne cs