aboutsummaryrefslogtreecommitdiff
path: root/src/Text
diff options
context:
space:
mode:
authorJohn MacFarlane <jgm@berkeley.edu>2017-04-01 22:27:00 +0200
committerJohn MacFarlane <jgm@berkeley.edu>2017-04-01 22:27:00 +0200
commit420e3eb26e6ac8b9854d41ede1bbd78e1c23fa66 (patch)
treecf47d6f1c7dafc6046d2625ce982dce945532f4a /src/Text
parent1c84a035098ab868db718b56f3f135603144d65a (diff)
downloadpandoc-420e3eb26e6ac8b9854d41ede1bbd78e1c23fa66.tar.gz
Allow a theme file as argument to `--highlight-style`.
Also include a sample, `default.theme`, in `data/`.
Diffstat (limited to 'src/Text')
-rw-r--r--src/Text/Pandoc/App.hs10
1 files changed, 8 insertions, 2 deletions
diff --git a/src/Text/Pandoc/App.hs b/src/Text/Pandoc/App.hs
index dfc8e3559..8f0410f12 100644
--- a/src/Text/Pandoc/App.hs
+++ b/src/Text/Pandoc/App.hs
@@ -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