2006-12-20 21:54:23 +01:00
|
|
|
{-
|
2008-01-08 18:26:16 +01:00
|
|
|
Copyright (C) 2006-8 John MacFarlane <jgm@berkeley.edu>
|
2006-12-20 21:54:23 +01:00
|
|
|
|
|
|
|
This program is free software; you can redistribute it and/or modify
|
|
|
|
it under the terms of the GNU General Public License as published by
|
|
|
|
the Free Software Foundation; either version 2 of the License, or
|
|
|
|
(at your option) any later version.
|
|
|
|
|
|
|
|
This program is distributed in the hope that it will be useful,
|
|
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
GNU General Public License for more details.
|
|
|
|
|
|
|
|
You should have received a copy of the GNU General Public License
|
|
|
|
along with this program; if not, write to the Free Software
|
|
|
|
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
|
|
|
-}
|
|
|
|
|
2006-12-20 07:50:14 +01:00
|
|
|
{- |
|
|
|
|
Module : Main
|
2008-01-08 18:26:16 +01:00
|
|
|
Copyright : Copyright (C) 2006-8 John MacFarlane
|
2008-08-10 19:33:20 +02:00
|
|
|
License : GNU GPL, version 2 or above
|
2006-12-20 07:50:14 +01:00
|
|
|
|
2007-07-08 00:51:55 +02:00
|
|
|
Maintainer : John MacFarlane <jgm@berkeley@edu>
|
2008-08-10 19:33:20 +02:00
|
|
|
Stability : alpha
|
2006-12-20 07:50:14 +01:00
|
|
|
Portability : portable
|
|
|
|
|
|
|
|
Parses command-line options and calls the appropriate readers and
|
|
|
|
writers.
|
|
|
|
-}
|
2006-10-17 16:22:29 +02:00
|
|
|
module Main where
|
2007-07-12 10:31:05 +02:00
|
|
|
import Text.Pandoc
|
2008-08-01 01:16:02 +02:00
|
|
|
import Text.Pandoc.ODT
|
2009-12-31 02:11:13 +01:00
|
|
|
import Text.Pandoc.Writers.S5 (s5HeaderIncludes)
|
2009-12-31 02:13:16 +01:00
|
|
|
import Text.Pandoc.LaTeXMathML (latexMathMLScript)
|
2009-12-31 17:48:36 +01:00
|
|
|
import Text.Pandoc.Shared ( tabFilter, ObfuscationMethod (..) )
|
2009-05-02 04:37:38 +02:00
|
|
|
#ifdef _HIGHLIGHTING
|
2008-02-09 04:21:19 +01:00
|
|
|
import Text.Pandoc.Highlighting ( languages )
|
2009-05-02 04:37:38 +02:00
|
|
|
#endif
|
2007-01-15 20:52:42 +01:00
|
|
|
import System.Environment ( getArgs, getProgName, getEnvironment )
|
2007-01-08 17:29:29 +01:00
|
|
|
import System.Exit ( exitWith, ExitCode (..) )
|
2009-01-24 20:58:06 +01:00
|
|
|
import System.FilePath
|
2006-10-17 16:22:29 +02:00
|
|
|
import System.Console.GetOpt
|
|
|
|
import Data.Maybe ( fromMaybe )
|
Extensive changes stemming from a rethinking of the Pandoc data
structure. Key and Note blocks have been removed. Link and image URLs
are now stored directly in Link and Image inlines, and note blocks
are stored in Note inlines. This requires changes in both parsers
and writers. Markdown and RST parsers need to extract data from key
and note blocks and insert them into the relevant inline elements.
Other parsers can be simplified, since there is no longer any need to
construct separate key and note blocks. Markdown, RST, and HTML writers
need to construct lists of notes; Markdown and RST writers need to
construct lists of link references (when the --reference-links option
is specified); and the RST writer needs to construct a list of image
substitution references. All writers have been rewritten to use the
State monad when state is required. This rewrite yields a small speed
boost and considerably cleaner code.
* Text/Pandoc/Definition.hs:
+ blocks: removed Key and Note
+ inlines: removed NoteRef, added Note
+ modified Target: there is no longer a 'Ref' target; all targets
are explicit URL, title pairs
* Text/Pandoc/Shared.hs:
+ Added 'Reference', 'isNoteBlock', 'isKeyBlock', 'isLineClump',
used in some of the readers.
+ Removed 'generateReference', 'keyTable', 'replaceReferenceLinks',
'replaceRefLinksBlockList', along with some auxiliary functions
used only by them. These are no longer needed, since
reference links are resolved in the Markdown and RST readers.
+ Moved 'inTags', 'selfClosingTag', 'inTagsSimple', and 'inTagsIndented'
to the Docbook writer, since that is now the only module that uses
them.
+ Changed name of 'escapeSGMLString' to 'escapeStringForXML'
+ Added KeyTable and NoteTable types
+ Removed fields from ParserState; 'stateKeyBlocks', 'stateKeysUsed',
'stateNoteBlocks', 'stateNoteIdentifiers', 'stateInlineLinks'.
Added 'stateKeys' and 'stateNotes'.
+ Added clause for Note to 'prettyBlock'.
+ Added 'writerNotes', 'writerReferenceLinks' fields to WriterOptions.
* Text/Pandoc/Entities.hs: Renamed 'escapeSGMLChar' and
'escapeSGMLString' to 'escapeCharForXML' and 'escapeStringForXML'
* Text/ParserCombinators/Pandoc.hs: Added lineClump parser: parses a raw
line block up to and including following blank lines.
* Main.hs: Replaced --inline-links with --reference-links.
* README:
+ Documented --reference-links and removed description of --inline-links.
+ Added note that footnotes may occur anywhere in the document, but must
be at the outer level, not embedded in block elements.
* man/man1/pandoc.1, man/man1/html2markdown.1: Removed --inline-links
option, added --reference-links option
* Markdown and RST readers:
+ Rewrote to fit new Pandoc definition. Since there are no longer
Note or Key blocks, all note and key blocks are parsed on a first pass
through the document. Once tables of notes and keys have been constructed,
the remaining parts of the document are reassembled and parsed.
+ Refactored link parsers.
* LaTeX and HTML readers: Rewrote to fit new Pandoc definition. Since
there are no longer Note or Key blocks, notes and references can be
parsed in a single pass through the document.
* RST, Markdown, and HTML writers: Rewrote using state monad new Pandoc
and definition. State is used to hold lists of references footnotes to
and be printed at the end of the document.
* RTF and LaTeX writers: Rewrote using new Pandoc definition. (Because
of the different treatment of footnotes, the "notes" parameter is no
longer needed in the block and inline conversion functions.)
* Docbook writer:
+ Moved the functions 'attributeList', 'inTags', 'selfClosingTag',
'inTagsSimple', 'inTagsIndented' from Text/Pandoc/Shared, since
they are now used only by the Docbook writer.
+ Rewrote using new Pandoc definition. (Because of the different
treatment of footnotes, the "notes" parameter is no longer needed
in the block and inline conversion functions.)
* Updated test suite
* Throughout: old haskell98 module names replaced by hierarchical module
names, e.g. List by Data.List.
* debian/control: Include libghc6-xhtml-dev instead of libghc6-html-dev
in "Build-Depends."
* cabalize:
+ Remove haskell98 from BASE_DEPENDS (since now the new hierarchical
module names are being used throughout)
+ Added mtl to BASE_DEPENDS (needed for state monad)
+ Removed html from GHC66_DEPENDS (not needed since xhtml is now used)
git-svn-id: https://pandoc.googlecode.com/svn/trunk@580 788f1e2b-df1e-0410-8736-df70ead52e1b
2007-04-10 03:56:50 +02:00
|
|
|
import Data.Char ( toLower )
|
2008-12-02 23:43:17 +01:00
|
|
|
import Data.List ( intercalate, isSuffixOf )
|
2009-12-31 17:48:21 +01:00
|
|
|
import System.IO ( stdout, stderr, hPutStrLn, hPutStr )
|
|
|
|
-- Note: ghc >= 6.12 (base >=4.2) supports unicode through iconv
|
|
|
|
-- So we use System.IO.UTF8 only if we have an earlier version
|
|
|
|
#if MIN_VERSION_base(4,2,0)
|
|
|
|
#else
|
2009-01-24 20:58:06 +01:00
|
|
|
import Prelude hiding ( putStr, putStrLn, writeFile, readFile, getContents )
|
2008-08-08 02:11:58 +02:00
|
|
|
import System.IO.UTF8
|
2009-12-31 17:48:21 +01:00
|
|
|
#endif
|
2008-08-04 05:15:34 +02:00
|
|
|
#ifdef _CITEPROC
|
|
|
|
import Text.CSL
|
|
|
|
import Text.Pandoc.Biblio
|
|
|
|
#endif
|
2009-02-24 23:59:44 +01:00
|
|
|
import Control.Monad (when, unless)
|
2006-10-17 16:22:29 +02:00
|
|
|
|
2006-12-22 21:16:03 +01:00
|
|
|
copyrightMessage :: String
|
2008-10-19 01:14:48 +02:00
|
|
|
copyrightMessage = "\nCopyright (C) 2006-8 John MacFarlane\n" ++
|
2008-08-01 01:55:27 +02:00
|
|
|
"Web: http://johnmacfarlane.net/pandoc\n" ++
|
|
|
|
"This is free software; see the source for copying conditions. There is no\n" ++
|
|
|
|
"warranty, not even for merchantability or fitness for a particular purpose."
|
2006-12-22 21:16:03 +01:00
|
|
|
|
2008-08-04 01:33:40 +02:00
|
|
|
compileInfo :: String
|
2008-08-04 05:15:34 +02:00
|
|
|
compileInfo =
|
|
|
|
#ifdef _CITEPROC
|
2009-05-02 04:37:38 +02:00
|
|
|
"\nCompiled with citeproc support." ++
|
2008-08-04 05:15:34 +02:00
|
|
|
#endif
|
|
|
|
#ifdef _HIGHLIGHTING
|
2009-05-02 04:37:38 +02:00
|
|
|
"\nCompiled with syntax highlighting support for:\n" ++
|
|
|
|
wrapWords 78 languages ++
|
2008-08-04 01:33:40 +02:00
|
|
|
#endif
|
2009-05-02 04:37:38 +02:00
|
|
|
""
|
2008-02-09 04:22:01 +01:00
|
|
|
|
2008-09-30 22:16:03 +02:00
|
|
|
-- | Converts a list of strings into a single string with the items printed as
|
|
|
|
-- comma separated words in lines with a maximum line length.
|
|
|
|
wrapWords :: Int -> [String] -> String
|
|
|
|
wrapWords c = wrap' c c where
|
|
|
|
wrap' _ _ [] = ""
|
|
|
|
wrap' cols remaining (x:xs) = if remaining == cols
|
|
|
|
then x ++ wrap' cols (remaining - length x) xs
|
|
|
|
else if (length x + 1) > remaining
|
|
|
|
then ",\n" ++ x ++ wrap' cols (cols - length x) xs
|
|
|
|
else ", " ++ x ++ wrap' cols (remaining - (length x + 2)) xs
|
2008-02-09 04:21:19 +01:00
|
|
|
|
2006-10-17 16:22:29 +02:00
|
|
|
-- | Association list of formats and readers.
|
|
|
|
readers :: [(String, ParserState -> String -> Pandoc)]
|
2008-12-02 23:43:17 +01:00
|
|
|
readers = [("native" , readPandoc)
|
|
|
|
,("markdown" , readMarkdown)
|
|
|
|
,("markdown+lhs" , readMarkdown)
|
|
|
|
,("rst" , readRST)
|
|
|
|
,("rst+lhs" , readRST)
|
|
|
|
,("html" , readHtml)
|
|
|
|
,("latex" , readLaTeX)
|
|
|
|
,("latex+lhs" , readLaTeX)
|
2006-10-17 16:22:29 +02:00
|
|
|
]
|
|
|
|
|
|
|
|
-- | Reader for native Pandoc format.
|
|
|
|
readPandoc :: ParserState -> String -> Pandoc
|
2009-01-24 20:59:07 +01:00
|
|
|
readPandoc _ = read
|
2008-08-10 19:33:20 +02:00
|
|
|
|
2009-12-31 02:10:57 +01:00
|
|
|
-- | Association list of formats and writers.
|
|
|
|
writers :: [ ( String, WriterOptions -> Pandoc -> String ) ]
|
|
|
|
writers = [("native" , writeDoc)
|
|
|
|
,("html" , writeHtmlString)
|
|
|
|
,("html+lhs" , writeHtmlString)
|
|
|
|
,("s5" , writeS5String)
|
|
|
|
,("docbook" , writeDocbook)
|
|
|
|
,("opendocument" , writeOpenDocument)
|
|
|
|
,("odt" , writeOpenDocument)
|
|
|
|
,("latex" , writeLaTeX)
|
|
|
|
,("latex+lhs" , writeLaTeX)
|
|
|
|
,("context" , writeConTeXt)
|
|
|
|
,("texinfo" , writeTexinfo)
|
|
|
|
,("man" , writeMan)
|
|
|
|
,("markdown" , writeMarkdown)
|
|
|
|
,("markdown+lhs" , writeMarkdown)
|
|
|
|
,("rst" , writeRST)
|
|
|
|
,("rst+lhs" , writeRST)
|
|
|
|
,("mediawiki" , writeMediaWiki)
|
|
|
|
,("rtf" , writeRTF)
|
2006-10-17 16:22:29 +02:00
|
|
|
]
|
|
|
|
|
2008-08-01 01:16:02 +02:00
|
|
|
isNonTextOutput :: String -> Bool
|
2008-08-27 07:50:26 +02:00
|
|
|
isNonTextOutput = (`elem` ["odt"])
|
2008-08-01 01:16:02 +02:00
|
|
|
|
2006-10-17 16:22:29 +02:00
|
|
|
-- | Writer for Pandoc native format.
|
|
|
|
writeDoc :: WriterOptions -> Pandoc -> String
|
2008-06-17 20:55:42 +02:00
|
|
|
writeDoc _ = prettyPandoc
|
2006-10-17 16:22:29 +02:00
|
|
|
|
|
|
|
-- | Data structure for command line options.
|
|
|
|
data Opt = Opt
|
2009-01-31 18:13:41 +01:00
|
|
|
{ optTabStop :: Int -- ^ Number of spaces per tab
|
2009-04-08 22:19:50 +02:00
|
|
|
, optPreserveTabs :: Bool -- ^ Preserve tabs instead of converting to spaces
|
2006-12-30 23:51:49 +01:00
|
|
|
, optStandalone :: Bool -- ^ Include header, footer
|
2006-12-28 03:20:09 +01:00
|
|
|
, optReader :: String -- ^ Reader format
|
|
|
|
, optWriter :: String -- ^ Writer format
|
2006-12-30 23:51:49 +01:00
|
|
|
, optParseRaw :: Bool -- ^ Parse unconvertable HTML and TeX
|
2007-07-07 07:43:23 +02:00
|
|
|
, optTableOfContents :: Bool -- ^ Include table of contents
|
2009-12-31 02:10:04 +01:00
|
|
|
, optTemplate :: String -- ^ Custom template
|
2009-12-31 02:09:56 +01:00
|
|
|
, optVariables :: [(String,String)] -- ^ Template variables to set
|
2009-12-31 02:12:59 +01:00
|
|
|
, optBefore :: [String] -- ^ Texts to include before body
|
|
|
|
, optAfter :: [String] -- ^ Texts to include after body
|
2006-12-22 21:16:03 +01:00
|
|
|
, optOutputFile :: String -- ^ Name of output file
|
2006-12-30 23:51:49 +01:00
|
|
|
, optNumberSections :: Bool -- ^ Number sections in LaTeX
|
|
|
|
, optIncremental :: Bool -- ^ Use incremental lists in S5
|
2009-12-31 02:18:06 +01:00
|
|
|
, optXeTeX :: Bool -- ^ Format latex for xetex
|
2006-12-30 23:51:49 +01:00
|
|
|
, optSmart :: Bool -- ^ Use smart typography
|
2007-12-01 04:11:52 +01:00
|
|
|
, optHTMLMathMethod :: HTMLMathMethod -- ^ Method to print HTML math
|
Changes to Pandoc's options to facilitate wrapper scripts:
+ removed -d/--debug option
+ added --dump-args option, which prints the name of the output file
(or '-' for STDOUT) and all the command-line arguments (excluding
Pandoc options and their arguments), one per line, then exits. Note
that special wrapper options will be treated as arguments if they
follow '--' at the end of the command line. Thus,
pandoc --dump-args -o foo.html foo.txt -- -e latin1
will print the following to STDOUT:
foo.html
foo.txt
-e
latin1
+ added --ignore-args option, which causes Pandoc to ignore all
(non-option) arguments, including any special options that occur
after '--' at the end of the command line.
+ '-' now means STDIN as the name of an input file, STDOUT as the
name of an output file. So,
pandoc -o - -
will take input from STDIN and print output to STDOUT. Note that
if multiple '-o' options are specified on the same line, the last
one takes precedence. So, in a script,
pandoc "$@" -o -
will guarantee output to STDOUT, even if the '-o' option was used.
+ documented these changes in man pages, README, and changelog.
git-svn-id: https://pandoc.googlecode.com/svn/trunk@454 788f1e2b-df1e-0410-8736-df70ead52e1b
2007-01-08 09:11:08 +01:00
|
|
|
, optDumpArgs :: Bool -- ^ Output command-line arguments
|
|
|
|
, optIgnoreArgs :: Bool -- ^ Ignore command-line arguments
|
2006-12-30 23:51:49 +01:00
|
|
|
, optStrict :: Bool -- ^ Use strict markdown syntax
|
Extensive changes stemming from a rethinking of the Pandoc data
structure. Key and Note blocks have been removed. Link and image URLs
are now stored directly in Link and Image inlines, and note blocks
are stored in Note inlines. This requires changes in both parsers
and writers. Markdown and RST parsers need to extract data from key
and note blocks and insert them into the relevant inline elements.
Other parsers can be simplified, since there is no longer any need to
construct separate key and note blocks. Markdown, RST, and HTML writers
need to construct lists of notes; Markdown and RST writers need to
construct lists of link references (when the --reference-links option
is specified); and the RST writer needs to construct a list of image
substitution references. All writers have been rewritten to use the
State monad when state is required. This rewrite yields a small speed
boost and considerably cleaner code.
* Text/Pandoc/Definition.hs:
+ blocks: removed Key and Note
+ inlines: removed NoteRef, added Note
+ modified Target: there is no longer a 'Ref' target; all targets
are explicit URL, title pairs
* Text/Pandoc/Shared.hs:
+ Added 'Reference', 'isNoteBlock', 'isKeyBlock', 'isLineClump',
used in some of the readers.
+ Removed 'generateReference', 'keyTable', 'replaceReferenceLinks',
'replaceRefLinksBlockList', along with some auxiliary functions
used only by them. These are no longer needed, since
reference links are resolved in the Markdown and RST readers.
+ Moved 'inTags', 'selfClosingTag', 'inTagsSimple', and 'inTagsIndented'
to the Docbook writer, since that is now the only module that uses
them.
+ Changed name of 'escapeSGMLString' to 'escapeStringForXML'
+ Added KeyTable and NoteTable types
+ Removed fields from ParserState; 'stateKeyBlocks', 'stateKeysUsed',
'stateNoteBlocks', 'stateNoteIdentifiers', 'stateInlineLinks'.
Added 'stateKeys' and 'stateNotes'.
+ Added clause for Note to 'prettyBlock'.
+ Added 'writerNotes', 'writerReferenceLinks' fields to WriterOptions.
* Text/Pandoc/Entities.hs: Renamed 'escapeSGMLChar' and
'escapeSGMLString' to 'escapeCharForXML' and 'escapeStringForXML'
* Text/ParserCombinators/Pandoc.hs: Added lineClump parser: parses a raw
line block up to and including following blank lines.
* Main.hs: Replaced --inline-links with --reference-links.
* README:
+ Documented --reference-links and removed description of --inline-links.
+ Added note that footnotes may occur anywhere in the document, but must
be at the outer level, not embedded in block elements.
* man/man1/pandoc.1, man/man1/html2markdown.1: Removed --inline-links
option, added --reference-links option
* Markdown and RST readers:
+ Rewrote to fit new Pandoc definition. Since there are no longer
Note or Key blocks, all note and key blocks are parsed on a first pass
through the document. Once tables of notes and keys have been constructed,
the remaining parts of the document are reassembled and parsed.
+ Refactored link parsers.
* LaTeX and HTML readers: Rewrote to fit new Pandoc definition. Since
there are no longer Note or Key blocks, notes and references can be
parsed in a single pass through the document.
* RST, Markdown, and HTML writers: Rewrote using state monad new Pandoc
and definition. State is used to hold lists of references footnotes to
and be printed at the end of the document.
* RTF and LaTeX writers: Rewrote using new Pandoc definition. (Because
of the different treatment of footnotes, the "notes" parameter is no
longer needed in the block and inline conversion functions.)
* Docbook writer:
+ Moved the functions 'attributeList', 'inTags', 'selfClosingTag',
'inTagsSimple', 'inTagsIndented' from Text/Pandoc/Shared, since
they are now used only by the Docbook writer.
+ Rewrote using new Pandoc definition. (Because of the different
treatment of footnotes, the "notes" parameter is no longer needed
in the block and inline conversion functions.)
* Updated test suite
* Throughout: old haskell98 module names replaced by hierarchical module
names, e.g. List by Data.List.
* debian/control: Include libghc6-xhtml-dev instead of libghc6-html-dev
in "Build-Depends."
* cabalize:
+ Remove haskell98 from BASE_DEPENDS (since now the new hierarchical
module names are being used throughout)
+ Added mtl to BASE_DEPENDS (needed for state monad)
+ Removed html from GHC66_DEPENDS (not needed since xhtml is now used)
git-svn-id: https://pandoc.googlecode.com/svn/trunk@580 788f1e2b-df1e-0410-8736-df70ead52e1b
2007-04-10 03:56:50 +02:00
|
|
|
, optReferenceLinks :: Bool -- ^ Use reference links in writing markdown, rst
|
2007-09-27 03:23:44 +02:00
|
|
|
, optWrapText :: Bool -- ^ Wrap text
|
2008-01-03 22:32:32 +01:00
|
|
|
, optSanitizeHTML :: Bool -- ^ Sanitize HTML
|
2009-01-24 20:58:06 +01:00
|
|
|
, optPlugins :: [Pandoc -> IO Pandoc] -- ^ Plugins to apply
|
2009-01-24 20:58:48 +01:00
|
|
|
, optEmailObfuscation :: ObfuscationMethod
|
2009-12-05 18:56:02 +01:00
|
|
|
, optIdentifierPrefix :: String
|
2009-12-05 05:46:57 +01:00
|
|
|
, optIndentedCodeClasses :: [String] -- ^ Default classes for indented code blocks
|
2008-08-04 05:15:34 +02:00
|
|
|
#ifdef _CITEPROC
|
2008-12-29 23:45:18 +01:00
|
|
|
, optBiblioFile :: String
|
|
|
|
, optBiblioFormat :: String
|
2008-08-04 05:15:34 +02:00
|
|
|
, optCslFile :: String
|
|
|
|
#endif
|
2006-10-17 16:22:29 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
-- | Defaults for command-line options.
|
2006-12-28 03:20:09 +01:00
|
|
|
defaultOpts :: Opt
|
|
|
|
defaultOpts = Opt
|
2009-01-31 18:13:41 +01:00
|
|
|
{ optTabStop = 4
|
2009-04-08 22:19:50 +02:00
|
|
|
, optPreserveTabs = False
|
2006-10-17 16:22:29 +02:00
|
|
|
, optStandalone = False
|
2006-12-28 03:20:09 +01:00
|
|
|
, optReader = "" -- null for default reader
|
|
|
|
, optWriter = "" -- null for default writer
|
2006-10-17 16:22:29 +02:00
|
|
|
, optParseRaw = False
|
2007-07-07 07:43:23 +02:00
|
|
|
, optTableOfContents = False
|
2009-12-31 02:10:04 +01:00
|
|
|
, optTemplate = ""
|
2009-12-31 02:09:56 +01:00
|
|
|
, optVariables = []
|
2009-12-31 02:12:59 +01:00
|
|
|
, optBefore = []
|
|
|
|
, optAfter = []
|
Changes to Pandoc's options to facilitate wrapper scripts:
+ removed -d/--debug option
+ added --dump-args option, which prints the name of the output file
(or '-' for STDOUT) and all the command-line arguments (excluding
Pandoc options and their arguments), one per line, then exits. Note
that special wrapper options will be treated as arguments if they
follow '--' at the end of the command line. Thus,
pandoc --dump-args -o foo.html foo.txt -- -e latin1
will print the following to STDOUT:
foo.html
foo.txt
-e
latin1
+ added --ignore-args option, which causes Pandoc to ignore all
(non-option) arguments, including any special options that occur
after '--' at the end of the command line.
+ '-' now means STDIN as the name of an input file, STDOUT as the
name of an output file. So,
pandoc -o - -
will take input from STDIN and print output to STDOUT. Note that
if multiple '-o' options are specified on the same line, the last
one takes precedence. So, in a script,
pandoc "$@" -o -
will guarantee output to STDOUT, even if the '-o' option was used.
+ documented these changes in man pages, README, and changelog.
git-svn-id: https://pandoc.googlecode.com/svn/trunk@454 788f1e2b-df1e-0410-8736-df70ead52e1b
2007-01-08 09:11:08 +01:00
|
|
|
, optOutputFile = "-" -- "-" means stdout
|
2006-10-17 16:22:29 +02:00
|
|
|
, optNumberSections = False
|
|
|
|
, optIncremental = False
|
2009-12-31 02:18:06 +01:00
|
|
|
, optXeTeX = False
|
2006-12-18 23:02:39 +01:00
|
|
|
, optSmart = False
|
2007-12-01 04:11:52 +01:00
|
|
|
, optHTMLMathMethod = PlainMath
|
Changes to Pandoc's options to facilitate wrapper scripts:
+ removed -d/--debug option
+ added --dump-args option, which prints the name of the output file
(or '-' for STDOUT) and all the command-line arguments (excluding
Pandoc options and their arguments), one per line, then exits. Note
that special wrapper options will be treated as arguments if they
follow '--' at the end of the command line. Thus,
pandoc --dump-args -o foo.html foo.txt -- -e latin1
will print the following to STDOUT:
foo.html
foo.txt
-e
latin1
+ added --ignore-args option, which causes Pandoc to ignore all
(non-option) arguments, including any special options that occur
after '--' at the end of the command line.
+ '-' now means STDIN as the name of an input file, STDOUT as the
name of an output file. So,
pandoc -o - -
will take input from STDIN and print output to STDOUT. Note that
if multiple '-o' options are specified on the same line, the last
one takes precedence. So, in a script,
pandoc "$@" -o -
will guarantee output to STDOUT, even if the '-o' option was used.
+ documented these changes in man pages, README, and changelog.
git-svn-id: https://pandoc.googlecode.com/svn/trunk@454 788f1e2b-df1e-0410-8736-df70ead52e1b
2007-01-08 09:11:08 +01:00
|
|
|
, optDumpArgs = False
|
|
|
|
, optIgnoreArgs = False
|
2006-12-30 23:51:49 +01:00
|
|
|
, optStrict = False
|
Extensive changes stemming from a rethinking of the Pandoc data
structure. Key and Note blocks have been removed. Link and image URLs
are now stored directly in Link and Image inlines, and note blocks
are stored in Note inlines. This requires changes in both parsers
and writers. Markdown and RST parsers need to extract data from key
and note blocks and insert them into the relevant inline elements.
Other parsers can be simplified, since there is no longer any need to
construct separate key and note blocks. Markdown, RST, and HTML writers
need to construct lists of notes; Markdown and RST writers need to
construct lists of link references (when the --reference-links option
is specified); and the RST writer needs to construct a list of image
substitution references. All writers have been rewritten to use the
State monad when state is required. This rewrite yields a small speed
boost and considerably cleaner code.
* Text/Pandoc/Definition.hs:
+ blocks: removed Key and Note
+ inlines: removed NoteRef, added Note
+ modified Target: there is no longer a 'Ref' target; all targets
are explicit URL, title pairs
* Text/Pandoc/Shared.hs:
+ Added 'Reference', 'isNoteBlock', 'isKeyBlock', 'isLineClump',
used in some of the readers.
+ Removed 'generateReference', 'keyTable', 'replaceReferenceLinks',
'replaceRefLinksBlockList', along with some auxiliary functions
used only by them. These are no longer needed, since
reference links are resolved in the Markdown and RST readers.
+ Moved 'inTags', 'selfClosingTag', 'inTagsSimple', and 'inTagsIndented'
to the Docbook writer, since that is now the only module that uses
them.
+ Changed name of 'escapeSGMLString' to 'escapeStringForXML'
+ Added KeyTable and NoteTable types
+ Removed fields from ParserState; 'stateKeyBlocks', 'stateKeysUsed',
'stateNoteBlocks', 'stateNoteIdentifiers', 'stateInlineLinks'.
Added 'stateKeys' and 'stateNotes'.
+ Added clause for Note to 'prettyBlock'.
+ Added 'writerNotes', 'writerReferenceLinks' fields to WriterOptions.
* Text/Pandoc/Entities.hs: Renamed 'escapeSGMLChar' and
'escapeSGMLString' to 'escapeCharForXML' and 'escapeStringForXML'
* Text/ParserCombinators/Pandoc.hs: Added lineClump parser: parses a raw
line block up to and including following blank lines.
* Main.hs: Replaced --inline-links with --reference-links.
* README:
+ Documented --reference-links and removed description of --inline-links.
+ Added note that footnotes may occur anywhere in the document, but must
be at the outer level, not embedded in block elements.
* man/man1/pandoc.1, man/man1/html2markdown.1: Removed --inline-links
option, added --reference-links option
* Markdown and RST readers:
+ Rewrote to fit new Pandoc definition. Since there are no longer
Note or Key blocks, all note and key blocks are parsed on a first pass
through the document. Once tables of notes and keys have been constructed,
the remaining parts of the document are reassembled and parsed.
+ Refactored link parsers.
* LaTeX and HTML readers: Rewrote to fit new Pandoc definition. Since
there are no longer Note or Key blocks, notes and references can be
parsed in a single pass through the document.
* RST, Markdown, and HTML writers: Rewrote using state monad new Pandoc
and definition. State is used to hold lists of references footnotes to
and be printed at the end of the document.
* RTF and LaTeX writers: Rewrote using new Pandoc definition. (Because
of the different treatment of footnotes, the "notes" parameter is no
longer needed in the block and inline conversion functions.)
* Docbook writer:
+ Moved the functions 'attributeList', 'inTags', 'selfClosingTag',
'inTagsSimple', 'inTagsIndented' from Text/Pandoc/Shared, since
they are now used only by the Docbook writer.
+ Rewrote using new Pandoc definition. (Because of the different
treatment of footnotes, the "notes" parameter is no longer needed
in the block and inline conversion functions.)
* Updated test suite
* Throughout: old haskell98 module names replaced by hierarchical module
names, e.g. List by Data.List.
* debian/control: Include libghc6-xhtml-dev instead of libghc6-html-dev
in "Build-Depends."
* cabalize:
+ Remove haskell98 from BASE_DEPENDS (since now the new hierarchical
module names are being used throughout)
+ Added mtl to BASE_DEPENDS (needed for state monad)
+ Removed html from GHC66_DEPENDS (not needed since xhtml is now used)
git-svn-id: https://pandoc.googlecode.com/svn/trunk@580 788f1e2b-df1e-0410-8736-df70ead52e1b
2007-04-10 03:56:50 +02:00
|
|
|
, optReferenceLinks = False
|
2007-09-27 03:23:44 +02:00
|
|
|
, optWrapText = True
|
2008-01-03 22:32:32 +01:00
|
|
|
, optSanitizeHTML = False
|
2009-01-24 20:58:06 +01:00
|
|
|
, optPlugins = []
|
2009-01-24 20:58:48 +01:00
|
|
|
, optEmailObfuscation = JavascriptObfuscation
|
2009-12-05 18:56:02 +01:00
|
|
|
, optIdentifierPrefix = ""
|
2009-12-05 05:46:57 +01:00
|
|
|
, optIndentedCodeClasses = []
|
2008-08-04 05:15:34 +02:00
|
|
|
#ifdef _CITEPROC
|
2008-12-29 23:45:18 +01:00
|
|
|
, optBiblioFile = []
|
|
|
|
, optBiblioFormat = []
|
2008-08-04 05:15:34 +02:00
|
|
|
, optCslFile = []
|
|
|
|
#endif
|
2006-10-17 16:22:29 +02:00
|
|
|
}
|
|
|
|
|
2006-12-28 03:20:09 +01:00
|
|
|
-- | A list of functions, each transforming the options data structure
|
|
|
|
-- in response to a command-line option.
|
|
|
|
options :: [OptDescr (Opt -> IO Opt)]
|
|
|
|
options =
|
2006-12-22 21:16:03 +01:00
|
|
|
[ Option "fr" ["from","read"]
|
2006-10-17 16:22:29 +02:00
|
|
|
(ReqArg
|
2006-12-28 03:20:09 +01:00
|
|
|
(\arg opt -> return opt { optReader = map toLower arg })
|
2006-10-17 16:22:29 +02:00
|
|
|
"FORMAT")
|
2008-09-08 08:36:28 +02:00
|
|
|
"" -- ("(" ++ (intercalate ", " $ map fst readers) ++ ")")
|
2006-10-17 16:22:29 +02:00
|
|
|
|
|
|
|
, Option "tw" ["to","write"]
|
|
|
|
(ReqArg
|
2006-12-28 03:20:09 +01:00
|
|
|
(\arg opt -> return opt { optWriter = map toLower arg })
|
2006-10-17 16:22:29 +02:00
|
|
|
"FORMAT")
|
2008-09-08 08:36:28 +02:00
|
|
|
"" -- ("(" ++ (intercalate ", " $ map fst writers) ++ ")")
|
2008-08-10 19:33:20 +02:00
|
|
|
|
2006-10-17 16:22:29 +02:00
|
|
|
, Option "s" ["standalone"]
|
|
|
|
(NoArg
|
2009-12-31 02:15:08 +01:00
|
|
|
(\opt -> return opt { optStandalone = True }))
|
2006-12-31 02:12:01 +01:00
|
|
|
"" -- "Include needed header and footer on output"
|
2006-10-17 16:22:29 +02:00
|
|
|
|
2006-12-22 21:16:03 +01:00
|
|
|
, Option "o" ["output"]
|
|
|
|
(ReqArg
|
2006-12-28 03:20:09 +01:00
|
|
|
(\arg opt -> return opt { optOutputFile = arg })
|
2006-12-22 21:16:03 +01:00
|
|
|
"FILENAME")
|
2006-12-31 02:12:01 +01:00
|
|
|
"" -- "Name of output file"
|
2006-12-22 21:16:03 +01:00
|
|
|
|
2006-10-17 16:22:29 +02:00
|
|
|
, Option "p" ["preserve-tabs"]
|
|
|
|
(NoArg
|
2009-04-08 22:19:50 +02:00
|
|
|
(\opt -> return opt { optPreserveTabs = True }))
|
2006-12-31 02:12:01 +01:00
|
|
|
"" -- "Preserve tabs instead of converting to spaces"
|
2006-10-17 16:22:29 +02:00
|
|
|
|
|
|
|
, Option "" ["tab-stop"]
|
|
|
|
(ReqArg
|
|
|
|
(\arg opt -> return opt { optTabStop = (read arg) } )
|
|
|
|
"TABSTOP")
|
2006-12-31 02:12:01 +01:00
|
|
|
"" -- "Tab stop (default 4)"
|
2006-10-17 16:22:29 +02:00
|
|
|
|
2006-12-30 23:51:49 +01:00
|
|
|
, Option "" ["strict"]
|
|
|
|
(NoArg
|
|
|
|
(\opt -> return opt { optStrict = True } ))
|
2007-07-22 21:20:21 +02:00
|
|
|
"" -- "Disable markdown syntax extensions"
|
2006-12-30 23:51:49 +01:00
|
|
|
|
Extensive changes stemming from a rethinking of the Pandoc data
structure. Key and Note blocks have been removed. Link and image URLs
are now stored directly in Link and Image inlines, and note blocks
are stored in Note inlines. This requires changes in both parsers
and writers. Markdown and RST parsers need to extract data from key
and note blocks and insert them into the relevant inline elements.
Other parsers can be simplified, since there is no longer any need to
construct separate key and note blocks. Markdown, RST, and HTML writers
need to construct lists of notes; Markdown and RST writers need to
construct lists of link references (when the --reference-links option
is specified); and the RST writer needs to construct a list of image
substitution references. All writers have been rewritten to use the
State monad when state is required. This rewrite yields a small speed
boost and considerably cleaner code.
* Text/Pandoc/Definition.hs:
+ blocks: removed Key and Note
+ inlines: removed NoteRef, added Note
+ modified Target: there is no longer a 'Ref' target; all targets
are explicit URL, title pairs
* Text/Pandoc/Shared.hs:
+ Added 'Reference', 'isNoteBlock', 'isKeyBlock', 'isLineClump',
used in some of the readers.
+ Removed 'generateReference', 'keyTable', 'replaceReferenceLinks',
'replaceRefLinksBlockList', along with some auxiliary functions
used only by them. These are no longer needed, since
reference links are resolved in the Markdown and RST readers.
+ Moved 'inTags', 'selfClosingTag', 'inTagsSimple', and 'inTagsIndented'
to the Docbook writer, since that is now the only module that uses
them.
+ Changed name of 'escapeSGMLString' to 'escapeStringForXML'
+ Added KeyTable and NoteTable types
+ Removed fields from ParserState; 'stateKeyBlocks', 'stateKeysUsed',
'stateNoteBlocks', 'stateNoteIdentifiers', 'stateInlineLinks'.
Added 'stateKeys' and 'stateNotes'.
+ Added clause for Note to 'prettyBlock'.
+ Added 'writerNotes', 'writerReferenceLinks' fields to WriterOptions.
* Text/Pandoc/Entities.hs: Renamed 'escapeSGMLChar' and
'escapeSGMLString' to 'escapeCharForXML' and 'escapeStringForXML'
* Text/ParserCombinators/Pandoc.hs: Added lineClump parser: parses a raw
line block up to and including following blank lines.
* Main.hs: Replaced --inline-links with --reference-links.
* README:
+ Documented --reference-links and removed description of --inline-links.
+ Added note that footnotes may occur anywhere in the document, but must
be at the outer level, not embedded in block elements.
* man/man1/pandoc.1, man/man1/html2markdown.1: Removed --inline-links
option, added --reference-links option
* Markdown and RST readers:
+ Rewrote to fit new Pandoc definition. Since there are no longer
Note or Key blocks, all note and key blocks are parsed on a first pass
through the document. Once tables of notes and keys have been constructed,
the remaining parts of the document are reassembled and parsed.
+ Refactored link parsers.
* LaTeX and HTML readers: Rewrote to fit new Pandoc definition. Since
there are no longer Note or Key blocks, notes and references can be
parsed in a single pass through the document.
* RST, Markdown, and HTML writers: Rewrote using state monad new Pandoc
and definition. State is used to hold lists of references footnotes to
and be printed at the end of the document.
* RTF and LaTeX writers: Rewrote using new Pandoc definition. (Because
of the different treatment of footnotes, the "notes" parameter is no
longer needed in the block and inline conversion functions.)
* Docbook writer:
+ Moved the functions 'attributeList', 'inTags', 'selfClosingTag',
'inTagsSimple', 'inTagsIndented' from Text/Pandoc/Shared, since
they are now used only by the Docbook writer.
+ Rewrote using new Pandoc definition. (Because of the different
treatment of footnotes, the "notes" parameter is no longer needed
in the block and inline conversion functions.)
* Updated test suite
* Throughout: old haskell98 module names replaced by hierarchical module
names, e.g. List by Data.List.
* debian/control: Include libghc6-xhtml-dev instead of libghc6-html-dev
in "Build-Depends."
* cabalize:
+ Remove haskell98 from BASE_DEPENDS (since now the new hierarchical
module names are being used throughout)
+ Added mtl to BASE_DEPENDS (needed for state monad)
+ Removed html from GHC66_DEPENDS (not needed since xhtml is now used)
git-svn-id: https://pandoc.googlecode.com/svn/trunk@580 788f1e2b-df1e-0410-8736-df70ead52e1b
2007-04-10 03:56:50 +02:00
|
|
|
, Option "" ["reference-links"]
|
2007-03-03 19:19:31 +01:00
|
|
|
(NoArg
|
Extensive changes stemming from a rethinking of the Pandoc data
structure. Key and Note blocks have been removed. Link and image URLs
are now stored directly in Link and Image inlines, and note blocks
are stored in Note inlines. This requires changes in both parsers
and writers. Markdown and RST parsers need to extract data from key
and note blocks and insert them into the relevant inline elements.
Other parsers can be simplified, since there is no longer any need to
construct separate key and note blocks. Markdown, RST, and HTML writers
need to construct lists of notes; Markdown and RST writers need to
construct lists of link references (when the --reference-links option
is specified); and the RST writer needs to construct a list of image
substitution references. All writers have been rewritten to use the
State monad when state is required. This rewrite yields a small speed
boost and considerably cleaner code.
* Text/Pandoc/Definition.hs:
+ blocks: removed Key and Note
+ inlines: removed NoteRef, added Note
+ modified Target: there is no longer a 'Ref' target; all targets
are explicit URL, title pairs
* Text/Pandoc/Shared.hs:
+ Added 'Reference', 'isNoteBlock', 'isKeyBlock', 'isLineClump',
used in some of the readers.
+ Removed 'generateReference', 'keyTable', 'replaceReferenceLinks',
'replaceRefLinksBlockList', along with some auxiliary functions
used only by them. These are no longer needed, since
reference links are resolved in the Markdown and RST readers.
+ Moved 'inTags', 'selfClosingTag', 'inTagsSimple', and 'inTagsIndented'
to the Docbook writer, since that is now the only module that uses
them.
+ Changed name of 'escapeSGMLString' to 'escapeStringForXML'
+ Added KeyTable and NoteTable types
+ Removed fields from ParserState; 'stateKeyBlocks', 'stateKeysUsed',
'stateNoteBlocks', 'stateNoteIdentifiers', 'stateInlineLinks'.
Added 'stateKeys' and 'stateNotes'.
+ Added clause for Note to 'prettyBlock'.
+ Added 'writerNotes', 'writerReferenceLinks' fields to WriterOptions.
* Text/Pandoc/Entities.hs: Renamed 'escapeSGMLChar' and
'escapeSGMLString' to 'escapeCharForXML' and 'escapeStringForXML'
* Text/ParserCombinators/Pandoc.hs: Added lineClump parser: parses a raw
line block up to and including following blank lines.
* Main.hs: Replaced --inline-links with --reference-links.
* README:
+ Documented --reference-links and removed description of --inline-links.
+ Added note that footnotes may occur anywhere in the document, but must
be at the outer level, not embedded in block elements.
* man/man1/pandoc.1, man/man1/html2markdown.1: Removed --inline-links
option, added --reference-links option
* Markdown and RST readers:
+ Rewrote to fit new Pandoc definition. Since there are no longer
Note or Key blocks, all note and key blocks are parsed on a first pass
through the document. Once tables of notes and keys have been constructed,
the remaining parts of the document are reassembled and parsed.
+ Refactored link parsers.
* LaTeX and HTML readers: Rewrote to fit new Pandoc definition. Since
there are no longer Note or Key blocks, notes and references can be
parsed in a single pass through the document.
* RST, Markdown, and HTML writers: Rewrote using state monad new Pandoc
and definition. State is used to hold lists of references footnotes to
and be printed at the end of the document.
* RTF and LaTeX writers: Rewrote using new Pandoc definition. (Because
of the different treatment of footnotes, the "notes" parameter is no
longer needed in the block and inline conversion functions.)
* Docbook writer:
+ Moved the functions 'attributeList', 'inTags', 'selfClosingTag',
'inTagsSimple', 'inTagsIndented' from Text/Pandoc/Shared, since
they are now used only by the Docbook writer.
+ Rewrote using new Pandoc definition. (Because of the different
treatment of footnotes, the "notes" parameter is no longer needed
in the block and inline conversion functions.)
* Updated test suite
* Throughout: old haskell98 module names replaced by hierarchical module
names, e.g. List by Data.List.
* debian/control: Include libghc6-xhtml-dev instead of libghc6-html-dev
in "Build-Depends."
* cabalize:
+ Remove haskell98 from BASE_DEPENDS (since now the new hierarchical
module names are being used throughout)
+ Added mtl to BASE_DEPENDS (needed for state monad)
+ Removed html from GHC66_DEPENDS (not needed since xhtml is now used)
git-svn-id: https://pandoc.googlecode.com/svn/trunk@580 788f1e2b-df1e-0410-8736-df70ead52e1b
2007-04-10 03:56:50 +02:00
|
|
|
(\opt -> return opt { optReferenceLinks = True } ))
|
|
|
|
"" -- "Use reference links in parsing HTML"
|
2007-03-03 19:19:31 +01:00
|
|
|
|
2006-10-17 16:22:29 +02:00
|
|
|
, Option "R" ["parse-raw"]
|
|
|
|
(NoArg
|
|
|
|
(\opt -> return opt { optParseRaw = True }))
|
2006-12-31 02:12:01 +01:00
|
|
|
"" -- "Parse untranslatable HTML codes and LaTeX environments as raw"
|
2006-10-17 16:22:29 +02:00
|
|
|
|
2006-12-18 23:02:39 +01:00
|
|
|
, Option "S" ["smart"]
|
2006-10-17 16:22:29 +02:00
|
|
|
(NoArg
|
2006-12-18 23:02:39 +01:00
|
|
|
(\opt -> return opt { optSmart = True }))
|
2007-01-06 10:54:58 +01:00
|
|
|
"" -- "Use smart quotes, dashes, and ellipses"
|
2006-10-17 16:22:29 +02:00
|
|
|
|
2008-08-13 05:02:42 +02:00
|
|
|
, Option "m" ["latexmathml", "asciimathml"]
|
2007-07-26 04:19:20 +02:00
|
|
|
(OptArg
|
2009-12-31 02:13:16 +01:00
|
|
|
(\arg opt ->
|
|
|
|
return opt { optHTMLMathMethod = LaTeXMathML arg })
|
2007-07-26 04:19:20 +02:00
|
|
|
"URL")
|
2008-08-13 05:02:42 +02:00
|
|
|
"" -- "Use LaTeXMathML script in html output"
|
2006-10-17 16:22:29 +02:00
|
|
|
|
2007-12-01 04:11:52 +01:00
|
|
|
, Option "" ["mimetex"]
|
|
|
|
(OptArg
|
|
|
|
(\arg opt -> return opt { optHTMLMathMethod = MimeTeX
|
|
|
|
(fromMaybe "/cgi-bin/mimetex.cgi" arg)})
|
|
|
|
"URL")
|
|
|
|
"" -- "Use mimetex for HTML math"
|
|
|
|
|
2008-10-28 22:54:50 +01:00
|
|
|
, Option "" ["jsmath"]
|
|
|
|
(OptArg
|
|
|
|
(\arg opt -> return opt { optHTMLMathMethod = JsMath arg})
|
|
|
|
"URL")
|
|
|
|
"" -- "Use jsMath for HTML math"
|
|
|
|
|
2007-12-01 04:11:52 +01:00
|
|
|
, Option "" ["gladtex"]
|
|
|
|
(NoArg
|
|
|
|
(\opt -> return opt { optHTMLMathMethod = GladTeX }))
|
|
|
|
"" -- "Use gladtex for HTML math"
|
|
|
|
|
2006-10-17 16:22:29 +02:00
|
|
|
, Option "i" ["incremental"]
|
|
|
|
(NoArg
|
|
|
|
(\opt -> return opt { optIncremental = True }))
|
2006-12-31 02:12:01 +01:00
|
|
|
"" -- "Make list items display incrementally in S5"
|
2006-10-17 16:22:29 +02:00
|
|
|
|
2009-12-31 02:18:06 +01:00
|
|
|
, Option "" ["xetex"]
|
|
|
|
(NoArg
|
|
|
|
(\opt -> return opt { optXeTeX = True }))
|
|
|
|
"" -- "Format latex for processing by XeTeX"
|
|
|
|
|
2006-10-17 16:22:29 +02:00
|
|
|
, Option "N" ["number-sections"]
|
|
|
|
(NoArg
|
|
|
|
(\opt -> return opt { optNumberSections = True }))
|
2006-12-31 02:12:01 +01:00
|
|
|
"" -- "Number sections in LaTeX"
|
2006-10-17 16:22:29 +02:00
|
|
|
|
2007-09-27 03:23:44 +02:00
|
|
|
, Option "" ["no-wrap"]
|
|
|
|
(NoArg
|
|
|
|
(\opt -> return opt { optWrapText = False }))
|
|
|
|
"" -- "Do not wrap text in output"
|
|
|
|
|
2008-01-03 22:32:32 +01:00
|
|
|
, Option "" ["sanitize-html"]
|
|
|
|
(NoArg
|
|
|
|
(\opt -> return opt { optSanitizeHTML = True }))
|
|
|
|
"" -- "Sanitize HTML"
|
|
|
|
|
2009-01-24 20:58:48 +01:00
|
|
|
, Option "" ["email-obfuscation"]
|
|
|
|
(ReqArg
|
|
|
|
(\arg opt -> do
|
|
|
|
method <- case arg of
|
|
|
|
"references" -> return ReferenceObfuscation
|
|
|
|
"javascript" -> return JavascriptObfuscation
|
|
|
|
"none" -> return NoObfuscation
|
|
|
|
_ -> hPutStrLn stderr ("Error: Unknown obfuscation method: " ++ arg) >>
|
|
|
|
exitWith (ExitFailure 6)
|
|
|
|
return opt { optEmailObfuscation = method })
|
|
|
|
"none|javascript|references")
|
|
|
|
"" -- "Method for obfuscating email in HTML"
|
|
|
|
|
2009-12-05 18:56:02 +01:00
|
|
|
, Option "" ["id-prefix"]
|
|
|
|
(ReqArg
|
|
|
|
(\arg opt -> return opt { optIdentifierPrefix = arg })
|
|
|
|
"STRING")
|
|
|
|
"" -- "Prefix to add to automatically generated HTML identifiers"
|
|
|
|
|
2009-12-05 05:46:57 +01:00
|
|
|
, Option "" ["indented-code-classes"]
|
2009-12-01 07:56:47 +01:00
|
|
|
(ReqArg
|
2009-12-05 05:46:57 +01:00
|
|
|
(\arg opt -> return opt { optIndentedCodeClasses = words $
|
2009-12-01 07:56:47 +01:00
|
|
|
map (\c -> if c == ',' then ' ' else c) arg })
|
|
|
|
"STRING")
|
|
|
|
"" -- "Classes (whitespace- or comma-separated) to use for indented code-blocks"
|
|
|
|
|
2007-07-12 05:27:24 +02:00
|
|
|
, Option "" ["toc", "table-of-contents"]
|
|
|
|
(NoArg
|
|
|
|
(\opt -> return opt { optTableOfContents = True }))
|
2008-08-10 19:33:20 +02:00
|
|
|
"" -- "Include table of contents"
|
2007-07-12 05:27:24 +02:00
|
|
|
|
2009-12-31 02:10:04 +01:00
|
|
|
, Option "" ["template"]
|
|
|
|
(ReqArg
|
|
|
|
(\arg opt -> do
|
|
|
|
text <- readFile arg
|
|
|
|
return opt{ optTemplate = text,
|
|
|
|
optStandalone = True })
|
|
|
|
"FILENAME")
|
|
|
|
"" -- "Use custom template"
|
|
|
|
|
2009-12-31 02:10:26 +01:00
|
|
|
, Option "V" ["variable"]
|
|
|
|
(ReqArg
|
|
|
|
(\arg opt ->
|
|
|
|
case break (`elem` ":=") arg of
|
|
|
|
(k,_:v) -> do
|
2009-12-31 02:15:50 +01:00
|
|
|
let newvars = optVariables opt ++ [(k,v)]
|
2009-12-31 02:10:26 +01:00
|
|
|
return opt{ optVariables = newvars }
|
|
|
|
_ -> do
|
|
|
|
hPutStrLn stderr $ "Could not parse `" ++ arg ++ "' as a key/value pair (k=v or k:v)"
|
|
|
|
exitWith $ ExitFailure 17)
|
|
|
|
"FILENAME")
|
|
|
|
"" -- "Use custom template"
|
|
|
|
|
2006-10-17 16:22:29 +02:00
|
|
|
, Option "c" ["css"]
|
|
|
|
(ReqArg
|
2008-08-10 19:33:20 +02:00
|
|
|
(\arg opt -> do
|
2009-12-31 02:15:50 +01:00
|
|
|
-- add new link to end, so it is included in proper order
|
|
|
|
let newvars = optVariables opt ++ [("css",arg)]
|
2009-12-31 02:10:32 +01:00
|
|
|
return opt { optVariables = newvars,
|
2008-01-08 21:21:28 +01:00
|
|
|
optStandalone = True })
|
2009-12-31 02:10:04 +01:00
|
|
|
"URL")
|
2006-12-31 02:12:01 +01:00
|
|
|
"" -- "Link to CSS style sheet"
|
2006-10-17 16:22:29 +02:00
|
|
|
|
|
|
|
, Option "H" ["include-in-header"]
|
|
|
|
(ReqArg
|
|
|
|
(\arg opt -> do
|
|
|
|
text <- readFile arg
|
2009-12-31 02:15:50 +01:00
|
|
|
-- add new ones to end, so they're included in order specified
|
|
|
|
let newvars = optVariables opt ++ [("header-includes",text)]
|
2009-12-31 02:10:32 +01:00
|
|
|
return opt { optVariables = newvars,
|
2006-12-20 07:50:14 +01:00
|
|
|
optStandalone = True })
|
2006-10-17 16:22:29 +02:00
|
|
|
"FILENAME")
|
2006-12-31 02:12:01 +01:00
|
|
|
"" -- "File to include at end of header (implies -s)"
|
2006-10-17 16:22:29 +02:00
|
|
|
|
|
|
|
, Option "B" ["include-before-body"]
|
|
|
|
(ReqArg
|
|
|
|
(\arg opt -> do
|
|
|
|
text <- readFile arg
|
2009-12-31 02:12:59 +01:00
|
|
|
let oldBefore = optBefore opt
|
2009-12-31 02:15:50 +01:00
|
|
|
-- add new text to end, so it is included in proper order
|
|
|
|
return opt { optBefore = oldBefore ++ [text] })
|
2006-10-17 16:22:29 +02:00
|
|
|
"FILENAME")
|
2006-12-31 02:12:01 +01:00
|
|
|
"" -- "File to include before document body"
|
2006-10-17 16:22:29 +02:00
|
|
|
|
|
|
|
, Option "A" ["include-after-body"]
|
|
|
|
(ReqArg
|
|
|
|
(\arg opt -> do
|
|
|
|
text <- readFile arg
|
2009-12-31 02:12:59 +01:00
|
|
|
let oldAfter = optAfter opt
|
2009-12-31 02:15:50 +01:00
|
|
|
-- add new text to end, so it is included in proper order
|
|
|
|
return opt { optAfter = oldAfter ++ [text]})
|
2006-10-17 16:22:29 +02:00
|
|
|
"FILENAME")
|
2006-12-31 02:12:01 +01:00
|
|
|
"" -- "File to include after document body"
|
2006-10-17 16:22:29 +02:00
|
|
|
|
2006-12-22 21:16:03 +01:00
|
|
|
, Option "C" ["custom-header"]
|
2006-10-17 16:22:29 +02:00
|
|
|
(ReqArg
|
|
|
|
(\arg opt -> do
|
2009-12-31 02:09:56 +01:00
|
|
|
hPutStrLn stderr $
|
|
|
|
"Warning: The -C/--custom-header is deprecated.\n" ++
|
|
|
|
"Please transition to using --template instead."
|
2006-10-17 16:22:29 +02:00
|
|
|
text <- readFile arg
|
2009-12-31 02:09:56 +01:00
|
|
|
let newVars = ("legacy-header", text) : optVariables opt
|
|
|
|
return opt { optVariables = newVars
|
|
|
|
, optStandalone = True })
|
2006-10-17 16:22:29 +02:00
|
|
|
"FILENAME")
|
2006-12-31 02:12:01 +01:00
|
|
|
"" -- "File to use for custom header (implies -s)"
|
2006-10-17 16:22:29 +02:00
|
|
|
|
|
|
|
, Option "T" ["title-prefix"]
|
|
|
|
(ReqArg
|
2009-12-31 02:10:17 +01:00
|
|
|
(\arg opt -> do
|
|
|
|
let newvars = ("title-prefix", arg) : optVariables opt
|
|
|
|
return opt { optVariables = newvars,
|
|
|
|
optStandalone = True })
|
2006-10-17 16:22:29 +02:00
|
|
|
"STRING")
|
2006-12-31 02:12:01 +01:00
|
|
|
"" -- "String to prefix to HTML window title"
|
2008-08-10 19:33:20 +02:00
|
|
|
|
2009-12-31 02:09:36 +01:00
|
|
|
, Option "D" ["print-default-template"]
|
2006-10-17 16:22:29 +02:00
|
|
|
(ReqArg
|
2008-06-17 20:55:42 +02:00
|
|
|
(\arg _ -> do
|
2009-12-31 02:10:57 +01:00
|
|
|
templ <- getDefaultTemplate arg
|
|
|
|
case templ of
|
|
|
|
Right t -> hPutStr stdout t
|
|
|
|
Left e -> error $ show e
|
2006-10-17 16:22:29 +02:00
|
|
|
exitWith ExitSuccess)
|
|
|
|
"FORMAT")
|
2009-12-31 02:09:36 +01:00
|
|
|
"" -- "Print default template for FORMAT"
|
2008-08-04 05:15:34 +02:00
|
|
|
#ifdef _CITEPROC
|
2008-12-29 23:45:18 +01:00
|
|
|
, Option "" ["biblio"]
|
2008-08-04 05:15:34 +02:00
|
|
|
(ReqArg
|
2008-12-29 23:45:18 +01:00
|
|
|
(\arg opt -> return opt { optBiblioFile = arg} )
|
2008-08-04 05:15:34 +02:00
|
|
|
"FILENAME")
|
|
|
|
""
|
2008-12-29 23:45:18 +01:00
|
|
|
, Option "" ["biblio-format"]
|
|
|
|
(ReqArg
|
|
|
|
(\arg opt -> return opt { optBiblioFormat = arg} )
|
|
|
|
"STRING")
|
|
|
|
""
|
2008-08-04 05:15:34 +02:00
|
|
|
, Option "" ["csl"]
|
|
|
|
(ReqArg
|
|
|
|
(\arg opt -> return opt { optCslFile = arg} )
|
|
|
|
"FILENAME")
|
|
|
|
""
|
|
|
|
#endif
|
Changes to Pandoc's options to facilitate wrapper scripts:
+ removed -d/--debug option
+ added --dump-args option, which prints the name of the output file
(or '-' for STDOUT) and all the command-line arguments (excluding
Pandoc options and their arguments), one per line, then exits. Note
that special wrapper options will be treated as arguments if they
follow '--' at the end of the command line. Thus,
pandoc --dump-args -o foo.html foo.txt -- -e latin1
will print the following to STDOUT:
foo.html
foo.txt
-e
latin1
+ added --ignore-args option, which causes Pandoc to ignore all
(non-option) arguments, including any special options that occur
after '--' at the end of the command line.
+ '-' now means STDIN as the name of an input file, STDOUT as the
name of an output file. So,
pandoc -o - -
will take input from STDIN and print output to STDOUT. Note that
if multiple '-o' options are specified on the same line, the last
one takes precedence. So, in a script,
pandoc "$@" -o -
will guarantee output to STDOUT, even if the '-o' option was used.
+ documented these changes in man pages, README, and changelog.
git-svn-id: https://pandoc.googlecode.com/svn/trunk@454 788f1e2b-df1e-0410-8736-df70ead52e1b
2007-01-08 09:11:08 +01:00
|
|
|
, Option "" ["dump-args"]
|
2006-12-22 21:16:03 +01:00
|
|
|
(NoArg
|
Changes to Pandoc's options to facilitate wrapper scripts:
+ removed -d/--debug option
+ added --dump-args option, which prints the name of the output file
(or '-' for STDOUT) and all the command-line arguments (excluding
Pandoc options and their arguments), one per line, then exits. Note
that special wrapper options will be treated as arguments if they
follow '--' at the end of the command line. Thus,
pandoc --dump-args -o foo.html foo.txt -- -e latin1
will print the following to STDOUT:
foo.html
foo.txt
-e
latin1
+ added --ignore-args option, which causes Pandoc to ignore all
(non-option) arguments, including any special options that occur
after '--' at the end of the command line.
+ '-' now means STDIN as the name of an input file, STDOUT as the
name of an output file. So,
pandoc -o - -
will take input from STDIN and print output to STDOUT. Note that
if multiple '-o' options are specified on the same line, the last
one takes precedence. So, in a script,
pandoc "$@" -o -
will guarantee output to STDOUT, even if the '-o' option was used.
+ documented these changes in man pages, README, and changelog.
git-svn-id: https://pandoc.googlecode.com/svn/trunk@454 788f1e2b-df1e-0410-8736-df70ead52e1b
2007-01-08 09:11:08 +01:00
|
|
|
(\opt -> return opt { optDumpArgs = True }))
|
|
|
|
"" -- "Print output filename and arguments to stdout."
|
|
|
|
|
2008-08-04 05:15:34 +02:00
|
|
|
, Option "" ["ignore-args"]
|
Changes to Pandoc's options to facilitate wrapper scripts:
+ removed -d/--debug option
+ added --dump-args option, which prints the name of the output file
(or '-' for STDOUT) and all the command-line arguments (excluding
Pandoc options and their arguments), one per line, then exits. Note
that special wrapper options will be treated as arguments if they
follow '--' at the end of the command line. Thus,
pandoc --dump-args -o foo.html foo.txt -- -e latin1
will print the following to STDOUT:
foo.html
foo.txt
-e
latin1
+ added --ignore-args option, which causes Pandoc to ignore all
(non-option) arguments, including any special options that occur
after '--' at the end of the command line.
+ '-' now means STDIN as the name of an input file, STDOUT as the
name of an output file. So,
pandoc -o - -
will take input from STDIN and print output to STDOUT. Note that
if multiple '-o' options are specified on the same line, the last
one takes precedence. So, in a script,
pandoc "$@" -o -
will guarantee output to STDOUT, even if the '-o' option was used.
+ documented these changes in man pages, README, and changelog.
git-svn-id: https://pandoc.googlecode.com/svn/trunk@454 788f1e2b-df1e-0410-8736-df70ead52e1b
2007-01-08 09:11:08 +01:00
|
|
|
(NoArg
|
|
|
|
(\opt -> return opt { optIgnoreArgs = True }))
|
|
|
|
"" -- "Ignore command-line arguments."
|
2008-08-10 19:33:20 +02:00
|
|
|
|
2006-12-22 21:16:03 +01:00
|
|
|
, Option "v" ["version"]
|
|
|
|
(NoArg
|
|
|
|
(\_ -> do
|
|
|
|
prg <- getProgName
|
2009-02-26 17:47:36 +01:00
|
|
|
hPutStrLn stdout (prg ++ " " ++ pandocVersion ++ compileInfo ++
|
2006-12-22 21:16:03 +01:00
|
|
|
copyrightMessage)
|
2009-02-26 17:47:36 +01:00
|
|
|
exitWith ExitSuccess ))
|
2006-12-31 02:12:01 +01:00
|
|
|
"" -- "Print version"
|
2006-12-22 21:16:03 +01:00
|
|
|
|
|
|
|
, Option "h" ["help"]
|
|
|
|
(NoArg
|
2006-12-28 03:20:09 +01:00
|
|
|
(\_ -> do
|
|
|
|
prg <- getProgName
|
2009-02-26 17:47:36 +01:00
|
|
|
hPutStr stdout (usageMessage prg options)
|
|
|
|
exitWith ExitSuccess ))
|
2006-12-31 02:12:01 +01:00
|
|
|
"" -- "Show help"
|
2006-10-17 16:22:29 +02:00
|
|
|
]
|
2006-12-22 21:16:03 +01:00
|
|
|
|
2006-12-31 02:12:01 +01:00
|
|
|
-- Returns usage message
|
|
|
|
usageMessage :: String -> [OptDescr (Opt -> IO Opt)] -> String
|
2009-01-24 20:59:07 +01:00
|
|
|
usageMessage programName = usageInfo
|
2008-08-10 19:33:20 +02:00
|
|
|
(programName ++ " [OPTIONS] [FILES]" ++ "\nInput formats: " ++
|
2008-09-08 08:36:28 +02:00
|
|
|
(intercalate ", " $ map fst readers) ++ "\nOutput formats: " ++
|
|
|
|
(intercalate ", " $ map fst writers) ++ "\nOptions:")
|
2008-08-10 19:33:20 +02:00
|
|
|
|
2006-12-28 03:20:09 +01:00
|
|
|
-- Determine default reader based on source file extensions
|
2008-02-09 04:21:04 +01:00
|
|
|
defaultReaderName :: [FilePath] -> String
|
2006-12-28 03:20:09 +01:00
|
|
|
defaultReaderName [] = "markdown"
|
2008-08-10 19:33:20 +02:00
|
|
|
defaultReaderName (x:xs) =
|
2008-02-09 04:21:04 +01:00
|
|
|
case takeExtension (map toLower x) of
|
|
|
|
".xhtml" -> "html"
|
|
|
|
".html" -> "html"
|
|
|
|
".htm" -> "html"
|
|
|
|
".tex" -> "latex"
|
|
|
|
".latex" -> "latex"
|
|
|
|
".ltx" -> "latex"
|
|
|
|
".rst" -> "rst"
|
2008-12-02 23:43:17 +01:00
|
|
|
".lhs" -> "markdown+lhs"
|
2008-02-09 04:21:04 +01:00
|
|
|
".native" -> "native"
|
|
|
|
_ -> defaultReaderName xs
|
2006-12-28 03:20:09 +01:00
|
|
|
|
2008-12-02 23:41:51 +01:00
|
|
|
-- Returns True if extension of first source is .lhs
|
|
|
|
lhsExtension :: [FilePath] -> Bool
|
|
|
|
lhsExtension (x:_) = takeExtension x == ".lhs"
|
|
|
|
lhsExtension _ = False
|
|
|
|
|
2006-12-28 03:20:09 +01:00
|
|
|
-- Determine default writer based on output file extension
|
2008-02-09 04:21:04 +01:00
|
|
|
defaultWriterName :: FilePath -> String
|
Changes to Pandoc's options to facilitate wrapper scripts:
+ removed -d/--debug option
+ added --dump-args option, which prints the name of the output file
(or '-' for STDOUT) and all the command-line arguments (excluding
Pandoc options and their arguments), one per line, then exits. Note
that special wrapper options will be treated as arguments if they
follow '--' at the end of the command line. Thus,
pandoc --dump-args -o foo.html foo.txt -- -e latin1
will print the following to STDOUT:
foo.html
foo.txt
-e
latin1
+ added --ignore-args option, which causes Pandoc to ignore all
(non-option) arguments, including any special options that occur
after '--' at the end of the command line.
+ '-' now means STDIN as the name of an input file, STDOUT as the
name of an output file. So,
pandoc -o - -
will take input from STDIN and print output to STDOUT. Note that
if multiple '-o' options are specified on the same line, the last
one takes precedence. So, in a script,
pandoc "$@" -o -
will guarantee output to STDOUT, even if the '-o' option was used.
+ documented these changes in man pages, README, and changelog.
git-svn-id: https://pandoc.googlecode.com/svn/trunk@454 788f1e2b-df1e-0410-8736-df70ead52e1b
2007-01-08 09:11:08 +01:00
|
|
|
defaultWriterName "-" = "html" -- no output file
|
2006-12-28 03:20:09 +01:00
|
|
|
defaultWriterName x =
|
2008-02-09 04:21:04 +01:00
|
|
|
case takeExtension (map toLower x) of
|
2008-02-24 06:48:59 +01:00
|
|
|
"" -> "markdown" -- empty extension
|
|
|
|
".tex" -> "latex"
|
|
|
|
".latex" -> "latex"
|
|
|
|
".ltx" -> "latex"
|
|
|
|
".context" -> "context"
|
|
|
|
".ctx" -> "context"
|
|
|
|
".rtf" -> "rtf"
|
|
|
|
".rst" -> "rst"
|
|
|
|
".s5" -> "s5"
|
|
|
|
".native" -> "native"
|
|
|
|
".txt" -> "markdown"
|
|
|
|
".text" -> "markdown"
|
|
|
|
".md" -> "markdown"
|
|
|
|
".markdown" -> "markdown"
|
2008-12-02 23:43:17 +01:00
|
|
|
".lhs" -> "markdown+lhs"
|
2008-02-24 06:48:59 +01:00
|
|
|
".texi" -> "texinfo"
|
|
|
|
".texinfo" -> "texinfo"
|
|
|
|
".db" -> "docbook"
|
2008-08-01 01:16:02 +02:00
|
|
|
".odt" -> "odt"
|
2008-06-17 20:55:42 +02:00
|
|
|
['.',y] | y `elem` ['1'..'9'] -> "man"
|
2008-02-09 04:21:04 +01:00
|
|
|
_ -> "html"
|
2006-12-22 21:16:03 +01:00
|
|
|
|
2008-06-17 20:55:42 +02:00
|
|
|
main :: IO ()
|
2006-12-28 03:20:09 +01:00
|
|
|
main = do
|
2006-12-22 21:16:03 +01:00
|
|
|
|
Changes to Pandoc's options to facilitate wrapper scripts:
+ removed -d/--debug option
+ added --dump-args option, which prints the name of the output file
(or '-' for STDOUT) and all the command-line arguments (excluding
Pandoc options and their arguments), one per line, then exits. Note
that special wrapper options will be treated as arguments if they
follow '--' at the end of the command line. Thus,
pandoc --dump-args -o foo.html foo.txt -- -e latin1
will print the following to STDOUT:
foo.html
foo.txt
-e
latin1
+ added --ignore-args option, which causes Pandoc to ignore all
(non-option) arguments, including any special options that occur
after '--' at the end of the command line.
+ '-' now means STDIN as the name of an input file, STDOUT as the
name of an output file. So,
pandoc -o - -
will take input from STDIN and print output to STDOUT. Note that
if multiple '-o' options are specified on the same line, the last
one takes precedence. So, in a script,
pandoc "$@" -o -
will guarantee output to STDOUT, even if the '-o' option was used.
+ documented these changes in man pages, README, and changelog.
git-svn-id: https://pandoc.googlecode.com/svn/trunk@454 788f1e2b-df1e-0410-8736-df70ead52e1b
2007-01-08 09:11:08 +01:00
|
|
|
rawArgs <- getArgs
|
2007-01-02 08:37:42 +01:00
|
|
|
prg <- getProgName
|
|
|
|
let compatMode = (prg == "hsmarkdown")
|
|
|
|
|
Changes to Pandoc's options to facilitate wrapper scripts:
+ removed -d/--debug option
+ added --dump-args option, which prints the name of the output file
(or '-' for STDOUT) and all the command-line arguments (excluding
Pandoc options and their arguments), one per line, then exits. Note
that special wrapper options will be treated as arguments if they
follow '--' at the end of the command line. Thus,
pandoc --dump-args -o foo.html foo.txt -- -e latin1
will print the following to STDOUT:
foo.html
foo.txt
-e
latin1
+ added --ignore-args option, which causes Pandoc to ignore all
(non-option) arguments, including any special options that occur
after '--' at the end of the command line.
+ '-' now means STDIN as the name of an input file, STDOUT as the
name of an output file. So,
pandoc -o - -
will take input from STDIN and print output to STDOUT. Note that
if multiple '-o' options are specified on the same line, the last
one takes precedence. So, in a script,
pandoc "$@" -o -
will guarantee output to STDOUT, even if the '-o' option was used.
+ documented these changes in man pages, README, and changelog.
git-svn-id: https://pandoc.googlecode.com/svn/trunk@454 788f1e2b-df1e-0410-8736-df70ead52e1b
2007-01-08 09:11:08 +01:00
|
|
|
let (actions, args, errors) = if compatMode
|
|
|
|
then ([], rawArgs, [])
|
|
|
|
else getOpt Permute options rawArgs
|
2006-12-22 21:16:03 +01:00
|
|
|
|
2009-01-24 20:59:07 +01:00
|
|
|
unless (null errors) $
|
|
|
|
do name <- getProgName
|
|
|
|
mapM_ (\e -> hPutStrLn stderr e) errors
|
|
|
|
hPutStr stderr (usageMessage name options)
|
|
|
|
exitWith $ ExitFailure 2
|
2006-10-17 16:22:29 +02:00
|
|
|
|
2008-08-10 19:33:20 +02:00
|
|
|
let defaultOpts' = if compatMode
|
2007-01-02 08:37:42 +01:00
|
|
|
then defaultOpts { optReader = "markdown"
|
|
|
|
, optWriter = "html"
|
|
|
|
, optStrict = True }
|
|
|
|
else defaultOpts
|
|
|
|
|
2006-10-17 16:22:29 +02:00
|
|
|
-- thread option data structure through all supplied option actions
|
2007-01-02 08:37:42 +01:00
|
|
|
opts <- foldl (>>=) (return defaultOpts') actions
|
2006-10-17 16:22:29 +02:00
|
|
|
|
2009-04-08 22:19:50 +02:00
|
|
|
let Opt { optTabStop = tabStop
|
|
|
|
, optPreserveTabs = preserveTabs
|
2006-10-17 16:22:29 +02:00
|
|
|
, optStandalone = standalone
|
2006-12-28 03:20:09 +01:00
|
|
|
, optReader = readerName
|
|
|
|
, optWriter = writerName
|
2006-10-17 16:22:29 +02:00
|
|
|
, optParseRaw = parseRaw
|
2009-12-31 02:09:56 +01:00
|
|
|
, optVariables = variables
|
2009-12-31 02:12:59 +01:00
|
|
|
, optBefore = befores
|
|
|
|
, optAfter = afters
|
2007-07-07 07:43:23 +02:00
|
|
|
, optTableOfContents = toc
|
2009-12-31 02:10:04 +01:00
|
|
|
, optTemplate = template
|
2006-12-22 21:16:03 +01:00
|
|
|
, optOutputFile = outputFile
|
2006-10-17 16:22:29 +02:00
|
|
|
, optNumberSections = numberSections
|
|
|
|
, optIncremental = incremental
|
2009-12-31 02:18:06 +01:00
|
|
|
, optXeTeX = xetex
|
2006-12-18 23:02:39 +01:00
|
|
|
, optSmart = smart
|
2007-12-01 04:11:52 +01:00
|
|
|
, optHTMLMathMethod = mathMethod
|
Changes to Pandoc's options to facilitate wrapper scripts:
+ removed -d/--debug option
+ added --dump-args option, which prints the name of the output file
(or '-' for STDOUT) and all the command-line arguments (excluding
Pandoc options and their arguments), one per line, then exits. Note
that special wrapper options will be treated as arguments if they
follow '--' at the end of the command line. Thus,
pandoc --dump-args -o foo.html foo.txt -- -e latin1
will print the following to STDOUT:
foo.html
foo.txt
-e
latin1
+ added --ignore-args option, which causes Pandoc to ignore all
(non-option) arguments, including any special options that occur
after '--' at the end of the command line.
+ '-' now means STDIN as the name of an input file, STDOUT as the
name of an output file. So,
pandoc -o - -
will take input from STDIN and print output to STDOUT. Note that
if multiple '-o' options are specified on the same line, the last
one takes precedence. So, in a script,
pandoc "$@" -o -
will guarantee output to STDOUT, even if the '-o' option was used.
+ documented these changes in man pages, README, and changelog.
git-svn-id: https://pandoc.googlecode.com/svn/trunk@454 788f1e2b-df1e-0410-8736-df70ead52e1b
2007-01-08 09:11:08 +01:00
|
|
|
, optDumpArgs = dumpArgs
|
|
|
|
, optIgnoreArgs = ignoreArgs
|
2006-12-30 23:51:49 +01:00
|
|
|
, optStrict = strict
|
Extensive changes stemming from a rethinking of the Pandoc data
structure. Key and Note blocks have been removed. Link and image URLs
are now stored directly in Link and Image inlines, and note blocks
are stored in Note inlines. This requires changes in both parsers
and writers. Markdown and RST parsers need to extract data from key
and note blocks and insert them into the relevant inline elements.
Other parsers can be simplified, since there is no longer any need to
construct separate key and note blocks. Markdown, RST, and HTML writers
need to construct lists of notes; Markdown and RST writers need to
construct lists of link references (when the --reference-links option
is specified); and the RST writer needs to construct a list of image
substitution references. All writers have been rewritten to use the
State monad when state is required. This rewrite yields a small speed
boost and considerably cleaner code.
* Text/Pandoc/Definition.hs:
+ blocks: removed Key and Note
+ inlines: removed NoteRef, added Note
+ modified Target: there is no longer a 'Ref' target; all targets
are explicit URL, title pairs
* Text/Pandoc/Shared.hs:
+ Added 'Reference', 'isNoteBlock', 'isKeyBlock', 'isLineClump',
used in some of the readers.
+ Removed 'generateReference', 'keyTable', 'replaceReferenceLinks',
'replaceRefLinksBlockList', along with some auxiliary functions
used only by them. These are no longer needed, since
reference links are resolved in the Markdown and RST readers.
+ Moved 'inTags', 'selfClosingTag', 'inTagsSimple', and 'inTagsIndented'
to the Docbook writer, since that is now the only module that uses
them.
+ Changed name of 'escapeSGMLString' to 'escapeStringForXML'
+ Added KeyTable and NoteTable types
+ Removed fields from ParserState; 'stateKeyBlocks', 'stateKeysUsed',
'stateNoteBlocks', 'stateNoteIdentifiers', 'stateInlineLinks'.
Added 'stateKeys' and 'stateNotes'.
+ Added clause for Note to 'prettyBlock'.
+ Added 'writerNotes', 'writerReferenceLinks' fields to WriterOptions.
* Text/Pandoc/Entities.hs: Renamed 'escapeSGMLChar' and
'escapeSGMLString' to 'escapeCharForXML' and 'escapeStringForXML'
* Text/ParserCombinators/Pandoc.hs: Added lineClump parser: parses a raw
line block up to and including following blank lines.
* Main.hs: Replaced --inline-links with --reference-links.
* README:
+ Documented --reference-links and removed description of --inline-links.
+ Added note that footnotes may occur anywhere in the document, but must
be at the outer level, not embedded in block elements.
* man/man1/pandoc.1, man/man1/html2markdown.1: Removed --inline-links
option, added --reference-links option
* Markdown and RST readers:
+ Rewrote to fit new Pandoc definition. Since there are no longer
Note or Key blocks, all note and key blocks are parsed on a first pass
through the document. Once tables of notes and keys have been constructed,
the remaining parts of the document are reassembled and parsed.
+ Refactored link parsers.
* LaTeX and HTML readers: Rewrote to fit new Pandoc definition. Since
there are no longer Note or Key blocks, notes and references can be
parsed in a single pass through the document.
* RST, Markdown, and HTML writers: Rewrote using state monad new Pandoc
and definition. State is used to hold lists of references footnotes to
and be printed at the end of the document.
* RTF and LaTeX writers: Rewrote using new Pandoc definition. (Because
of the different treatment of footnotes, the "notes" parameter is no
longer needed in the block and inline conversion functions.)
* Docbook writer:
+ Moved the functions 'attributeList', 'inTags', 'selfClosingTag',
'inTagsSimple', 'inTagsIndented' from Text/Pandoc/Shared, since
they are now used only by the Docbook writer.
+ Rewrote using new Pandoc definition. (Because of the different
treatment of footnotes, the "notes" parameter is no longer needed
in the block and inline conversion functions.)
* Updated test suite
* Throughout: old haskell98 module names replaced by hierarchical module
names, e.g. List by Data.List.
* debian/control: Include libghc6-xhtml-dev instead of libghc6-html-dev
in "Build-Depends."
* cabalize:
+ Remove haskell98 from BASE_DEPENDS (since now the new hierarchical
module names are being used throughout)
+ Added mtl to BASE_DEPENDS (needed for state monad)
+ Removed html from GHC66_DEPENDS (not needed since xhtml is now used)
git-svn-id: https://pandoc.googlecode.com/svn/trunk@580 788f1e2b-df1e-0410-8736-df70ead52e1b
2007-04-10 03:56:50 +02:00
|
|
|
, optReferenceLinks = referenceLinks
|
2007-09-27 03:23:44 +02:00
|
|
|
, optWrapText = wrap
|
2008-01-03 22:32:32 +01:00
|
|
|
, optSanitizeHTML = sanitize
|
2009-01-24 20:58:48 +01:00
|
|
|
, optEmailObfuscation = obfuscationMethod
|
2009-12-05 18:56:02 +01:00
|
|
|
, optIdentifierPrefix = idPrefix
|
2009-12-05 05:46:57 +01:00
|
|
|
, optIndentedCodeClasses = codeBlockClasses
|
2008-08-04 05:15:34 +02:00
|
|
|
#ifdef _CITEPROC
|
2009-01-24 20:58:48 +01:00
|
|
|
, optBiblioFile = biblioFile
|
|
|
|
, optBiblioFormat = biblioFormat
|
|
|
|
, optCslFile = cslFile
|
2008-08-04 05:15:34 +02:00
|
|
|
#endif
|
2006-10-17 16:22:29 +02:00
|
|
|
} = opts
|
|
|
|
|
2009-01-24 20:59:07 +01:00
|
|
|
when dumpArgs $
|
|
|
|
do hPutStrLn stdout outputFile
|
|
|
|
mapM_ (\arg -> hPutStrLn stdout arg) args
|
|
|
|
exitWith ExitSuccess
|
2007-01-09 02:43:23 +01:00
|
|
|
|
Changes to Pandoc's options to facilitate wrapper scripts:
+ removed -d/--debug option
+ added --dump-args option, which prints the name of the output file
(or '-' for STDOUT) and all the command-line arguments (excluding
Pandoc options and their arguments), one per line, then exits. Note
that special wrapper options will be treated as arguments if they
follow '--' at the end of the command line. Thus,
pandoc --dump-args -o foo.html foo.txt -- -e latin1
will print the following to STDOUT:
foo.html
foo.txt
-e
latin1
+ added --ignore-args option, which causes Pandoc to ignore all
(non-option) arguments, including any special options that occur
after '--' at the end of the command line.
+ '-' now means STDIN as the name of an input file, STDOUT as the
name of an output file. So,
pandoc -o - -
will take input from STDIN and print output to STDOUT. Note that
if multiple '-o' options are specified on the same line, the last
one takes precedence. So, in a script,
pandoc "$@" -o -
will guarantee output to STDOUT, even if the '-o' option was used.
+ documented these changes in man pages, README, and changelog.
git-svn-id: https://pandoc.googlecode.com/svn/trunk@454 788f1e2b-df1e-0410-8736-df70ead52e1b
2007-01-08 09:11:08 +01:00
|
|
|
let sources = if ignoreArgs then [] else args
|
|
|
|
|
2006-12-28 03:20:09 +01:00
|
|
|
-- assign reader and writer based on options and filenames
|
2008-08-10 19:33:20 +02:00
|
|
|
let readerName' = if null readerName
|
2006-12-28 03:20:09 +01:00
|
|
|
then defaultReaderName sources
|
2008-12-02 23:43:17 +01:00
|
|
|
else readerName
|
2006-12-28 03:20:09 +01:00
|
|
|
|
2008-08-10 19:33:20 +02:00
|
|
|
let writerName' = if null writerName
|
2006-12-28 03:20:09 +01:00
|
|
|
then defaultWriterName outputFile
|
|
|
|
else writerName
|
|
|
|
|
|
|
|
reader <- case (lookup readerName' readers) of
|
|
|
|
Just r -> return r
|
|
|
|
Nothing -> error ("Unknown reader: " ++ readerName')
|
|
|
|
|
2009-12-31 02:10:57 +01:00
|
|
|
writer <- case (lookup writerName' writers) of
|
|
|
|
Just r -> return r
|
|
|
|
Nothing -> error ("Unknown writer: " ++ writerName')
|
|
|
|
|
|
|
|
templ <- getDefaultTemplate writerName'
|
|
|
|
let defaultTemplate = case templ of
|
|
|
|
Right t -> t
|
|
|
|
Left e -> error (show e)
|
2006-12-22 21:16:03 +01:00
|
|
|
|
2007-01-15 20:52:42 +01:00
|
|
|
environment <- getEnvironment
|
|
|
|
let columns = case lookup "COLUMNS" environment of
|
|
|
|
Just cols -> read cols
|
|
|
|
Nothing -> stateColumns defaultParserState
|
|
|
|
|
2009-05-01 06:18:07 +02:00
|
|
|
let standalone' = standalone || isNonTextOutput writerName'
|
2008-08-01 01:16:02 +02:00
|
|
|
|
2008-08-04 05:15:34 +02:00
|
|
|
#ifdef _CITEPROC
|
2008-12-29 23:45:18 +01:00
|
|
|
refs <- if null biblioFile then return [] else readBiblioFile biblioFile biblioFormat
|
2008-08-04 05:15:34 +02:00
|
|
|
#endif
|
|
|
|
|
2009-12-31 02:11:13 +01:00
|
|
|
variables' <- if writerName' == "s5" && standalone'
|
|
|
|
then do
|
|
|
|
inc <- s5HeaderIncludes
|
2009-12-31 02:15:50 +01:00
|
|
|
return $ ("header-includes", inc) : variables
|
2009-12-31 02:11:13 +01:00
|
|
|
else return variables
|
|
|
|
|
2009-12-31 02:13:16 +01:00
|
|
|
variables'' <- case mathMethod of
|
2009-12-31 02:13:26 +01:00
|
|
|
LaTeXMathML Nothing -> do
|
2009-12-31 02:13:16 +01:00
|
|
|
s <- latexMathMLScript
|
|
|
|
return $ ("latexmathml-script", s) : variables'
|
|
|
|
_ -> return variables'
|
|
|
|
|
2008-08-10 19:33:20 +02:00
|
|
|
let startParserState =
|
2008-12-02 23:41:51 +01:00
|
|
|
defaultParserState { stateParseRaw = parseRaw,
|
|
|
|
stateTabStop = tabStop,
|
|
|
|
stateSanitizeHTML = sanitize,
|
2008-12-02 23:43:17 +01:00
|
|
|
stateLiterateHaskell = "+lhs" `isSuffixOf` readerName' ||
|
2008-12-02 23:41:51 +01:00
|
|
|
lhsExtension sources,
|
|
|
|
stateStandalone = standalone',
|
2008-08-04 05:15:34 +02:00
|
|
|
#ifdef _CITEPROC
|
2008-12-02 23:41:51 +01:00
|
|
|
stateCitations = map citeKey refs,
|
2008-08-04 05:15:34 +02:00
|
|
|
#endif
|
2008-12-02 23:41:51 +01:00
|
|
|
stateSmart = smart || writerName' `elem`
|
2009-06-06 23:27:40 +02:00
|
|
|
["latex", "context", "man"],
|
2008-12-02 23:41:51 +01:00
|
|
|
stateColumns = columns,
|
2009-12-01 07:56:47 +01:00
|
|
|
stateStrict = strict,
|
2009-12-05 05:46:57 +01:00
|
|
|
stateIndentedCodeClasses = codeBlockClasses }
|
2009-01-24 20:58:48 +01:00
|
|
|
let writerOptions = WriterOptions { writerStandalone = standalone',
|
2009-12-31 02:10:17 +01:00
|
|
|
writerTemplate = if null template
|
2009-12-31 02:10:04 +01:00
|
|
|
then defaultTemplate
|
|
|
|
else template,
|
2009-12-31 02:13:16 +01:00
|
|
|
writerVariables = variables'',
|
2009-12-31 02:12:59 +01:00
|
|
|
writerIncludeBefore = concat befores,
|
|
|
|
writerIncludeAfter = concat afters,
|
2009-01-24 20:58:48 +01:00
|
|
|
writerTabStop = tabStop,
|
|
|
|
writerTableOfContents = toc &&
|
|
|
|
writerName' /= "s5",
|
|
|
|
writerHTMLMathMethod = mathMethod,
|
|
|
|
writerS5 = (writerName' == "s5"),
|
2009-12-31 02:18:06 +01:00
|
|
|
writerXeTeX = xetex,
|
2009-01-24 20:58:48 +01:00
|
|
|
writerIgnoreNotes = False,
|
|
|
|
writerIncremental = incremental,
|
|
|
|
writerNumberSections = numberSections,
|
|
|
|
writerStrictMarkdown = strict,
|
|
|
|
writerReferenceLinks = referenceLinks,
|
|
|
|
writerWrapText = wrap,
|
|
|
|
writerLiterateHaskell = "+lhs" `isSuffixOf` writerName' ||
|
|
|
|
lhsExtension [outputFile],
|
|
|
|
writerEmailObfuscation = if strict
|
|
|
|
then ReferenceObfuscation
|
2009-12-05 18:56:02 +01:00
|
|
|
else obfuscationMethod,
|
|
|
|
writerIdentifierPrefix = idPrefix }
|
2006-10-17 16:22:29 +02:00
|
|
|
|
2009-01-24 20:59:07 +01:00
|
|
|
when (isNonTextOutput writerName' && outputFile == "-") $
|
|
|
|
do hPutStrLn stderr ("Error: Cannot write " ++ writerName ++ " output to stdout.\n" ++
|
2008-08-10 19:33:20 +02:00
|
|
|
"Specify an output file using the -o option.")
|
2009-01-24 20:59:07 +01:00
|
|
|
exitWith $ ExitFailure 5
|
2008-08-10 19:33:20 +02:00
|
|
|
|
|
|
|
let sourceDirRelative = if null sources
|
|
|
|
then ""
|
|
|
|
else takeDirectory (head sources)
|
|
|
|
|
2009-01-24 20:58:06 +01:00
|
|
|
let readSources [] = mapM readSource ["-"]
|
|
|
|
readSources srcs = mapM readSource srcs
|
|
|
|
readSource "-" = getContents
|
|
|
|
readSource src = readFile src
|
|
|
|
|
2009-04-08 22:19:50 +02:00
|
|
|
let convertTabs = tabFilter (if preserveTabs then 0 else tabStop)
|
|
|
|
|
|
|
|
doc <- fmap (reader startParserState . convertTabs . intercalate "\n") (readSources sources)
|
2008-08-01 01:16:02 +02:00
|
|
|
|
2009-01-24 20:58:06 +01:00
|
|
|
doc' <- do
|
2008-08-04 05:15:34 +02:00
|
|
|
#ifdef _CITEPROC
|
2009-01-24 20:58:06 +01:00
|
|
|
processBiblio cslFile refs doc
|
|
|
|
#else
|
|
|
|
return doc
|
2008-08-04 05:15:34 +02:00
|
|
|
#endif
|
2006-10-17 16:22:29 +02:00
|
|
|
|
2009-02-24 23:59:44 +01:00
|
|
|
let writerOutput = writer writerOptions doc' ++ "\n"
|
2009-01-24 20:58:06 +01:00
|
|
|
|
|
|
|
case writerName' of
|
|
|
|
"odt" -> saveOpenDocumentAsODT outputFile sourceDirRelative writerOutput
|
|
|
|
_ -> if outputFile == "-"
|
|
|
|
then putStr writerOutput
|
|
|
|
else writeFile outputFile writerOutput
|