Preserve attributes in highlighted HTML.
The container element will have the classes, id, and key-value attributes you specified in the delimited code block. Previously these were stripped off.
This commit is contained in:
parent
4fd9fb9ea2
commit
012405e8c3
4 changed files with 8 additions and 5 deletions
|
@ -70,6 +70,7 @@ highlight formatter (_, classes, keyvals) rawCode =
|
|||
in case find (`elem` lcLanguages) lcclasses of
|
||||
Nothing -> Nothing
|
||||
Just language -> Just
|
||||
$ formatter fmtOpts{ codeClasses = [language] }
|
||||
$ formatter fmtOpts{ codeClasses = [language],
|
||||
containerClasses = classes }
|
||||
$ highlightAs language rawCode
|
||||
|
||||
|
|
|
@ -379,7 +379,7 @@ blockToHtml opts (CodeBlock (id',classes,keyvals) rawCode) = do
|
|||
in return $ foldl (!) H.pre attrs $ H.code
|
||||
$ toHtml adjCode
|
||||
Just h -> modify (\st -> st{ stHighlighting = True }) >>
|
||||
return h
|
||||
return (foldl (!) h (attrsToHtml opts (id',[],keyvals)))
|
||||
blockToHtml opts (BlockQuote blocks) =
|
||||
-- in S5, treat list in blockquote specially
|
||||
-- if default is incremental, make it nonincremental;
|
||||
|
@ -547,7 +547,9 @@ inlineToHtml opts inline =
|
|||
Nothing -> return
|
||||
$ foldl (!) H.code (attrsToHtml opts attr)
|
||||
$ strToHtml str
|
||||
Just h -> return h
|
||||
Just h -> return $ foldl (!) h $
|
||||
attrsToHtml opts (id',[],keyvals)
|
||||
where (id',_,keyvals) = attr
|
||||
(Strikeout lst) -> inlineListToHtml opts lst >>=
|
||||
return . H.del
|
||||
(SmallCaps lst) -> inlineListToHtml opts lst >>=
|
||||
|
|
|
@ -27,7 +27,7 @@ code > span.er { color: #ff0000; font-weight: bold; }
|
|||
<body>
|
||||
<h1 id="lhs-test">lhs test</h1>
|
||||
<p><code>unsplit</code> is an arrow that takes a pair of values and combines them to return a single value:</p>
|
||||
<pre class="sourceCode"><code class="sourceCode haskell"><span class="ot">unsplit ::</span> (<span class="dt">Arrow</span> a) <span class="ot">=></span> (b <span class="ot">-></span> c <span class="ot">-></span> d) <span class="ot">-></span> a (b, c) d
|
||||
<pre class="sourceCode literate haskell"><code class="sourceCode haskell"><span class="ot">unsplit ::</span> (<span class="dt">Arrow</span> a) <span class="ot">=></span> (b <span class="ot">-></span> c <span class="ot">-></span> d) <span class="ot">-></span> a (b, c) d
|
||||
unsplit <span class="fu">=</span> arr <span class="fu">.</span> <span class="fu">uncurry</span>
|
||||
<span class="co">-- arr (\op (x,y) -> x `op` y) </span></code></pre>
|
||||
<p><code>(***)</code> combines two arrows into a new arrow by running the two arrows on a pair of values (one arrow on the first item of the pair and one arrow on the second item of the pair).</p>
|
||||
|
|
|
@ -27,7 +27,7 @@ code > span.er { color: #ff0000; font-weight: bold; }
|
|||
<body>
|
||||
<h1 id="lhs-test">lhs test</h1>
|
||||
<p><code>unsplit</code> is an arrow that takes a pair of values and combines them to return a single value:</p>
|
||||
<pre class="sourceCode"><code class="sourceCode haskell"><span class="fu">></span><span class="ot"> unsplit ::</span> (<span class="dt">Arrow</span> a) <span class="ot">=></span> (b <span class="ot">-></span> c <span class="ot">-></span> d) <span class="ot">-></span> a (b, c) d
|
||||
<pre class="sourceCode literate haskell"><code class="sourceCode haskell"><span class="fu">></span><span class="ot"> unsplit ::</span> (<span class="dt">Arrow</span> a) <span class="ot">=></span> (b <span class="ot">-></span> c <span class="ot">-></span> d) <span class="ot">-></span> a (b, c) d
|
||||
<span class="fu">></span> unsplit <span class="fu">=</span> arr <span class="fu">.</span> <span class="fu">uncurry</span>
|
||||
<span class="fu">></span> <span class="co">-- arr (\op (x,y) -> x `op` y) </span></code></pre>
|
||||
<p><code>(***)</code> combines two arrows into a new arrow by running the two arrows on a pair of values (one arrow on the first item of the pair and one arrow on the second item of the pair).</p>
|
||||
|
|
Loading…
Add table
Reference in a new issue