HTML writer: don't break attributes values when wrapping.

This commit is contained in:
John MacFarlane 2022-01-10 10:40:49 -08:00
parent 6f739cdb4d
commit 7bf1191686
9 changed files with 46 additions and 44 deletions

View file

@ -57,20 +57,20 @@ layoutMarkup = go True mempty
(space' wrap
<> literal (getText rawkey)
<> char '='
<> doubleQuotes (fromChoiceString wrap value)
<> doubleQuotes (fromChoiceString False value)
<> attrs) h
go wrap attrs (AddCustomAttribute key value h) =
go wrap
(space' wrap
<> fromChoiceString wrap key
<> char '='
<> doubleQuotes (fromChoiceString wrap value)
<> doubleQuotes (fromChoiceString False value)
<> attrs) h
go wrap _ (Content content _) = fromChoiceString wrap content
go wrap _ (Comment comment _) =
literal "<!--"
<> space' wrap
<> fromChoiceString wrap comment
<> fromChoiceString False comment
<> space' wrap
<> "-->"
go wrap attrs (Append h1 h2) = go wrap attrs h1 <> go wrap attrs h2

View file

@ -2,9 +2,9 @@
% pandoc -f latex -t html
I want to explain the interface of \lstinline[language=Java]{public class MyClass}.
^D
<p>I want to explain the interface of <code class="sourceCode
java"><span class="kw">public</span> <span class="kw">class</span>
MyClass</code>.</p>
<p>I want to explain the interface of <code
class="sourceCode java"><span class="kw">public</span> <span
class="kw">class</span> MyClass</code>.</p>
```
@ -46,9 +46,9 @@ I want to explain the interface of \lstinline[language=Java]{public class MyClas
% pandoc -f latex -t html
I want to explain the interface of \mintinline{java}{public class MyClass}.
^D
<p>I want to explain the interface of <code class="sourceCode
java"><span class="kw">public</span> <span class="kw">class</span>
MyClass</code>.</p>
<p>I want to explain the interface of <code
class="sourceCode java"><span class="kw">public</span> <span
class="kw">class</span> MyClass</code>.</p>
```
@ -56,9 +56,9 @@ MyClass</code>.</p>
% pandoc -f latex -t html
I want to explain the interface of \mintinline{java}|public class MyClass|.
^D
<p>I want to explain the interface of <code class="sourceCode
java"><span class="kw">public</span> <span class="kw">class</span>
MyClass</code>.</p>
<p>I want to explain the interface of <code
class="sourceCode java"><span class="kw">public</span> <span
class="kw">class</span> MyClass</code>.</p>
```

View file

@ -32,8 +32,8 @@ A spider: [spider]
^D
<h1 id="chapter-one">Chapter one</h1>
<p>A spider: <img src="command/chap1/spider.png" alt="spider" /></p>
<p>Another spider: <img src="command/chap2/spider.png" alt="another
spider" /></p>
<p>Another spider: <img src="command/chap2/spider.png"
alt="another spider" /></p>
<p>The moon: <img src="command/chap1/../../lalune.jpg" alt="moon" /></p>
<p>Link to <a href="command/chap1/spider.png">spider picture</a>.</p>
<p>URL left alone: <a
@ -51,8 +51,8 @@ href="/foo/bar/baz.png">absolute</a>.</p>
^D
<h1>Chapter one</h1>
<p>A spider: <img src="command/chap1/spider.png" alt="spider" /></p>
<p>Another spider: <img src="command/chap2/spider.png" alt="another
spider" /></p>
<p>Another spider: <img src="command/chap2/spider.png"
alt="another spider" /></p>
<p>The moon: <img src="command/chap1/../../lalune.jpg" alt="moon" /></p>
<p>Link to <a href="command/chap1/spider.png">spider picture</a>.</p>
<p>URL left alone: <a

View file

@ -20,10 +20,10 @@ Something
<li>Two <code>--&gt;something&lt;!--</code></li>
<li>Three</li>
</ol>
<div class="sourceCode" id="cb1"><pre class="sourceCode
html"><code class="sourceCode html"><span id="cb1-1"><a href="#cb1-1" aria-hidden="true" tabindex="-1"></a>--&gt;<span class="co">&lt;!--&lt;script&gt;alert(&#39;Escaped!&#39;)&lt;/script&gt;</span></span></code></pre></div>
<div class="sourceCode" id="cb2"><pre class="sourceCode
html"><code class="sourceCode html"><span id="cb2-1"><a href="#cb2-1" aria-hidden="true" tabindex="-1"></a>Something</span></code></pre></div>
<div class="sourceCode" id="cb1"><pre
class="sourceCode html"><code class="sourceCode html"><span id="cb1-1"><a href="#cb1-1" aria-hidden="true" tabindex="-1"></a>--&gt;<span class="co">&lt;!--&lt;script&gt;alert(&#39;Escaped!&#39;)&lt;/script&gt;</span></span></code></pre></div>
<div class="sourceCode" id="cb2"><pre
class="sourceCode html"><code class="sourceCode html"><span id="cb2-1"><a href="#cb2-1" aria-hidden="true" tabindex="-1"></a>Something</span></code></pre></div>
```
```
@ -48,10 +48,10 @@ Something
<li><code>--&gt;something&lt;!--</code></li>
<li>bye <code>--&gt;something else&lt;!--</code></li>
</ul>
<div class="sourceCode" id="cb1"><pre class="sourceCode
html"><code class="sourceCode html"><span id="cb1-1"><a href="#cb1-1" aria-hidden="true" tabindex="-1"></a>--&gt;<span class="co">&lt;!--&lt;script&gt;alert(&#39;Escaped!&#39;)&lt;/script&gt;</span></span></code></pre></div>
<div class="sourceCode" id="cb2"><pre class="sourceCode
html"><code class="sourceCode html"><span id="cb2-1"><a href="#cb2-1" aria-hidden="true" tabindex="-1"></a>Something</span></code></pre></div>
<div class="sourceCode" id="cb1"><pre
class="sourceCode html"><code class="sourceCode html"><span id="cb1-1"><a href="#cb1-1" aria-hidden="true" tabindex="-1"></a>--&gt;<span class="co">&lt;!--&lt;script&gt;alert(&#39;Escaped!&#39;)&lt;/script&gt;</span></span></code></pre></div>
<div class="sourceCode" id="cb2"><pre
class="sourceCode html"><code class="sourceCode html"><span id="cb2-1"><a href="#cb2-1" aria-hidden="true" tabindex="-1"></a>Something</span></code></pre></div>
```
```

View file

@ -5,8 +5,8 @@ a
b
```
^D
<div class="sourceCode" id="foocb1"><pre class="sourceCode
haskell"><code class="sourceCode haskell"><span id="foocb1-1"><a href="#foocb1-1" aria-hidden="true" tabindex="-1"></a>a</span>
<div class="sourceCode" id="foocb1"><pre
class="sourceCode haskell"><code class="sourceCode haskell"><span id="foocb1-1"><a href="#foocb1-1" aria-hidden="true" tabindex="-1"></a>a</span>
<span id="foocb1-2"><a href="#foocb1-2" aria-hidden="true" tabindex="-1"></a>b</span></code></pre></div>
````
@ -17,8 +17,8 @@ a
b
```
^D
<div class="sourceCode" id="foobar"><pre class="sourceCode
haskell"><code class="sourceCode haskell"><span id="foobar-1"><a href="#foobar-1" aria-hidden="true" tabindex="-1"></a>a</span>
<div class="sourceCode" id="foobar"><pre
class="sourceCode haskell"><code class="sourceCode haskell"><span id="foobar-1"><a href="#foobar-1" aria-hidden="true" tabindex="-1"></a>a</span>
<span id="foobar-2"><a href="#foobar-2" aria-hidden="true" tabindex="-1"></a>b</span></code></pre></div>
````

View file

@ -4,8 +4,8 @@ $T_n={n+1 \choose 2}$
^D
<p><img style="vertical-align:middle"
src="https://latex.codecogs.com/png.latex?%5Ctextstyle%20T_n%3D%7Bn%2B1%20%5Cchoose%202%7D"
alt="T_n={n+1 \choose 2}" title="T_n={n+1 \choose 2}" class="math
inline" /></p>
alt="T_n={n+1 \choose 2}" title="T_n={n+1 \choose 2}"
class="math inline" /></p>
````
````
@ -14,7 +14,7 @@ $$T_n={n+1 \choose 2}$$
^D
<p><img style="vertical-align:middle"
src="https://latex.codecogs.com/png.latex?%5Cdisplaystyle%20T_n%3D%7Bn%2B1%20%5Cchoose%202%7D"
alt="T_n={n+1 \choose 2}" title="T_n={n+1 \choose 2}" class="math
display" /></p>
alt="T_n={n+1 \choose 2}" title="T_n={n+1 \choose 2}"
class="math display" /></p>
````

View file

@ -1,12 +1,12 @@
<div id="5cf8f54d-bf3c-4db2-996d-22662a86ad43" class="cell code"
data-execution_count="1">
<div class="sourceCode" id="cb1"><pre class="sourceCode
python"><code class="sourceCode python"><span id="cb1-1"><a href="#cb1-1" aria-hidden="true" tabindex="-1"></a><span class="im">import</span> matplotlib.pyplot <span class="im">as</span> plt</span></code></pre></div>
<div class="sourceCode" id="cb1"><pre
class="sourceCode python"><code class="sourceCode python"><span id="cb1-1"><a href="#cb1-1" aria-hidden="true" tabindex="-1"></a><span class="im">import</span> matplotlib.pyplot <span class="im">as</span> plt</span></code></pre></div>
</div>
<div id="a0228622-9ff8-4392-9ddd-f70a90f0e106" class="cell code"
data-execution_count="2">
<div class="sourceCode" id="cb2"><pre class="sourceCode
python"><code class="sourceCode python"><span id="cb2-1"><a href="#cb2-1" aria-hidden="true" tabindex="-1"></a>fig, ax <span class="op">=</span> plt.subplots(figsize<span class="op">=</span>(<span class="dv">1</span>, <span class="dv">1</span>), dpi<span class="op">=</span><span class="dv">4</span>)</span>
<div class="sourceCode" id="cb2"><pre
class="sourceCode python"><code class="sourceCode python"><span id="cb2-1"><a href="#cb2-1" aria-hidden="true" tabindex="-1"></a>fig, ax <span class="op">=</span> plt.subplots(figsize<span class="op">=</span>(<span class="dv">1</span>, <span class="dv">1</span>), dpi<span class="op">=</span><span class="dv">4</span>)</span>
<span id="cb2-2"><a href="#cb2-2" aria-hidden="true" tabindex="-1"></a>ax.imshow([[<span class="dv">0</span>, <span class="dv">1</span>], [<span class="dv">2</span>, <span class="dv">3</span>]])<span class="op">;</span></span></code></pre></div>
<div class="output display_data">
<p><em>you should see this when converting from ipynb to html instead of the image below.</em></p>

View file

@ -595,10 +595,11 @@ href="http://example.com/?foo=1&amp;bar=2">quoted link</a>”.</p>
<li><span class="math inline"><em>α</em> ∧ <em>ω</em></span></li>
<li><span class="math inline">223</span></li>
<li><span class="math inline"><em>p</em></span>-Tree</li>
<li>Heres some display math: <span class="math
display">$$\frac{d}{dx}f(x)=\lim_{h\to 0}\frac{f(x+h)-f(x)}{h}$$</span></li>
<li>Heres one that has a line break in it: <span class="math
inline"><em>α</em>+<em>ω</em>×<em>x</em><sup>2</sup></span>.</li>
<li>Heres some display math: <span
class="math display">$$\frac{d}{dx}f(x)=\lim_{h\to
0}\frac{f(x+h)-f(x)}{h}$$</span></li>
<li>Heres one that has a line break in it: <span
class="math inline"><em>α</em>+<em>ω</em>×<em>x</em><sup>2</sup></span>.</li>
</ul>
<p>These shouldnt be math:</p>
<ul>

View file

@ -598,10 +598,11 @@ href="http://example.com/?foo=1&amp;bar=2">quoted link</a>”.</p>
<li><span class="math inline"><em>α</em> ∧ <em>ω</em></span></li>
<li><span class="math inline">223</span></li>
<li><span class="math inline"><em>p</em></span>-Tree</li>
<li>Heres some display math: <span class="math
display">$$\frac{d}{dx}f(x)=\lim_{h\to 0}\frac{f(x+h)-f(x)}{h}$$</span></li>
<li>Heres one that has a line break in it: <span class="math
inline"><em>α</em>+<em>ω</em>×<em>x</em><sup>2</sup></span>.</li>
<li>Heres some display math: <span
class="math display">$$\frac{d}{dx}f(x)=\lim_{h\to
0}\frac{f(x+h)-f(x)}{h}$$</span></li>
<li>Heres one that has a line break in it: <span
class="math inline"><em>α</em>+<em>ω</em>×<em>x</em><sup>2</sup></span>.</li>
</ul>
<p>These shouldnt be math:</p>
<ul>