Support for startFrom="nn" to select starting line number in syntax highlighting.
Changed argument of highlightHtml to Attr, not [String], for generality. git-svn-id: https://pandoc.googlecode.com/svn/trunk@1232 788f1e2b-df1e-0410-8736-df70ead52e1b
This commit is contained in:
parent
250a3e4dda
commit
742a465980
3 changed files with 13 additions and 9 deletions
|
@ -292,8 +292,8 @@ blockToHtml opts (Plain lst) = inlineListToHtml opts lst
|
|||
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
|
||||
case highlightHtml classes rawCode of
|
||||
blockToHtml opts (CodeBlock attr@(_,classes,_) rawCode) = do
|
||||
case highlightHtml attr rawCode of
|
||||
Left _ -> return $ pre ! (if null classes
|
||||
then []
|
||||
else [theclass $ unwords classes]) $ thecode <<
|
||||
|
|
|
@ -30,10 +30,10 @@ Exports functions for syntax highlighting.
|
|||
|
||||
module Text.Pandoc.Highlighting ( languages, highlightHtml ) where
|
||||
import Text.XHtml
|
||||
import Text.Pandoc.Definition
|
||||
|
||||
languages :: [String]
|
||||
languages = []
|
||||
|
||||
highlightHtml :: [String] -> String -> Either String Html
|
||||
highlightHtml classes str = Left "Pandoc was not compiled with support for highlighting"
|
||||
|
||||
highlightHtml :: Attr -> String -> Either String Html
|
||||
highlightHtml _ _ = Left "Pandoc was not compiled with support for highlighting"
|
||||
|
|
|
@ -31,12 +31,16 @@ Exports functions for syntax highlighting.
|
|||
module Text.Pandoc.Highlighting ( languages, highlightHtml ) where
|
||||
import Text.Highlighting.Kate
|
||||
import Text.XHtml
|
||||
import Data.List (find)
|
||||
import Data.List (find, lookup)
|
||||
import Data.Maybe (fromMaybe)
|
||||
import Data.Char (toLower)
|
||||
import Text.Pandoc.Definition
|
||||
|
||||
highlightHtml :: [String] -> String -> Either String Html
|
||||
highlightHtml classes rawCode =
|
||||
let fmtOpts = case find (`elem` ["number","numberLines","number-lines"]) classes of
|
||||
highlightHtml :: Attr -> String -> Either String Html
|
||||
highlightHtml (_, classes, keyvals) rawCode =
|
||||
let firstNum = read $ fromMaybe "1" $ lookup "startFrom" keyvals
|
||||
fmtOpts = [OptNumberFrom firstNum] ++
|
||||
case find (`elem` ["number","numberLines","number-lines"]) classes of
|
||||
Nothing -> []
|
||||
Just _ -> [OptNumberLines]
|
||||
lcLanguages = map (map toLower) languages
|
||||
|
|
Loading…
Add table
Reference in a new issue