aboutsummaryrefslogtreecommitdiff
path: root/templates
diff options
context:
space:
mode:
authorfiddlosopher <fiddlosopher@788f1e2b-df1e-0410-8736-df70ead52e1b>2008-02-10 18:59:34 +0000
committerfiddlosopher <fiddlosopher@788f1e2b-df1e-0410-8736-df70ead52e1b>2008-02-10 18:59:34 +0000
commit742a465980ea6cd1d23d38ee3f7d6d0d7616f471 (patch)
treea63ffde7d1dd8c69efef062ff8f2e235013eeac6 /templates
parent250a3e4dda52af478acfbb61add13461731945a8 (diff)
downloadpandoc-742a465980ea6cd1d23d38ee3f7d6d0d7616f471.tar.gz
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
Diffstat (limited to 'templates')
-rw-r--r--templates/Highlighting.no.hs6
-rw-r--r--templates/Highlighting.yes.hs12
2 files changed, 11 insertions, 7 deletions
diff --git a/templates/Highlighting.no.hs b/templates/Highlighting.no.hs
index 2acea4420..ed6b7c325 100644
--- a/templates/Highlighting.no.hs
+++ b/templates/Highlighting.no.hs
@@ -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"
diff --git a/templates/Highlighting.yes.hs b/templates/Highlighting.yes.hs
index a015e1e34..915f6ffee 100644
--- a/templates/Highlighting.yes.hs
+++ b/templates/Highlighting.yes.hs
@@ -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