git.iko.soy/typeable/pandoc
on master help sign in
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

commitdf0ce7658c28f45dd9afee804c76e3411b53c0ef authorfiddlosopher <fiddlosopher@788f1e2b-df1e-0410-8736-df70ead52e1b> dateTue 1 Dec 2009, 06:56 (17 years ago) parent65f05e0
5 files changed+28−4
README+5 man/man1/pandoc.1.md+5 src/Text/Pandoc/Readers/Markdown.hs+2−1 src/Text/Pandoc/Shared.hs+4−2 src/pandoc.hs+12−1
README+5
@@ -384,6 +384,11 @@ For further documentation, see the `pandoc(1)` man page.
384384 is specified, *references* is used regardless of the presence
385385 of this option.
386386
387+`--default-code-classes`*=classes*
388+: specifies classes to use for indented code blocks--for example,
389+ `perl,numberLines` or `haskell`. Multiple classes may be separated
390+ by spaces or commas.
391+
387392`--dump-args`
388393: is intended to make it easier to create wrapper scripts that use
389394 Pandoc. It causes Pandoc to dump information about the arguments
man/man1/pandoc.1.md+5
@@ -154,6 +154,11 @@ to Pandoc. Or use `html2markdown`(1), a wrapper around `pandoc`.
154154 If `--strict` is specified, *references* is used regardless of the
155155 presence of this option.
156156
157+\--default-code-classes*=classes*
158+: Specify classes to use for indented code blocks--for example,
159+ `perl,numberLines` or `haskell`. Multiple classes may be separated
160+ by spaces or commas.
161+
157162\--toc, \--table-of-contents
158163: Include an automatically generated table of contents (HTML, markdown,
159164 RTF) or an instruction to create one (LaTeX, reStructuredText).
src/Text/Pandoc/Readers/Markdown.hs+2−1
@@ -394,7 +394,8 @@ codeBlockIndented = do
394394 l <- indentedLine
395395 return $ b ++ l))
396396 optional blanklines
397− return $ CodeBlock ("",[],[]) $ stripTrailingNewlines $ concat contents
397+ st <- getState
398+ return $ CodeBlock ("", stateDefaultCodeClasses st, []) $ stripTrailingNewlines $ concat contents
398399
399400lhsCodeBlock :: GenParser Char ParserState Block
400401lhsCodeBlock = do
src/Text/Pandoc/Shared.hs+4−2
@@ -671,7 +671,8 @@ data ParserState = ParserState
671671 stateSmart :: Bool, -- ^ Use smart typography?
672672 stateLiterateHaskell :: Bool, -- ^ Treat input as literate haskell
673673 stateColumns :: Int, -- ^ Number of columns in terminal
674− stateHeaderTable :: [HeaderType] -- ^ Ordered list of header types used
674+ stateHeaderTable :: [HeaderType], -- ^ Ordered list of header types used
675+ stateDefaultCodeClasses :: [String] -- ^ Classes to use for indented code blocks
675676 }
676677 deriving Show
677678
@@ -695,7 +696,8 @@ defaultParserState =
695696 stateSmart = False,
696697 stateLiterateHaskell = False,
697698 stateColumns = 80,
698− stateHeaderTable = [] }
699+ stateHeaderTable = [],
700+ stateDefaultCodeClasses = [] }
699701
700702data HeaderType
701703 = SingleHeader Char -- ^ Single line of characters underneath
src/pandoc.hs+12−1
@@ -153,6 +153,7 @@ data Opt = Opt
153153 , optSanitizeHTML :: Bool -- ^ Sanitize HTML
154154 , optPlugins :: [Pandoc -> IO Pandoc] -- ^ Plugins to apply
155155 , optEmailObfuscation :: ObfuscationMethod
156+ , optDefaultCodeClasses :: [String] -- ^ Default classes for indented code blocks
156157#ifdef _CITEPROC
157158 , optBiblioFile :: String
158159 , optBiblioFormat :: String
@@ -189,6 +190,7 @@ defaultOpts = Opt
189190 , optSanitizeHTML = False
190191 , optPlugins = []
191192 , optEmailObfuscation = JavascriptObfuscation
193+ , optDefaultCodeClasses = []
192194#ifdef _CITEPROC
193195 , optBiblioFile = []
194196 , optBiblioFormat = []
@@ -312,6 +314,13 @@ options =
312314 "none|javascript|references")
313315 "" -- "Method for obfuscating email in HTML"
314316
317+ , Option "" ["default-code-classes"]
318+ (ReqArg
319+ (\arg opt -> return opt { optDefaultCodeClasses = words $
320+ map (\c -> if c == ',' then ' ' else c) arg })
321+ "STRING")
322+ "" -- "Classes (whitespace- or comma-separated) to use for indented code-blocks"
323+
315324 , Option "" ["toc", "table-of-contents"]
316325 (NoArg
317326 (\opt -> return opt { optTableOfContents = True }))
@@ -531,6 +540,7 @@ main = do
531540 , optWrapText = wrap
532541 , optSanitizeHTML = sanitize
533542 , optEmailObfuscation = obfuscationMethod
543+ , optDefaultCodeClasses = codeBlockClasses
534544#ifdef _CITEPROC
535545 , optBiblioFile = biblioFile
536546 , optBiblioFormat = biblioFormat
@@ -586,7 +596,8 @@ main = do
586596 stateSmart = smart || writerName' `elem`
587597 ["latex", "context", "man"],
588598 stateColumns = columns,
589− stateStrict = strict }
599+ stateStrict = strict,
600+ stateDefaultCodeClasses = codeBlockClasses }
590601 let csslink = if null css
591602 then ""
592603 else concatMap