diff options
| author | John MacFarlane <fiddlosopher@gmail.com> | 2013-02-03 10:30:48 -0800 | 
|---|---|---|
| committer | John MacFarlane <fiddlosopher@gmail.com> | 2013-02-03 10:30:48 -0800 | 
| commit | d46f434d4b8906ae3b983e568549213de94fd1a2 (patch) | |
| tree | d1c31ada67d539098130218e60e098fd989c81e7 /src/Text/Pandoc/Readers | |
| parent | e148fd75474f5391a5348fd674532dbd1dc1d756 (diff) | |
| download | pandoc-d46f434d4b8906ae3b983e568549213de94fd1a2.tar.gz | |
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.
Diffstat (limited to 'src/Text/Pandoc/Readers')
| -rw-r--r-- | src/Text/Pandoc/Readers/Markdown.hs | 22 | 
1 files changed, 14 insertions, 8 deletions
| diff --git a/src/Text/Pandoc/Readers/Markdown.hs b/src/Text/Pandoc/Readers/Markdown.hs index dc30e17ed..c476e23a7 100644 --- a/src/Text/Pandoc/Readers/Markdown.hs +++ b/src/Text/Pandoc/Readers/Markdown.hs @@ -1247,6 +1247,7 @@ inline = choice [ whitespace                  , emph                  , note                  , cite +                , textCite                  , link                  , image                  , math @@ -1625,12 +1626,12 @@ rawHtmlInline = do  cite :: MarkdownParser (F Inlines)  cite = do    guardEnabled Ext_citations -  getOption readerReferences >>= guard . not . null -  citations <- textualCite <|> normalCite +  citations <- normalCite    return $ flip B.cite mempty <$> citations -textualCite :: MarkdownParser (F [Citation]) -textualCite = try $ do +textCite :: MarkdownParser (F Inlines) +textCite = try $ do +  guardEnabled Ext_citations    (_, key) <- citeKey    let first = Citation{ citationId      = key                        , citationPrefix  = [] @@ -1641,8 +1642,15 @@ textualCite = try $ do                        }    mbrest <- option Nothing $ try $ spnl >> Just <$> normalCite    case mbrest of -       Just rest  -> return $ (first:) <$> rest -       Nothing    -> option (return [first]) $ bareloc first +       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])  bareloc :: Citation -> MarkdownParser (F [Citation])  bareloc c = try $ do @@ -1674,8 +1682,6 @@ 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) | 
