diff options
author | John MacFarlane <fiddlosopher@gmail.com> | 2012-10-13 11:33:55 -0700 |
---|---|---|
committer | John MacFarlane <fiddlosopher@gmail.com> | 2012-10-13 11:33:55 -0700 |
commit | b5dd06d30374edb7a2756ba58019d7f21f3bbfe5 (patch) | |
tree | c1ab0bb0361cfd9f65a9bed9583b845248a9119a /src/Text/Pandoc/Readers | |
parent | 9a77a3f15ba4201a0b617a814b73d2eb9cad11fc (diff) | |
download | pandoc-b5dd06d30374edb7a2756ba58019d7f21f3bbfe5.tar.gz |
Moved bibliography processing into readers.
Previously this was done in src/pandoc.hs, which made it difficult
for library users.
* Removed readerCitations in ReaderOptions.
* Added readerReferences and readerCitationStyle to ReaderOptions.
* Moved use of processBiblio from main program to the
markdown and LaTeX readers.
Diffstat (limited to 'src/Text/Pandoc/Readers')
-rw-r--r-- | src/Text/Pandoc/Readers/LaTeX.hs | 6 | ||||
-rw-r--r-- | src/Text/Pandoc/Readers/Markdown.hs | 11 |
2 files changed, 13 insertions, 4 deletions
diff --git a/src/Text/Pandoc/Readers/LaTeX.hs b/src/Text/Pandoc/Readers/LaTeX.hs index bdbf8f100..458c114ff 100644 --- a/src/Text/Pandoc/Readers/LaTeX.hs +++ b/src/Text/Pandoc/Readers/LaTeX.hs @@ -36,6 +36,7 @@ module Text.Pandoc.Readers.LaTeX ( readLaTeX, import Text.Pandoc.Definition import Text.Pandoc.Shared import Text.Pandoc.Options +import Text.Pandoc.Biblio (processBiblio) import Text.Pandoc.Parsing hiding ((<|>), many, optional, space) import qualified Text.Pandoc.UTF8 as UTF8 import Data.Char ( chr, ord ) @@ -63,7 +64,10 @@ parseLaTeX = do let title' = stateTitle st let authors' = stateAuthors st let date' = stateDate st - return $ Pandoc (Meta title' authors' date') $ toList bs + refs <- getOption readerReferences + mbsty <- getOption readerCitationStyle + return $ processBiblio mbsty refs + $ Pandoc (Meta title' authors' date') $ toList bs type LP = Parser [Char] ParserState diff --git a/src/Text/Pandoc/Readers/Markdown.hs b/src/Text/Pandoc/Readers/Markdown.hs index 7ac68c856..ab8069a75 100644 --- a/src/Text/Pandoc/Readers/Markdown.hs +++ b/src/Text/Pandoc/Readers/Markdown.hs @@ -45,6 +45,8 @@ import Text.Pandoc.Readers.LaTeX ( rawLaTeXInline, rawLaTeXBlock ) import Text.Pandoc.Readers.HTML ( htmlTag, htmlInBalanced, isInlineTag, isBlockTag, isTextTag, isCommentTag ) import Text.Pandoc.XML ( fromEntities ) +import Text.Pandoc.Biblio (processBiblio) +import qualified Text.CSL as CSL import Data.Monoid (mconcat, mempty) import Control.Applicative ((<$>), (<*), (*>), (<$)) import Control.Monad @@ -216,7 +218,10 @@ parseMarkdown = do (title, authors, date) <- option (mempty,return [],mempty) titleBlock blocks <- parseBlocks st <- getState - return $ B.setTitle (runF title st) + mbsty <- getOption readerCitationStyle + refs <- getOption readerReferences + return $ processBiblio mbsty refs + $ B.setTitle (runF title st) $ B.setAuthors (runF authors st) $ B.setDate (runF date st) $ B.doc $ runF blocks st @@ -1542,7 +1547,7 @@ rawHtmlInline = do cite :: Parser [Char] ParserState (F Inlines) cite = do guardEnabled Ext_citations - getOption readerCitations >>= guard . not . null + getOption readerReferences >>= guard . not . null citations <- textualCite <|> normalCite return $ flip B.cite mempty <$> citations @@ -1591,7 +1596,7 @@ citeKey = try $ do let internal p = try $ p >>~ lookAhead (letter <|> digit) rest <- many $ letter <|> digit <|> internal (oneOf ":.#$%&-_?<>~") let key = first:rest - citations' <- getOption readerCitations + citations' <- map CSL.refId <$> getOption readerReferences guard $ key `elem` citations' return (suppress_author, key) |