Skip to content

Commit

Permalink
Added defaultHighlightingCss to Format; removed from Highlight.hs.
Browse files Browse the repository at this point in the history
  • Loading branch information
jgm@berkeley.edu committed Feb 10, 2008
1 parent 17474ec commit d3ffa61
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 24 deletions.
23 changes: 1 addition & 22 deletions Highlight.hs
Expand Up @@ -57,27 +57,6 @@ xhtmlHighlight opts lang code =
Right result -> formatAsXHtml opts lang result
Left _ -> pre $ thecode << code

defaultCss =
"table.sourceCode, tr.sourceCode, td.lineNumbers, td.sourceCode, table.sourceCode pre \n\
\ { margin: 0; padding: 0; border: 0; vertical-align: baseline; border: none; }\n\
\td.lineNumbers { border-right: 1px solid #AAAAAA; text-align: right; color: #AAAAAA; padding-right: 5px; padding-left: 5px; }\n\
\td.sourceCode { padding-left: 5px; }\n\
\pre.sourceCode { }\n\
\pre.sourceCode span.Normal { }\n\
\pre.sourceCode span.Keyword { color: #007020; font-weight: bold; } \n\
\pre.sourceCode span.DataType { color: #902000; }\n\
\pre.sourceCode span.DecVal { color: #40a070; }\n\
\pre.sourceCode span.BaseN { color: #40a070; }\n\
\pre.sourceCode span.Float { color: #40a070; }\n\
\pre.sourceCode span.Char { color: #4070a0; }\n\
\pre.sourceCode span.String { color: #4070a0; }\n\
\pre.sourceCode span.Comment { color: #60a0b0; font-style: italic; }\n\
\pre.sourceCode span.Others { color: #007020; }\n\
\pre.sourceCode span.Alert { color: red; font-weight: bold; }\n\
\pre.sourceCode span.Function { color: #06287e; }\n\
\pre.sourceCode span.RegionMarker { }\n\
\pre.sourceCode span.Error { color: red; font-weight: bold; }"

main = do
(opts, fnames, errs) <- getArgs >>= return . getOpt Permute options
prg <- getProgName
Expand Down Expand Up @@ -117,7 +96,7 @@ main = do
let highlightOpts = (if TitleAttributes `elem` opts then [OptTitleAttributes] else []) ++
(if NumberLines `elem` opts then [OptNumberLines] else [])
let css = case cssPathOf opts of
Nothing -> style ! [thetype "text/css"] $ primHtml defaultCss
Nothing -> style ! [thetype "text/css"] $ primHtml defaultHighlightingCss
Just cssPath -> thelink ! [thetype "text/css", href cssPath, rel "stylesheet"] << noHtml
let hcode = xhtmlHighlight highlightOpts lang code
let pageTitle = if null fnames then noHtml else thetitle << (takeFileName $ head fnames)
Expand Down
3 changes: 2 additions & 1 deletion Text/Highlighting/Kate.hs
Expand Up @@ -26,11 +26,12 @@ module Text.Highlighting.Kate ( highlightAs
, languagesByExtension
, formatAsXHtml
, FormatOption (..)
, defaultHighlightingCss
, SourceLine
, LabeledSource
, highlightingKateVersion
) where
import Text.Highlighting.Kate.Format ( formatAsXHtml, FormatOption (..) )
import Text.Highlighting.Kate.Format ( formatAsXHtml, FormatOption (..), defaultHighlightingCss )
import Text.Highlighting.Kate.Syntax ( highlightAs, languages, languagesByExtension )
import Text.Highlighting.Kate.Definitions ( SourceLine, LabeledSource )

Expand Down
24 changes: 23 additions & 1 deletion Text/Highlighting/Kate/Format.hs
Expand Up @@ -10,7 +10,7 @@
Formatters that convert a list of annotated source lines to various output formats.
-}

module Text.Highlighting.Kate.Format ( formatAsXHtml, FormatOption (..) ) where
module Text.Highlighting.Kate.Format ( formatAsXHtml, FormatOption (..), defaultHighlightingCss ) where
import Text.Highlighting.Kate.Definitions
import Text.XHtml.Transitional

Expand Down Expand Up @@ -61,3 +61,25 @@ getStartNum :: [FormatOption] -> Int
getStartNum [] = 1
getStartNum (OptNumberFrom n : _) = n
getStartNum (_:xs) = getStartNum xs

defaultHighlightingCss :: String
defaultHighlightingCss =
"table.sourceCode, tr.sourceCode, td.lineNumbers, td.sourceCode, table.sourceCode pre \n\
\ { margin: 0; padding: 0; border: 0; vertical-align: baseline; border: none; }\n\
\td.lineNumbers { border-right: 1px solid #AAAAAA; text-align: right; color: #AAAAAA; padding-right: 5px; padding-left: 5px; }\n\
\td.sourceCode { padding-left: 5px; }\n\
\pre.sourceCode { }\n\
\pre.sourceCode span.Normal { }\n\
\pre.sourceCode span.Keyword { color: #007020; font-weight: bold; } \n\
\pre.sourceCode span.DataType { color: #902000; }\n\
\pre.sourceCode span.DecVal { color: #40a070; }\n\
\pre.sourceCode span.BaseN { color: #40a070; }\n\
\pre.sourceCode span.Float { color: #40a070; }\n\
\pre.sourceCode span.Char { color: #4070a0; }\n\
\pre.sourceCode span.String { color: #4070a0; }\n\
\pre.sourceCode span.Comment { color: #60a0b0; font-style: italic; }\n\
\pre.sourceCode span.Others { color: #007020; }\n\
\pre.sourceCode span.Alert { color: red; font-weight: bold; }\n\
\pre.sourceCode span.Function { color: #06287e; }\n\
\pre.sourceCode span.RegionMarker { }\n\
\pre.sourceCode span.Error { color: red; font-weight: bold; }"

0 comments on commit d3ffa61

Please sign in to comment.