diff options
Diffstat (limited to 'pandoc.hs')
-rw-r--r-- | pandoc.hs | 52 |
1 files changed, 39 insertions, 13 deletions
@@ -68,10 +68,10 @@ import qualified Data.Map as M import Data.Yaml (decode) import qualified Data.Yaml as Yaml import qualified Data.Text as T -import Control.Applicative ((<$>), (<|>)) +import Control.Applicative ((<|>)) import Text.Pandoc.Readers.Txt2Tags (getT2TMeta) -import Data.Monoid - +import Paths_pandoc (getDataDir) +import Text.Printf (printf) import Text.Pandoc.Error type Transform = Pandoc -> Pandoc @@ -856,7 +856,7 @@ options = (\arg opt -> return opt { optKaTeXJS = - arg <|> Just "https://cdnjs.cloudflare.com/ajax/libs/KaTeX/0.1.0/katex.min.js"}) + arg <|> Just "https://cdnjs.cloudflare.com/ajax/libs/KaTeX/0.5.1/katex.min.js"}) "URL") "" -- Use KaTeX for HTML Math @@ -892,6 +892,22 @@ options = (\opt -> return opt { optVerbose = True })) "" -- "Verbose diagnostic output." + , Option "" ["bash-completion"] + (NoArg + (\_ -> do + ddir <- getDataDir + tpl <- readDataFileUTF8 Nothing "bash_completion.tpl" + let optnames (Option shorts longs _ _) = + map (\c -> ['-',c]) shorts ++ + map ("--" ++) longs + let allopts = unwords (concatMap optnames options) + UTF8.hPutStrLn stdout $ printf tpl allopts + (unwords (map fst readers)) + (unwords ("pdf": map fst writers)) + ddir + exitWith ExitSuccess )) + "" -- "Print bash completion script" + , Option "v" ["version"] (NoArg (\_ -> do @@ -1006,6 +1022,7 @@ defaultWriterName x = ".epub" -> "epub" ".org" -> "org" ".asciidoc" -> "asciidoc" + ".adoc" -> "asciidoc" ".pdf" -> "latex" ".fb2" -> "fb2" ".opml" -> "opml" @@ -1128,7 +1145,7 @@ main = do mapM_ (\arg -> UTF8.hPutStrLn stdout arg) args exitWith ExitSuccess - let csscdn = "https://cdnjs.cloudflare.com/ajax/libs/KaTeX/0.1.0/katex.min.css" + let csscdn = "https://cdnjs.cloudflare.com/ajax/libs/KaTeX/0.5.1/katex.min.css" let mathMethod = case (katexJS, katexStylesheet) of (Nothing, _) -> mathMethod' @@ -1136,7 +1153,7 @@ main = do -- --bibliography implies -F pandoc-citeproc for backwards compatibility: - let needsCiteproc = any ("--bibliography" `isPrefixOf`) rawArgs && + let needsCiteproc = M.lookup "bibliography" (optMetadata opts) /= Nothing && optCiteMethod opts `notElem` [Natbib, Biblatex] && "pandoc-citeproc" `notElem` map takeBaseName filters let filters' = if needsCiteproc then "pandoc-citeproc" : filters @@ -1170,6 +1187,10 @@ main = do let laTeXOutput = "latex" `isPrefixOf` writerName' || "beamer" `isPrefixOf` writerName' + let conTeXtOutput = "context" `isPrefixOf` writerName' + + let laTeXInput = "latex" `isPrefixOf` readerName' || + "beamer" `isPrefixOf` readerName' writer <- if ".lua" `isSuffixOf` writerName' -- note: use non-lowercased version writerName @@ -1252,8 +1273,10 @@ main = do uriFragment = "" } _ -> Nothing - let readerOpts = def{ readerSmart = smart || (texLigatures && - (laTeXOutput || "context" `isPrefixOf` writerName')) + let readerOpts = def{ readerSmart = if laTeXInput + then texLigatures + else smart || (texLigatures && + (laTeXOutput || conTeXtOutput)) , readerStandalone = standalone' , readerParseRaw = parseRaw , readerColumns = columns @@ -1365,17 +1388,20 @@ main = do PureStringWriter f | pdfOutput -> do -- make sure writer is latex or beamer - unless laTeXOutput $ + unless (laTeXOutput || conTeXtOutput) $ err 47 $ "cannot produce pdf output with " ++ writerName' ++ " writer" + let texprog = if conTeXtOutput + then "context" + else latexEngine -- check for latex program - mbLatex <- findExecutable latexEngine + mbLatex <- findExecutable texprog when (mbLatex == Nothing) $ - err 41 $ latexEngine ++ " not found. " ++ - latexEngine ++ " is needed for pdf output." + err 41 $ texprog ++ " not found. " ++ + texprog ++ " is needed for pdf output." - res <- makePDF latexEngine f writerOptions doc' + res <- makePDF texprog f writerOptions doc' case res of Right pdf -> writeBinary pdf Left err' -> do |