diff options
author | fiddlosopher <fiddlosopher@788f1e2b-df1e-0410-8736-df70ead52e1b> | 2008-02-09 03:21:19 +0000 |
---|---|---|
committer | fiddlosopher <fiddlosopher@788f1e2b-df1e-0410-8736-df70ead52e1b> | 2008-02-09 03:21:19 +0000 |
commit | 04b32451be96cc64e3c8ee37a4b099ffe6236146 (patch) | |
tree | 197c78f2332f728ea63238aa972ab01e7d1ab4ed /Text/Pandoc/Writers | |
parent | 427c2e484ded241d073e80b3a90be0005509a085 (diff) | |
download | pandoc-04b32451be96cc64e3c8ee37a4b099ffe6236146.tar.gz |
Added build option for syntax highlighting, with *optional* dependency on highlighting-kate.
+ pandoc.cabal includes a flag, 'highlighting', that causes a dependency
on highlighting-kate.
+ if Setup.hs detects this dependency, it copies templates/Highlighting.yes.hs
to Text/Pandoc/Highlighting.hs. Otherwise, it copies templates/Highlighting.no.hs.
+ The HTML writer imports this new module instead of Text.Highlighting.Kate.
The new module exports highlightHtml, which either uses highlighting-kate to
perform syntax highlighting or automatically returns a failure code, depending
on whether highlighting support was selected.
+ --version now prints information about whether syntax highlighting support is compiled in.
git-svn-id: https://pandoc.googlecode.com/svn/trunk@1221 788f1e2b-df1e-0410-8736-df70ead52e1b
Diffstat (limited to 'Text/Pandoc/Writers')
-rw-r--r-- | Text/Pandoc/Writers/HTML.hs | 20 |
1 files changed, 7 insertions, 13 deletions
diff --git a/Text/Pandoc/Writers/HTML.hs b/Text/Pandoc/Writers/HTML.hs index 7837493a1..e668e9885 100644 --- a/Text/Pandoc/Writers/HTML.hs +++ b/Text/Pandoc/Writers/HTML.hs @@ -33,13 +33,13 @@ import Text.Pandoc.ASCIIMathML import Text.Pandoc.CharacterReferences ( decodeCharacterReferences ) import Text.Pandoc.Shared import Text.Pandoc.Readers.TeXMath +import Text.Pandoc.Highlighting ( highlightHtml ) import Numeric ( showHex ) import Data.Char ( ord, toLower, isAlpha ) import Data.List ( isPrefixOf, intersperse, find ) import qualified Data.Set as S import Control.Monad.State import Text.XHtml.Transitional -import Text.Highlighting.Kate data WriterState = WriterState { stNotes :: [Html] -- ^ List of notes @@ -293,18 +293,12 @@ blockToHtml opts (Para lst) = inlineListToHtml opts lst >>= (return . paragraph) blockToHtml opts (RawHtml str) = return $ primHtml str blockToHtml opts (HorizontalRule) = return $ hr blockToHtml opts (CodeBlock (_,classes,_) rawCode) = do - let fmtOpts = - case find (`elem` ["number","numberLines","number-lines"]) classes of - Nothing -> [] - Just _ -> [OptNumberLines] - let toPre str = pre ! (if null classes then [] else [theclass $ unwords classes]) $ thecode << str - let lcLanguages = map (map toLower) languages - case find (\c -> (map toLower c) `elem` lcLanguages) classes of - Nothing -> return $ toPre (rawCode ++ "\n") - Just lang -> case highlightAs lang rawCode of - Left _ -> return $ toPre (rawCode ++ "\n") - Right hl -> do addToCSS highlightingCSS - return $ formatAsXHtml fmtOpts lang hl + case highlightHtml classes rawCode of + Left _ -> return $ pre ! (if null classes + then [] + else [theclass $ unwords classes]) $ thecode << + (rawCode ++ "\n") + Right h -> addToCSS highlightingCSS >> return h blockToHtml opts (BlockQuote blocks) = -- in S5, treat list in blockquote specially -- if default is incremental, make it nonincremental; |