aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/Text/Pandoc/Highlighting.hs8
-rw-r--r--src/Text/Pandoc/Writers/HTML.hs4
2 files changed, 8 insertions, 4 deletions
diff --git a/src/Text/Pandoc/Highlighting.hs b/src/Text/Pandoc/Highlighting.hs
index f29106262..cf8d37431 100644
--- a/src/Text/Pandoc/Highlighting.hs
+++ b/src/Text/Pandoc/Highlighting.hs
@@ -37,10 +37,14 @@ import Data.List (find)
import Data.Maybe (fromMaybe)
import Data.Char (toLower)
-highlightHtml :: Attr -> String -> Either String Html
-highlightHtml (_, classes, keyvals) rawCode =
+highlightHtml :: Bool -- ^ True if inline HTML
+ -> Attr -- ^ Attributes of the Code or CodeBlock
+ -> String -- ^ Raw contents of the Code or CodeBlock
+ -> Either String Html -- ^ An error or the formatted Html
+highlightHtml inline (_, classes, keyvals) rawCode =
let firstNum = read $ fromMaybe "1" $ lookup "startFrom" keyvals
fmtOpts = [OptNumberFrom firstNum] ++
+ [OptInline | inline] ++
case find (`elem` ["number","numberLines","number-lines"]) classes of
Nothing -> []
Just _ -> [OptNumberLines]
diff --git a/src/Text/Pandoc/Writers/HTML.hs b/src/Text/Pandoc/Writers/HTML.hs
index 3b40515da..08860e0f1 100644
--- a/src/Text/Pandoc/Writers/HTML.hs
+++ b/src/Text/Pandoc/Writers/HTML.hs
@@ -324,7 +324,7 @@ blockToHtml opts (CodeBlock (id',classes,keyvals) rawCode) = do
let classes' = if writerLiterateHaskell opts
then classes
else filter (/= "literate") classes
- case highlightHtml (id',classes',keyvals) rawCode of
+ case highlightHtml False (id',classes',keyvals) rawCode of
Left _ -> -- change leading newlines into <br /> tags, because some
-- browsers ignore leading newlines in pre blocks
let (leadingBreaks, rawCode') = span (=='\n') rawCode
@@ -484,7 +484,7 @@ inlineToHtml opts inline =
(Emph lst) -> inlineListToHtml opts lst >>= return . emphasize
(Strong lst) -> inlineListToHtml opts lst >>= return . strong
(Code attr str) -> return $ thecode ! (attrsToHtml opts attr) << str'
- where str' = case highlightHtml attr str of
+ where str' = case highlightHtml True attr str of
Left _ -> stringToHtml str
Right h -> h
(Strikeout lst) -> inlineListToHtml opts lst >>=