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 is specified, *references* is used regardless of the presence
of this option. 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` `--dump-args`
: is intended to make it easier to create wrapper scripts that use : is intended to make it easier to create wrapper scripts that use
Pandoc. It causes Pandoc to dump information about the arguments 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 If `--strict` is specified, *references* is used regardless of the
presence of this option. 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 \--toc, \--table-of-contents
: Include an automatically generated table of contents (HTML, markdown, : Include an automatically generated table of contents (HTML, markdown,
RTF) or an instruction to create one (LaTeX, reStructuredText). RTF) or an instruction to create one (LaTeX, reStructuredText).

View file

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

View file

@ -671,7 +671,8 @@ data ParserState = ParserState
stateSmart :: Bool, -- ^ Use smart typography? stateSmart :: Bool, -- ^ Use smart typography?
stateLiterateHaskell :: Bool, -- ^ Treat input as literate haskell stateLiterateHaskell :: Bool, -- ^ Treat input as literate haskell
stateColumns :: Int, -- ^ Number of columns in terminal 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 deriving Show
@ -695,7 +696,8 @@ defaultParserState =
stateSmart = False, stateSmart = False,
stateLiterateHaskell = False, stateLiterateHaskell = False,
stateColumns = 80, stateColumns = 80,
stateHeaderTable = [] } stateHeaderTable = [],
stateDefaultCodeClasses = [] }
data HeaderType data HeaderType
= SingleHeader Char -- ^ Single line of characters underneath = SingleHeader Char -- ^ Single line of characters underneath

View file

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