git.iko.soy/typeable/pandoc
on master help sign in
Added --default-code-classes option.
df0ce76fiddlosopher
@@ -384,6 +384,11 @@ For further documentation, see the `pandoc(1)` man page.
384 is specified, *references* is used regardless of the presence
384 is specified, *references* is used regardless of the presence
385 of this option.
385 of this option.
386
386
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+
387`--dump-args`
392`--dump-args`
388: is intended to make it easier to create wrapper scripts that use
393: is intended to make it easier to create wrapper scripts that use
389 Pandoc. It causes Pandoc to dump information about the arguments
394 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`.
154 If `--strict` is specified, *references* is used regardless of the
154 If `--strict` is specified, *references* is used regardless of the
155 presence of this option.
155 presence of this option.
156
156
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+
157\--toc, \--table-of-contents
162\--toc, \--table-of-contents
158: Include an automatically generated table of contents (HTML, markdown,
163: Include an automatically generated table of contents (HTML, markdown,
159 RTF) or an instruction to create one (LaTeX, reStructuredText).
164 RTF) or an instruction to create one (LaTeX, reStructuredText).
src/Text/Pandoc/Readers/Markdown.hs+2−1
@@ -394,7 +394,8 @@ codeBlockIndented = do
394 l <- indentedLine
394 l <- indentedLine
395 return $ b ++ l))
395 return $ b ++ l))
396 optional blanklines
396 optional blanklines
397+ st <- getState
397− return $ CodeBlock ("",[],[]) $ stripTrailingNewlines $ concat contents
398+ return $ CodeBlock ("", stateDefaultCodeClasses st, []) $ stripTrailingNewlines $ concat contents
398
399
399lhsCodeBlock :: GenParser Char ParserState Block
400lhsCodeBlock :: GenParser Char ParserState Block
400lhsCodeBlock = do
401lhsCodeBlock = do
src/Text/Pandoc/Shared.hs+4−2
@@ -671,7 +671,8 @@ data ParserState = ParserState
671 stateSmart :: Bool, -- ^ Use smart typography?
671 stateSmart :: Bool, -- ^ Use smart typography?
672 stateLiterateHaskell :: Bool, -- ^ Treat input as literate haskell
672 stateLiterateHaskell :: Bool, -- ^ Treat input as literate haskell
673 stateColumns :: Int, -- ^ Number of columns in terminal
673 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
675 }
676 }
676 deriving Show
677 deriving Show
677
678
@@ -695,7 +696,8 @@ defaultParserState =
695 stateSmart = False,
696 stateSmart = False,
696 stateLiterateHaskell = False,
697 stateLiterateHaskell = False,
697 stateColumns = 80,
698 stateColumns = 80,
698− stateHeaderTable = [] }
699+ stateHeaderTable = [],
700+ stateDefaultCodeClasses = [] }
699
701
700data HeaderType
702data HeaderType
701 = SingleHeader Char -- ^ Single line of characters underneath
703 = SingleHeader Char -- ^ Single line of characters underneath
src/pandoc.hs+12−1
@@ -153,6 +153,7 @@ data Opt = Opt
153 , optSanitizeHTML :: Bool -- ^ Sanitize HTML
153 , optSanitizeHTML :: Bool -- ^ Sanitize HTML
154 , optPlugins :: [Pandoc -> IO Pandoc] -- ^ Plugins to apply
154 , optPlugins :: [Pandoc -> IO Pandoc] -- ^ Plugins to apply
155 , optEmailObfuscation :: ObfuscationMethod
155 , optEmailObfuscation :: ObfuscationMethod
156+ , optDefaultCodeClasses :: [String] -- ^ Default classes for indented code blocks
156#ifdef _CITEPROC
157#ifdef _CITEPROC
157 , optBiblioFile :: String
158 , optBiblioFile :: String
158 , optBiblioFormat :: String
159 , optBiblioFormat :: String
@@ -189,6 +190,7 @@ defaultOpts = Opt
189 , optSanitizeHTML = False
190 , optSanitizeHTML = False
190 , optPlugins = []
191 , optPlugins = []
191 , optEmailObfuscation = JavascriptObfuscation
192 , optEmailObfuscation = JavascriptObfuscation
193+ , optDefaultCodeClasses = []
192#ifdef _CITEPROC
194#ifdef _CITEPROC
193 , optBiblioFile = []
195 , optBiblioFile = []
194 , optBiblioFormat = []
196 , optBiblioFormat = []
@@ -312,6 +314,13 @@ options =
312 "none|javascript|references")
314 "none|javascript|references")
313 "" -- "Method for obfuscating email in HTML"
315 "" -- "Method for obfuscating email in HTML"
314
316
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+
315 , Option "" ["toc", "table-of-contents"]
324 , Option "" ["toc", "table-of-contents"]
316 (NoArg
325 (NoArg
317 (\opt -> return opt { optTableOfContents = True }))
326 (\opt -> return opt { optTableOfContents = True }))
@@ -531,6 +540,7 @@ main = do
531 , optWrapText = wrap
540 , optWrapText = wrap
532 , optSanitizeHTML = sanitize
541 , optSanitizeHTML = sanitize
533 , optEmailObfuscation = obfuscationMethod
542 , optEmailObfuscation = obfuscationMethod
543+ , optDefaultCodeClasses = codeBlockClasses
534#ifdef _CITEPROC
544#ifdef _CITEPROC
535 , optBiblioFile = biblioFile
545 , optBiblioFile = biblioFile
536 , optBiblioFormat = biblioFormat
546 , optBiblioFormat = biblioFormat
@@ -586,7 +596,8 @@ main = do
586 stateSmart = smart || writerName' `elem`
596 stateSmart = smart || writerName' `elem`
587 ["latex", "context", "man"],
597 ["latex", "context", "man"],
588 stateColumns = columns,
598 stateColumns = columns,
589− stateStrict = strict }
599+ stateStrict = strict,
600+ stateDefaultCodeClasses = codeBlockClasses }
590 let csslink = if null css
601 let csslink = if null css
591 then ""
602 then ""
592 else concatMap
603 else concatMap