Replaced --biblio-file with --bibliography, removed --biblio-format.

Bibliography format is guessed from the file extension of the
bibliography.

Also, the bibliography entries are now read during option parsing.
This commit is contained in:
John MacFarlane 2010-11-13 08:42:09 -08:00
parent 1fa2973da6
commit 7aecddd0f7
2 changed files with 10 additions and 19 deletions

View file

@ -163,8 +163,7 @@ data Opt = Opt
, optIndentedCodeClasses :: [String] -- ^ Default classes for indented code blocks , optIndentedCodeClasses :: [String] -- ^ Default classes for indented code blocks
, optDataDir :: Maybe FilePath , optDataDir :: Maybe FilePath
#ifdef _CITEPROC #ifdef _CITEPROC
, optBiblioFile :: String , optBibliography :: [Reference]
, optBiblioFormat :: String
, optCslFile :: String , optCslFile :: String
#endif #endif
} }
@ -205,8 +204,7 @@ defaultOpts = Opt
, optIndentedCodeClasses = [] , optIndentedCodeClasses = []
, optDataDir = Nothing , optDataDir = Nothing
#ifdef _CITEPROC #ifdef _CITEPROC
, optBiblioFile = [] , optBibliography = []
, optBiblioFormat = []
, optCslFile = [] , optCslFile = []
#endif #endif
} }
@ -520,16 +518,14 @@ options =
"FORMAT") "FORMAT")
"" -- "Print default template for FORMAT" "" -- "Print default template for FORMAT"
#ifdef _CITEPROC #ifdef _CITEPROC
, Option "" ["biblio"] , Option "" ["bibliography"]
(ReqArg (ReqArg
(\arg opt -> return opt { optBiblioFile = arg} ) (\arg opt -> do
refs <- readBiblioFile arg ""
return opt { optBibliography =
optBibliography opt ++ refs } )
"FILENAME") "FILENAME")
"" ""
, Option "" ["biblio-format"]
(ReqArg
(\arg opt -> return opt { optBiblioFormat = arg} )
"STRING")
""
, Option "" ["csl"] , Option "" ["csl"]
(ReqArg (ReqArg
(\arg opt -> return opt { optCslFile = arg} ) (\arg opt -> return opt { optCslFile = arg} )
@ -684,9 +680,8 @@ main = do
, optIndentedCodeClasses = codeBlockClasses , optIndentedCodeClasses = codeBlockClasses
, optDataDir = mbDataDir , optDataDir = mbDataDir
#ifdef _CITEPROC #ifdef _CITEPROC
, optBiblioFile = biblioFile , optBibliography = refs
, optBiblioFormat = biblioFormat , optCslFile = cslFile
, optCslFile = cslFile
#endif #endif
} = opts } = opts
@ -746,10 +741,6 @@ main = do
let standalone' = standalone || isNonTextOutput writerName' let standalone' = standalone || isNonTextOutput writerName'
#ifdef _CITEPROC
refs <- if null biblioFile then return [] else readBiblioFile biblioFile biblioFormat
#endif
variables' <- case (writerName', standalone', offline) of variables' <- case (writerName', standalone', offline) of
("s5", True, True) -> do ("s5", True, True) -> do
inc <- s5HeaderIncludes datadir inc <- s5HeaderIncludes datadir

View file

@ -106,7 +106,7 @@ main = do
"latex-reader.latex" "latex-reader.native" "latex-reader.latex" "latex-reader.native"
r11 <- runTest "native reader" ["-r", "native", "-w", "native", "-s"] r11 <- runTest "native reader" ["-r", "native", "-w", "native", "-s"]
"testsuite.native" "testsuite.native" "testsuite.native" "testsuite.native"
r14 <- runTest "markdown reader (citations)" ["-r", "markdown", "-w", "plain", "--biblio", "biblio.bib", "--csl", "chicago-author-date.csl"] "markdown-citations.txt" "markdown-citations.plain" r14 <- runTest "markdown reader (citations)" ["-r", "markdown", "-w", "plain", "--bibliography", "biblio.bib", "--csl", "chicago-author-date.csl"] "markdown-citations.txt" "markdown-citations.plain"
r12s <- if runLhsTests r12s <- if runLhsTests
then mapM runLhsWriterTest lhsWriterFormats then mapM runLhsWriterTest lhsWriterFormats
else putStrLn "Skipping lhs writer tests because they presuppose highlighting support" >> return [] else putStrLn "Skipping lhs writer tests because they presuppose highlighting support" >> return []