Allow a theme file as argument to --highlight-style
.
Also include a sample, `default.theme`, in `data/`.
This commit is contained in:
parent
1c84a03509
commit
420e3eb26e
3 changed files with 17 additions and 3 deletions
|
@ -630,7 +630,7 @@ General writer options
|
|||
: Disables syntax highlighting for code blocks and inlines, even when
|
||||
a language attribute is given.
|
||||
|
||||
`--highlight-style=`*STYLE*
|
||||
`--highlight-style=`*STYLE*|*FILE*
|
||||
|
||||
: Specifies the coloring style to be used in highlighted source code.
|
||||
Options are `pygments` (the default), `kate`, `monochrome`,
|
||||
|
@ -639,6 +639,12 @@ General writer options
|
|||
[Syntax highlighting], below. See also
|
||||
`--list-highlight-styles`.
|
||||
|
||||
Instead of a *STYLE* name, a JSON file with extension
|
||||
`.theme` may be supplied. This will be parsed as a KDE
|
||||
syntax highlighting theme and (if valid) used as the
|
||||
highlighting style. To see a sample theme that can be
|
||||
modified, `pandoc --print-default-data-file default.theme`.
|
||||
|
||||
`--syntax-definition=`*FILE*
|
||||
|
||||
: Instructs pandoc to load a KDE XML syntax definition file,
|
||||
|
|
|
@ -109,6 +109,8 @@ Data-Files:
|
|||
data/sample.lua
|
||||
-- pandoc lua module
|
||||
data/pandoc.lua
|
||||
-- sample highlighting theme
|
||||
data/default.theme
|
||||
-- bash completion template
|
||||
data/bash_completion.tpl
|
||||
-- jats csl
|
||||
|
|
|
@ -56,7 +56,7 @@ import Data.Yaml (decode)
|
|||
import qualified Data.Yaml as Yaml
|
||||
import Network.URI (URI (..), isURI, parseURI)
|
||||
import Paths_pandoc (getDataDir)
|
||||
import Skylighting (Style, Syntax (..), defaultSyntaxMap)
|
||||
import Skylighting (Style, Syntax (..), defaultSyntaxMap, parseTheme)
|
||||
import Skylighting.Parser (missingIncludes, parseSyntaxDefinition,
|
||||
addSyntaxDefinition)
|
||||
import System.Console.GetOpt
|
||||
|
@ -802,7 +802,13 @@ writerFn f = liftIO . UTF8.writeFile f
|
|||
|
||||
lookupHighlightStyle :: Maybe String -> IO (Maybe Style)
|
||||
lookupHighlightStyle Nothing = return Nothing
|
||||
lookupHighlightStyle (Just s) =
|
||||
lookupHighlightStyle (Just s)
|
||||
| takeExtension s == ".theme" = -- attempt to load KDE theme
|
||||
do contents <- B.readFile s
|
||||
case parseTheme contents of
|
||||
Left _ -> err 69 $ "Could not read highlighting theme " ++ s
|
||||
Right sty -> return (Just sty)
|
||||
| otherwise =
|
||||
case lookup (map toLower s) highlightingStyles of
|
||||
Just sty -> return (Just sty)
|
||||
Nothing -> err 68 $ "Unknown highlight-style " ++ s
|
||||
|
|
Loading…
Add table
Reference in a new issue