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
|
2006-12-20 07:50:14 +01:00
|
|
|
License : GNU GPL, version 2 or above
|
|
|
|
|
2007-07-08 00:51:55 +02:00
|
|
|
Maintainer : John MacFarlane <jgm@berkeley@edu>
|
2006-12-20 21:20:10 +01: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
|
2007-12-01 04:11:44 +01:00
|
|
|
import Text.Pandoc.Shared ( joinWithSep, HTMLMathMethod (..) )
|
2008-02-09 04:21:19 +01:00
|
|
|
import Text.Pandoc.Highlighting ( languages )
|
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 (..) )
|
2008-08-01 01:16:02 +02:00
|
|
|
import System.FilePath ( takeExtension, takeDirectory )
|
2006-10-17 16:22:29 +02:00
|
|
|
import System.Console.GetOpt
|
2008-08-01 01:16:31 +02:00
|
|
|
import Prelude hiding ( putStrLn, writeFile, readFile, getContents )
|
|
|
|
import System.IO ( stdout, stderr )
|
|
|
|
import System.IO.UTF8
|
2006-10-17 16:22:29 +02:00
|
|
|
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 )
|
2006-10-17 16:22:29 +02:00
|
|
|
import Control.Monad ( (>>=) )
|
|
|
|
|
2006-12-22 21:16:03 +01:00
|
|
|
copyrightMessage :: String
|
2008-08-01 01:55:27 +02:00
|
|
|
copyrightMessage = "\nCopyright (C) 2006-7 John MacFarlane\n" ++
|
|
|
|
"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-02-09 04:21:19 +01:00
|
|
|
compileOptions :: String
|
2008-02-09 04:22:01 +01:00
|
|
|
compileOptions =
|
|
|
|
if null languages
|
|
|
|
then "\nCompiled without syntax highlighting support."
|
|
|
|
else "\nCompiled with syntax highlighting support for the following languages:\n" ++
|
|
|
|
(unlines $ map unwords $ chunk 5 $
|
|
|
|
map (\s -> s ++ replicate (15 - length s) ' ') languages)
|
|
|
|
|
|
|
|
-- | Splits a list into groups of at most n.
|
|
|
|
chunk :: Int -> [a] -> [[a]]
|
|
|
|
chunk size lst =
|
|
|
|
let (next, rest) = splitAt size lst
|
|
|
|
in if null rest then [next] else next : chunk size rest
|
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)]
|
|
|
|
readers = [("native" , readPandoc)
|
|
|
|
,("markdown" , readMarkdown)
|
|
|
|
,("rst" , readRST)
|
|
|
|
,("html" , readHtml)
|
|
|
|
,("latex" , readLaTeX)
|
|
|
|
]
|
|
|
|
|
|
|
|
-- | Reader for native Pandoc format.
|
|
|
|
readPandoc :: ParserState -> String -> Pandoc
|
2008-06-17 20:55:42 +02:00
|
|
|
readPandoc _ input = read input
|
2006-10-17 16:22:29 +02:00
|
|
|
|
|
|
|
-- | Association list of formats and pairs of writers and default headers.
|
|
|
|
writers :: [ ( String, ( WriterOptions -> Pandoc -> String, String ) ) ]
|
2008-03-19 19:45:51 +01:00
|
|
|
writers = [("native" , (writeDoc, ""))
|
|
|
|
,("html" , (writeHtmlString, ""))
|
|
|
|
,("s5" , (writeS5String, defaultS5Header))
|
|
|
|
,("docbook" , (writeDocbook, defaultDocbookHeader))
|
|
|
|
,("opendocument" , (writeOpenDocument, defaultOpenDocumentHeader))
|
2008-08-01 01:16:02 +02:00
|
|
|
,("odt" , (writeOpenDocument, defaultOpenDocumentHeader))
|
2008-03-19 19:45:51 +01:00
|
|
|
,("latex" , (writeLaTeX, defaultLaTeXHeader))
|
|
|
|
,("context" , (writeConTeXt, defaultConTeXtHeader))
|
|
|
|
,("texinfo" , (writeTexinfo, ""))
|
|
|
|
,("man" , (writeMan, ""))
|
|
|
|
,("markdown" , (writeMarkdown, ""))
|
|
|
|
,("rst" , (writeRST, ""))
|
2008-07-27 05:25:51 +02:00
|
|
|
,("mediawiki" , (writeMediaWiki, ""))
|
2008-03-19 19:45:51 +01:00
|
|
|
,("rtf" , (writeRTF, defaultRTFHeader))
|
2006-10-17 16:22:29 +02:00
|
|
|
]
|
|
|
|
|
2008-08-01 01:16:02 +02:00
|
|
|
isNonTextOutput :: String -> Bool
|
|
|
|
isNonTextOutput "odt" = True
|
|
|
|
isNonTextOutput _ = False
|
|
|
|
|
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
|
2006-12-30 23:51:49 +01:00
|
|
|
{ optPreserveTabs :: Bool -- ^ Convert tabs to spaces
|
2006-12-20 07:50:14 +01:00
|
|
|
, optTabStop :: Int -- ^ Number of spaces per tab
|
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
|
2008-01-08 21:21:28 +01:00
|
|
|
, optCSS :: [String] -- ^ CSS file to link to
|
2007-07-07 07:43:23 +02:00
|
|
|
, optTableOfContents :: Bool -- ^ Include table of contents
|
2006-12-20 07:50:14 +01:00
|
|
|
, optIncludeInHeader :: String -- ^ File to include in header
|
|
|
|
, optIncludeBeforeBody :: String -- ^ File to include at top of body
|
|
|
|
, optIncludeAfterBody :: String -- ^ File to include at end of body
|
|
|
|
, optCustomHeader :: String -- ^ Custom header to use, or "DEFAULT"
|
|
|
|
, optTitlePrefix :: String -- ^ Optional prefix for HTML title
|
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
|
|
|
|
, 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
|
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
|
2006-10-17 16:22:29 +02:00
|
|
|
{ optPreserveTabs = False
|
|
|
|
, optTabStop = 4
|
|
|
|
, 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
|
2008-01-08 21:21:28 +01:00
|
|
|
, optCSS = []
|
2007-07-07 07:43:23 +02:00
|
|
|
, optTableOfContents = False
|
2006-10-17 16:22:29 +02:00
|
|
|
, optIncludeInHeader = ""
|
|
|
|
, optIncludeBeforeBody = ""
|
|
|
|
, optIncludeAfterBody = ""
|
|
|
|
, optCustomHeader = "DEFAULT"
|
|
|
|
, optTitlePrefix = ""
|
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
|
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
|
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")
|
2007-07-12 10:31:05 +02:00
|
|
|
"" -- ("(" ++ (joinWithSep ", " $ 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")
|
2007-07-12 10:31:05 +02:00
|
|
|
"" -- ("(" ++ (joinWithSep ", " $ map fst writers) ++ ")")
|
2006-10-17 16:22:29 +02:00
|
|
|
|
|
|
|
, Option "s" ["standalone"]
|
|
|
|
(NoArg
|
|
|
|
(\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
|
|
|
|
(\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
|
|
|
|
|
|
|
, Option "m" ["asciimathml"]
|
2007-07-26 04:19:20 +02:00
|
|
|
(OptArg
|
2007-12-01 04:11:52 +01:00
|
|
|
(\arg opt -> return opt { optHTMLMathMethod =
|
|
|
|
ASCIIMathML arg })
|
2007-07-26 04:19:20 +02:00
|
|
|
"URL")
|
2006-12-31 02:12:01 +01:00
|
|
|
"" -- "Use ASCIIMathML 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"
|
|
|
|
|
|
|
|
, 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
|
|
|
|
|
|
|
, 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"
|
|
|
|
|
2007-07-12 05:27:24 +02:00
|
|
|
, Option "" ["toc", "table-of-contents"]
|
|
|
|
(NoArg
|
|
|
|
(\opt -> return opt { optTableOfContents = True }))
|
|
|
|
"" -- "Include table of contents"
|
|
|
|
|
2006-10-17 16:22:29 +02:00
|
|
|
, Option "c" ["css"]
|
|
|
|
(ReqArg
|
2008-01-08 21:21:28 +01:00
|
|
|
(\arg opt -> do
|
|
|
|
let old = optCSS opt
|
|
|
|
return opt { optCSS = old ++ [arg],
|
|
|
|
optStandalone = True })
|
2006-10-17 16:22:29 +02:00
|
|
|
"CSS")
|
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
|
2008-01-01 21:43:48 +01:00
|
|
|
let old = optIncludeInHeader opt
|
2006-10-17 16:22:29 +02:00
|
|
|
text <- readFile arg
|
2008-08-01 01:16:31 +02:00
|
|
|
return opt { optIncludeInHeader = old ++ text,
|
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
|
2008-01-01 21:43:48 +01:00
|
|
|
let old = optIncludeBeforeBody opt
|
2006-10-17 16:22:29 +02:00
|
|
|
text <- readFile arg
|
2008-08-01 01:16:31 +02:00
|
|
|
return opt { optIncludeBeforeBody = old ++ 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
|
2008-01-01 21:43:48 +01:00
|
|
|
let old = optIncludeAfterBody opt
|
2006-10-17 16:22:29 +02:00
|
|
|
text <- readFile arg
|
2008-08-01 01:16:31 +02:00
|
|
|
return opt { optIncludeAfterBody = old ++ 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
|
|
|
|
text <- readFile arg
|
2008-08-01 01:16:31 +02:00
|
|
|
return opt { optCustomHeader = text,
|
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 use for custom header (implies -s)"
|
2006-10-17 16:22:29 +02:00
|
|
|
|
|
|
|
, Option "T" ["title-prefix"]
|
|
|
|
(ReqArg
|
2006-12-20 07:50:14 +01:00
|
|
|
(\arg opt -> return opt { optTitlePrefix = arg,
|
|
|
|
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"
|
2006-10-17 16:22:29 +02:00
|
|
|
|
|
|
|
, Option "D" ["print-default-header"]
|
|
|
|
(ReqArg
|
2008-06-17 20:55:42 +02:00
|
|
|
(\arg _ -> do
|
2006-10-17 16:22:29 +02:00
|
|
|
let header = case (lookup arg writers) of
|
2008-06-17 20:55:42 +02:00
|
|
|
Just (_, h) -> h
|
2006-12-20 07:50:14 +01:00
|
|
|
Nothing -> error ("Unknown reader: " ++ arg)
|
2006-12-22 21:16:03 +01:00
|
|
|
hPutStr stdout header
|
2006-10-17 16:22:29 +02:00
|
|
|
exitWith ExitSuccess)
|
|
|
|
"FORMAT")
|
2006-12-31 02:12:01 +01:00
|
|
|
"" -- "Print default header for FORMAT"
|
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
|
|
|
, 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."
|
|
|
|
|
|
|
|
, Option "" ["ignore-args"]
|
|
|
|
(NoArg
|
|
|
|
(\opt -> return opt { optIgnoreArgs = True }))
|
|
|
|
"" -- "Ignore command-line arguments."
|
2006-12-22 21:16:03 +01:00
|
|
|
|
|
|
|
, Option "v" ["version"]
|
|
|
|
(NoArg
|
|
|
|
(\_ -> do
|
|
|
|
prg <- getProgName
|
2008-02-09 04:21:19 +01:00
|
|
|
hPutStrLn stderr (prg ++ " " ++ pandocVersion ++ compileOptions ++
|
2006-12-22 21:16:03 +01:00
|
|
|
copyrightMessage)
|
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
|
|
|
exitWith $ ExitFailure 4))
|
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
|
2006-12-31 02:12:01 +01:00
|
|
|
hPutStr stderr (usageMessage prg options)
|
2006-12-28 03:20:09 +01:00
|
|
|
exitWith $ ExitFailure 2))
|
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
|
2008-06-17 20:55:42 +02:00
|
|
|
usageMessage programName opts = usageInfo
|
2006-12-31 02:12:01 +01:00
|
|
|
(programName ++ " [OPTIONS] [FILES]" ++ "\nInput formats: " ++
|
2007-07-12 10:31:05 +02:00
|
|
|
(joinWithSep ", " $ map fst readers) ++ "\nOutput formats: " ++
|
|
|
|
(joinWithSep ", " $ map fst writers) ++ "\nOptions:")
|
2008-06-17 20:55:42 +02:00
|
|
|
opts
|
2006-12-31 02:12:01 +01: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"
|
|
|
|
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"
|
|
|
|
".native" -> "native"
|
|
|
|
_ -> defaultReaderName xs
|
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"
|
|
|
|
".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
|
|
|
|
|
|
|
if (not (null errors))
|
|
|
|
then do
|
2006-12-28 03:20:09 +01:00
|
|
|
name <- getProgName
|
2006-12-22 21:16:03 +01:00
|
|
|
mapM (\e -> hPutStrLn stderr e) errors
|
2006-12-31 02:12:01 +01:00
|
|
|
hPutStr stderr (usageMessage name options)
|
2007-01-08 17:29:29 +01:00
|
|
|
exitWith $ ExitFailure 2
|
2006-12-22 21:16:03 +01:00
|
|
|
else
|
|
|
|
return ()
|
2006-10-17 16:22:29 +02:00
|
|
|
|
2007-01-02 08:37:42 +01:00
|
|
|
let defaultOpts' = if compatMode
|
|
|
|
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
|
|
|
|
|
|
|
let Opt { optPreserveTabs = preserveTabs
|
|
|
|
, optTabStop = tabStop
|
|
|
|
, optStandalone = standalone
|
2006-12-28 03:20:09 +01:00
|
|
|
, optReader = readerName
|
|
|
|
, optWriter = writerName
|
2006-10-17 16:22:29 +02:00
|
|
|
, optParseRaw = parseRaw
|
|
|
|
, optCSS = css
|
2007-07-07 07:43:23 +02:00
|
|
|
, optTableOfContents = toc
|
2006-10-17 16:22:29 +02:00
|
|
|
, optIncludeInHeader = includeHeader
|
|
|
|
, optIncludeBeforeBody = includeBefore
|
|
|
|
, optIncludeAfterBody = includeAfter
|
|
|
|
, optCustomHeader = customHeader
|
|
|
|
, optTitlePrefix = titlePrefix
|
2006-12-22 21:16:03 +01:00
|
|
|
, optOutputFile = outputFile
|
2006-10-17 16:22:29 +02:00
|
|
|
, optNumberSections = numberSections
|
|
|
|
, optIncremental = incremental
|
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
|
2006-10-17 16:22:29 +02:00
|
|
|
} = opts
|
|
|
|
|
2007-01-09 02:43:23 +01:00
|
|
|
if dumpArgs
|
|
|
|
then do
|
|
|
|
hPutStrLn stdout outputFile
|
|
|
|
mapM (\arg -> hPutStrLn stdout arg) args
|
|
|
|
exitWith $ ExitSuccess
|
|
|
|
else return ()
|
|
|
|
|
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
|
|
|
|
let readerName' = if null readerName
|
|
|
|
then defaultReaderName sources
|
|
|
|
else readerName
|
|
|
|
|
|
|
|
let writerName' = if null writerName
|
|
|
|
then defaultWriterName outputFile
|
|
|
|
else writerName
|
|
|
|
|
|
|
|
reader <- case (lookup readerName' readers) of
|
|
|
|
Just r -> return r
|
|
|
|
Nothing -> error ("Unknown reader: " ++ readerName')
|
|
|
|
|
|
|
|
(writer, defaultHeader) <- case (lookup writerName' writers) of
|
|
|
|
Just (w,h) -> return (w, h)
|
|
|
|
Nothing -> error ("Unknown writer: " ++ writerName')
|
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
|
|
|
|
|
2007-08-28 21:54:16 +02:00
|
|
|
let tabFilter _ [] = ""
|
|
|
|
tabFilter _ ('\n':xs) = '\n':(tabFilter tabStop xs)
|
|
|
|
-- remove DOS line endings
|
2007-09-18 08:48:36 +02:00
|
|
|
tabFilter _ ('\r':'\n':xs) = '\n':(tabFilter tabStop xs)
|
|
|
|
tabFilter _ ('\r':xs) = '\n':(tabFilter tabStop xs)
|
2007-08-28 21:54:16 +02:00
|
|
|
tabFilter spsToNextStop ('\t':xs) =
|
|
|
|
if preserveTabs
|
|
|
|
then '\t':(tabFilter tabStop xs)
|
|
|
|
else replicate spsToNextStop ' ' ++ tabFilter tabStop xs
|
|
|
|
tabFilter 1 (x:xs) =
|
|
|
|
x:(tabFilter tabStop xs)
|
|
|
|
tabFilter spsToNextStop (x:xs) =
|
|
|
|
x:(tabFilter (spsToNextStop - 1) xs)
|
2007-08-28 21:33:47 +02:00
|
|
|
|
2008-08-01 01:16:02 +02:00
|
|
|
let standalone' = (standalone && not strict) || writerName' == "odt"
|
|
|
|
|
2007-01-02 08:37:42 +01:00
|
|
|
let startParserState =
|
2008-01-03 22:32:32 +01:00
|
|
|
defaultParserState { stateParseRaw = parseRaw,
|
|
|
|
stateTabStop = tabStop,
|
|
|
|
stateSanitizeHTML = sanitize,
|
2008-08-01 01:16:02 +02:00
|
|
|
stateStandalone = standalone',
|
2008-01-03 22:32:32 +01:00
|
|
|
stateSmart = smart || writerName' `elem`
|
|
|
|
["latex", "context"],
|
|
|
|
stateColumns = columns,
|
|
|
|
stateStrict = strict }
|
2008-01-08 21:21:28 +01:00
|
|
|
let csslink = if null css
|
|
|
|
then ""
|
|
|
|
else concatMap
|
|
|
|
(\f -> "<link rel=\"stylesheet\" href=\"" ++
|
|
|
|
f ++ "\" type=\"text/css\" media=\"all\" />\n")
|
|
|
|
css
|
2006-12-20 07:50:14 +01:00
|
|
|
let header = (if (customHeader == "DEFAULT")
|
|
|
|
then defaultHeader
|
2007-07-26 04:19:20 +02:00
|
|
|
else customHeader) ++ csslink ++ includeHeader
|
2008-08-01 01:16:02 +02:00
|
|
|
let writerOptions = WriterOptions { writerStandalone = standalone',
|
2006-10-17 16:22:29 +02:00
|
|
|
writerHeader = header,
|
|
|
|
writerTitlePrefix = titlePrefix,
|
|
|
|
writerTabStop = tabStop,
|
2007-07-07 07:43:23 +02:00
|
|
|
writerTableOfContents = toc &&
|
2007-07-12 05:40:01 +02:00
|
|
|
(not strict) &&
|
2008-08-01 01:16:02 +02:00
|
|
|
writerName' /= "s5",
|
2007-12-01 04:11:44 +01:00
|
|
|
writerHTMLMathMethod = mathMethod,
|
2008-08-01 01:16:02 +02:00
|
|
|
writerS5 = (writerName' == "s5"),
|
2007-07-07 21:04:10 +02:00
|
|
|
writerIgnoreNotes = False,
|
2006-10-17 16:22:29 +02:00
|
|
|
writerIncremental = incremental,
|
|
|
|
writerNumberSections = numberSections,
|
|
|
|
writerIncludeBefore = includeBefore,
|
2006-12-30 23:51:49 +01:00
|
|
|
writerIncludeAfter = includeAfter,
|
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
|
|
|
writerStrictMarkdown = strict,
|
2007-09-27 03:23:44 +02:00
|
|
|
writerReferenceLinks = referenceLinks,
|
|
|
|
writerWrapText = wrap }
|
2006-10-17 16:22:29 +02:00
|
|
|
|
2008-08-01 01:16:02 +02:00
|
|
|
let writeOutput = if writerName' == "odt"
|
|
|
|
then if outputFile == "-"
|
|
|
|
then \_ -> do
|
|
|
|
hPutStrLn stderr ("Error: Cannot write " ++ writerName ++
|
|
|
|
" output to stdout.\n" ++
|
|
|
|
"Specify an output file using the -o option.")
|
|
|
|
exitWith $ ExitFailure 5
|
|
|
|
else let sourceDirRelative = if null sources
|
|
|
|
then ""
|
|
|
|
else takeDirectory (head sources)
|
|
|
|
in saveOpenDocumentAsODT outputFile sourceDirRelative
|
|
|
|
else if outputFile == "-"
|
|
|
|
then putStrLn
|
|
|
|
else writeFile outputFile . (++ "\n")
|
|
|
|
|
2008-08-01 01:16:31 +02:00
|
|
|
(readSources sources) >>= writeOutput .
|
|
|
|
writer writerOptions .
|
|
|
|
reader startParserState .
|
|
|
|
tabFilter tabStop .
|
|
|
|
joinWithSep "\n"
|
2006-10-17 16:22:29 +02:00
|
|
|
|
|
|
|
where
|
|
|
|
readSources [] = mapM readSource ["-"]
|
|
|
|
readSources sources = mapM readSource sources
|
2006-12-22 21:16:03 +01:00
|
|
|
readSource "-" = getContents
|
2006-10-17 16:22:29 +02:00
|
|
|
readSource source = readFile source
|