Added --default-code-classes option.

This specifies classes to use for indented code blocks.
Thanks to buttock for the (slightly modified) patch.
Resolves Issue #87.

git-svn-id: https://pandoc.googlecode.com/svn/trunk@1637 788f1e2b-df1e-0410-8736-df70ead52e1b
This commit is contained in:
fiddlosopher 2009-12-01 06:56:47 +00:00
parent 65f05e036a
commit df0ce7658c
5 changed files with 28 additions and 4 deletions

5
README
View file

@ -384,6 +384,11 @@ For further documentation, see the `pandoc(1)` man page.
is specified, *references* is used regardless of the presence
of this option.
`--default-code-classes`*=classes*
: specifies classes to use for indented code blocks--for example,
`perl,numberLines` or `haskell`. Multiple classes may be separated
by spaces or commas.
`--dump-args`
: is intended to make it easier to create wrapper scripts that use
Pandoc. It causes Pandoc to dump information about the arguments

View file

@ -154,6 +154,11 @@ to Pandoc. Or use `html2markdown`(1), a wrapper around `pandoc`.
If `--strict` is specified, *references* is used regardless of the
presence of this option.
\--default-code-classes*=classes*
: Specify classes to use for indented code blocks--for example,
`perl,numberLines` or `haskell`. Multiple classes may be separated
by spaces or commas.
\--toc, \--table-of-contents
: Include an automatically generated table of contents (HTML, markdown,
RTF) or an instruction to create one (LaTeX, reStructuredText).

View file

@ -394,7 +394,8 @@ codeBlockIndented = do
l <- indentedLine
return $ b ++ l))
optional blanklines
return $ CodeBlock ("",[],[]) $ stripTrailingNewlines $ concat contents
st <- getState
return $ CodeBlock ("", stateDefaultCodeClasses st, []) $ stripTrailingNewlines $ concat contents
lhsCodeBlock :: GenParser Char ParserState Block
lhsCodeBlock = do

View file

@ -671,7 +671,8 @@ data ParserState = ParserState
stateSmart :: Bool, -- ^ Use smart typography?
stateLiterateHaskell :: Bool, -- ^ Treat input as literate haskell
stateColumns :: Int, -- ^ Number of columns in terminal
stateHeaderTable :: [HeaderType] -- ^ Ordered list of header types used
stateHeaderTable :: [HeaderType], -- ^ Ordered list of header types used
stateDefaultCodeClasses :: [String] -- ^ Classes to use for indented code blocks
}
deriving Show
@ -695,7 +696,8 @@ defaultParserState =
stateSmart = False,
stateLiterateHaskell = False,
stateColumns = 80,
stateHeaderTable = [] }
stateHeaderTable = [],
stateDefaultCodeClasses = [] }
data HeaderType
= SingleHeader Char -- ^ Single line of characters underneath

View file

@ -153,6 +153,7 @@ data Opt = Opt
, optSanitizeHTML :: Bool -- ^ Sanitize HTML
, optPlugins :: [Pandoc -> IO Pandoc] -- ^ Plugins to apply
, optEmailObfuscation :: ObfuscationMethod
, optDefaultCodeClasses :: [String] -- ^ Default classes for indented code blocks
#ifdef _CITEPROC
, optBiblioFile :: String
, optBiblioFormat :: String
@ -189,6 +190,7 @@ defaultOpts = Opt
, optSanitizeHTML = False
, optPlugins = []
, optEmailObfuscation = JavascriptObfuscation
, optDefaultCodeClasses = []
#ifdef _CITEPROC
, optBiblioFile = []
, optBiblioFormat = []
@ -312,6 +314,13 @@ options =
"none|javascript|references")
"" -- "Method for obfuscating email in HTML"
, Option "" ["default-code-classes"]
(ReqArg
(\arg opt -> return opt { optDefaultCodeClasses = words $
map (\c -> if c == ',' then ' ' else c) arg })
"STRING")
"" -- "Classes (whitespace- or comma-separated) to use for indented code-blocks"
, Option "" ["toc", "table-of-contents"]
(NoArg
(\opt -> return opt { optTableOfContents = True }))
@ -531,6 +540,7 @@ main = do
, optWrapText = wrap
, optSanitizeHTML = sanitize
, optEmailObfuscation = obfuscationMethod
, optDefaultCodeClasses = codeBlockClasses
#ifdef _CITEPROC
, optBiblioFile = biblioFile
, optBiblioFormat = biblioFormat
@ -586,7 +596,8 @@ main = do
stateSmart = smart || writerName' `elem`
["latex", "context", "man"],
stateColumns = columns,
stateStrict = strict }
stateStrict = strict,
stateDefaultCodeClasses = codeBlockClasses }
let csslink = if null css
then ""
else concatMap