Fixed highlighting for inline code.
highlightHtml in Highlighting now has a boolean argument that selects between inline and block content. Revised tests for new highlighting-kate.
This commit is contained in:
parent
9e89047518
commit
9f28acba9d
5 changed files with 42 additions and 34 deletions
|
@ -169,6 +169,10 @@ pandoc (1.8)
|
|||
* Added support for `lang` in `html` tag in the HTML template,
|
||||
so you can do `pandoc -s -V lang=es`, for example.
|
||||
|
||||
* `highlightHtml` in `Text.Pandoc.Highlighting` now takes
|
||||
a boolean argument that selects between "inline" and
|
||||
"block" HTML.
|
||||
|
||||
* `Text.Pandoc.Writers.RTF` now exports `rtfEmbedImage`.
|
||||
Images are embedded in RTF output when possible (png, jpeg).
|
||||
Resolves Issue #275.
|
||||
|
|
|
@ -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]
|
||||
|
|
|
@ -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 >>=
|
||||
|
|
|
@ -9,19 +9,19 @@ table.sourceCode, tr.sourceCode, td.lineNumbers, td.sourceCode, table.sourceCode
|
|||
{ margin: 0; padding: 0; border: 0; vertical-align: baseline; border: none; }
|
||||
td.lineNumbers { border-right: 1px solid #AAAAAA; text-align: right; color: #AAAAAA; padding-right: 5px; padding-left: 5px; }
|
||||
td.sourceCode { padding-left: 5px; }
|
||||
pre.sourceCode span.kw { color: #007020; font-weight: bold; }
|
||||
pre.sourceCode span.dt { color: #902000; }
|
||||
pre.sourceCode span.dv { color: #40a070; }
|
||||
pre.sourceCode span.bn { color: #40a070; }
|
||||
pre.sourceCode span.fl { color: #40a070; }
|
||||
pre.sourceCode span.ch { color: #4070a0; }
|
||||
pre.sourceCode span.st { color: #4070a0; }
|
||||
pre.sourceCode span.co { color: #60a0b0; font-style: italic; }
|
||||
pre.sourceCode span.ot { color: #007020; }
|
||||
pre.sourceCode span.al { color: red; font-weight: bold; }
|
||||
pre.sourceCode span.fu { color: #06287e; }
|
||||
pre.sourceCode span.re { }
|
||||
pre.sourceCode span.er { color: red; font-weight: bold; }
|
||||
code.sourceCode span.kw { color: #007020; font-weight: bold; }
|
||||
code.sourceCode span.dt { color: #902000; }
|
||||
code.sourceCode span.dv { color: #40a070; }
|
||||
code.sourceCode span.bn { color: #40a070; }
|
||||
code.sourceCode span.fl { color: #40a070; }
|
||||
code.sourceCode span.ch { color: #4070a0; }
|
||||
code.sourceCode span.st { color: #4070a0; }
|
||||
code.sourceCode span.co { color: #60a0b0; font-style: italic; }
|
||||
code.sourceCode span.ot { color: #007020; }
|
||||
code.sourceCode span.al { color: red; font-weight: bold; }
|
||||
code.sourceCode span.fu { color: #06287e; }
|
||||
code.sourceCode span.re { }
|
||||
code.sourceCode span.er { color: red; font-weight: bold; }
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
|
@ -31,8 +31,8 @@ pre.sourceCode span.er { color: red; font-weight: bold; }
|
|||
><code
|
||||
>unsplit</code
|
||||
> is an arrow that takes a pair of values and combines them to return a single value:</p
|
||||
><pre class="sourceCode haskell"
|
||||
><code
|
||||
><pre class="sourceCode"
|
||||
><code class="sourceCode haskell"
|
||||
><span class="ot"
|
||||
>unsplit </span
|
||||
><span class="ot"
|
||||
|
|
|
@ -9,19 +9,19 @@ table.sourceCode, tr.sourceCode, td.lineNumbers, td.sourceCode, table.sourceCode
|
|||
{ margin: 0; padding: 0; border: 0; vertical-align: baseline; border: none; }
|
||||
td.lineNumbers { border-right: 1px solid #AAAAAA; text-align: right; color: #AAAAAA; padding-right: 5px; padding-left: 5px; }
|
||||
td.sourceCode { padding-left: 5px; }
|
||||
pre.sourceCode span.kw { color: #007020; font-weight: bold; }
|
||||
pre.sourceCode span.dt { color: #902000; }
|
||||
pre.sourceCode span.dv { color: #40a070; }
|
||||
pre.sourceCode span.bn { color: #40a070; }
|
||||
pre.sourceCode span.fl { color: #40a070; }
|
||||
pre.sourceCode span.ch { color: #4070a0; }
|
||||
pre.sourceCode span.st { color: #4070a0; }
|
||||
pre.sourceCode span.co { color: #60a0b0; font-style: italic; }
|
||||
pre.sourceCode span.ot { color: #007020; }
|
||||
pre.sourceCode span.al { color: red; font-weight: bold; }
|
||||
pre.sourceCode span.fu { color: #06287e; }
|
||||
pre.sourceCode span.re { }
|
||||
pre.sourceCode span.er { color: red; font-weight: bold; }
|
||||
code.sourceCode span.kw { color: #007020; font-weight: bold; }
|
||||
code.sourceCode span.dt { color: #902000; }
|
||||
code.sourceCode span.dv { color: #40a070; }
|
||||
code.sourceCode span.bn { color: #40a070; }
|
||||
code.sourceCode span.fl { color: #40a070; }
|
||||
code.sourceCode span.ch { color: #4070a0; }
|
||||
code.sourceCode span.st { color: #4070a0; }
|
||||
code.sourceCode span.co { color: #60a0b0; font-style: italic; }
|
||||
code.sourceCode span.ot { color: #007020; }
|
||||
code.sourceCode span.al { color: red; font-weight: bold; }
|
||||
code.sourceCode span.fu { color: #06287e; }
|
||||
code.sourceCode span.re { }
|
||||
code.sourceCode span.er { color: red; font-weight: bold; }
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
|
@ -31,8 +31,8 @@ pre.sourceCode span.er { color: red; font-weight: bold; }
|
|||
><code
|
||||
>unsplit</code
|
||||
> is an arrow that takes a pair of values and combines them to return a single value:</p
|
||||
><pre class="sourceCode haskell"
|
||||
><code
|
||||
><pre class="sourceCode"
|
||||
><code class="sourceCode haskell"
|
||||
>> <span class="ot"
|
||||
>unsplit </span
|
||||
><span class="ot"
|
||||
|
|
Loading…
Reference in a new issue