summaryrefslogtreecommitdiff
path: root/src/Text/Pandoc
diff options
context:
space:
mode:
authorJohn MacFarlane <fiddlosopher@gmail.com>2013-09-14 22:27:25 -0700
committerJohn MacFarlane <fiddlosopher@gmail.com>2013-09-14 22:28:37 -0700
commit21f1bcb2805aad0c8c3a201cf59ce068bab6ec51 (patch)
tree8ce74e7505c16aa49c9b0dff30b16c590d1e65ee /src/Text/Pandoc
parent5529d9d9f53a78e430531b88ee60cb0e38a70580 (diff)
Markdown reader: unresolved citations fall back to original text.
Not ???. Reason: Less surprising, especially for people using @ as in twitter.
Diffstat (limited to 'src/Text/Pandoc')
-rw-r--r--src/Text/Pandoc/Readers/Markdown.hs25
1 files changed, 14 insertions, 11 deletions
diff --git a/src/Text/Pandoc/Readers/Markdown.hs b/src/Text/Pandoc/Readers/Markdown.hs
index 9f2bc4447..5456f25b5 100644
--- a/src/Text/Pandoc/Readers/Markdown.hs
+++ b/src/Text/Pandoc/Readers/Markdown.hs
@@ -1774,12 +1774,11 @@ rawHtmlInline = do
cite :: MarkdownParser (F Inlines)
cite = do
guardEnabled Ext_citations
- citations <- textualCite <|> (fmap (flip B.cite unknownC) <$> normalCite)
+ citations <- textualCite
+ <|> do (cs, raw) <- withRaw normalCite
+ return $ (flip B.cite (B.text raw)) <$> cs
return citations
-unknownC :: Inlines
-unknownC = B.str "???"
-
textualCite :: MarkdownParser (F Inlines)
textualCite = try $ do
(_, key) <- citeKey
@@ -1790,14 +1789,18 @@ textualCite = try $ do
, citationNoteNum = 0
, citationHash = 0
}
- mbrest <- option Nothing $ try $ spnl >> Just <$> normalCite
+ mbrest <- option Nothing $ try $ spnl >> Just <$> withRaw normalCite
case mbrest of
- Just rest -> return $ (flip B.cite unknownC . (first:)) <$> rest
- Nothing -> (fmap (flip B.cite unknownC) <$> bareloc first) <|>
- return (do st <- askF
- return $ case M.lookup key (stateExamples st) of
- Just n -> B.str (show n)
- _ -> B.cite [first] unknownC)
+ Just (rest, raw) ->
+ return $ (flip B.cite (B.text $ '@':key ++ " " ++ raw) . (first:))
+ <$> rest
+ Nothing ->
+ (do (cs, raw) <- withRaw $ bareloc first
+ return $ (flip B.cite (B.text $ '@':key ++ " " ++ raw)) <$> cs)
+ <|> return (do st <- askF
+ return $ case M.lookup key (stateExamples st) of
+ Just n -> B.str (show n)
+ _ -> B.cite [first] $ B.str $ '@':key)
bareloc :: Citation -> MarkdownParser (F [Citation])
bareloc c = try $ do