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 (space' wrap
<> literal (getText rawkey) <> literal (getText rawkey)
<> char '=' <> char '='
<> doubleQuotes (fromChoiceString wrap value) <> doubleQuotes (fromChoiceString False value)
<> attrs) h <> attrs) h
go wrap attrs (AddCustomAttribute key value h) = go wrap attrs (AddCustomAttribute key value h) =
go wrap go wrap
(space' wrap (space' wrap
<> fromChoiceString wrap key <> fromChoiceString wrap key
<> char '=' <> char '='
<> doubleQuotes (fromChoiceString wrap value) <> doubleQuotes (fromChoiceString False value)
<> attrs) h <> attrs) h
go wrap _ (Content content _) = fromChoiceString wrap content go wrap _ (Content content _) = fromChoiceString wrap content
go wrap _ (Comment comment _) = go wrap _ (Comment comment _) =
literal "<!--" literal "<!--"
<> space' wrap <> space' wrap
<> fromChoiceString wrap comment <> fromChoiceString False comment
<> space' wrap <> space' wrap
<> "-->" <> "-->"
go wrap attrs (Append h1 h2) = go wrap attrs h1 <> go wrap attrs h2 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 % pandoc -f latex -t html
I want to explain the interface of \lstinline[language=Java]{public class MyClass}. I want to explain the interface of \lstinline[language=Java]{public class MyClass}.
^D ^D
<p>I want to explain the interface of <code class="sourceCode <p>I want to explain the interface of <code
java"><span class="kw">public</span> <span class="kw">class</span> class="sourceCode java"><span class="kw">public</span> <span
MyClass</code>.</p> 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 % pandoc -f latex -t html
I want to explain the interface of \mintinline{java}{public class MyClass}. I want to explain the interface of \mintinline{java}{public class MyClass}.
^D ^D
<p>I want to explain the interface of <code class="sourceCode <p>I want to explain the interface of <code
java"><span class="kw">public</span> <span class="kw">class</span> class="sourceCode java"><span class="kw">public</span> <span
MyClass</code>.</p> class="kw">class</span> MyClass</code>.</p>
``` ```
@ -56,9 +56,9 @@ MyClass</code>.</p>
% pandoc -f latex -t html % pandoc -f latex -t html
I want to explain the interface of \mintinline{java}|public class MyClass|. I want to explain the interface of \mintinline{java}|public class MyClass|.
^D ^D
<p>I want to explain the interface of <code class="sourceCode <p>I want to explain the interface of <code
java"><span class="kw">public</span> <span class="kw">class</span> class="sourceCode java"><span class="kw">public</span> <span
MyClass</code>.</p> class="kw">class</span> MyClass</code>.</p>
``` ```

View file

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

View file

@ -20,10 +20,10 @@ Something
<li>Two <code>--&gt;something&lt;!--</code></li> <li>Two <code>--&gt;something&lt;!--</code></li>
<li>Three</li> <li>Three</li>
</ol> </ol>
<div class="sourceCode" id="cb1"><pre class="sourceCode <div class="sourceCode" id="cb1"><pre
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> 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 <div class="sourceCode" id="cb2"><pre
html"><code class="sourceCode html"><span id="cb2-1"><a href="#cb2-1" aria-hidden="true" tabindex="-1"></a>Something</span></code></pre></div> 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><code>--&gt;something&lt;!--</code></li>
<li>bye <code>--&gt;something else&lt;!--</code></li> <li>bye <code>--&gt;something else&lt;!--</code></li>
</ul> </ul>
<div class="sourceCode" id="cb1"><pre class="sourceCode <div class="sourceCode" id="cb1"><pre
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> 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 <div class="sourceCode" id="cb2"><pre
html"><code class="sourceCode html"><span id="cb2-1"><a href="#cb2-1" aria-hidden="true" tabindex="-1"></a>Something</span></code></pre></div> 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 b
``` ```
^D ^D
<div class="sourceCode" id="foocb1"><pre class="sourceCode <div class="sourceCode" id="foocb1"><pre
haskell"><code class="sourceCode haskell"><span id="foocb1-1"><a href="#foocb1-1" aria-hidden="true" tabindex="-1"></a>a</span> 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> <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 b
``` ```
^D ^D
<div class="sourceCode" id="foobar"><pre class="sourceCode <div class="sourceCode" id="foobar"><pre
haskell"><code class="sourceCode haskell"><span id="foobar-1"><a href="#foobar-1" aria-hidden="true" tabindex="-1"></a>a</span> 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> <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 ^D
<p><img style="vertical-align:middle" <p><img style="vertical-align:middle"
src="https://latex.codecogs.com/png.latex?%5Ctextstyle%20T_n%3D%7Bn%2B1%20%5Cchoose%202%7D" 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 alt="T_n={n+1 \choose 2}" title="T_n={n+1 \choose 2}"
inline" /></p> class="math inline" /></p>
```` ````
```` ````
@ -14,7 +14,7 @@ $$T_n={n+1 \choose 2}$$
^D ^D
<p><img style="vertical-align:middle" <p><img style="vertical-align:middle"
src="https://latex.codecogs.com/png.latex?%5Cdisplaystyle%20T_n%3D%7Bn%2B1%20%5Cchoose%202%7D" 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 alt="T_n={n+1 \choose 2}" title="T_n={n+1 \choose 2}"
display" /></p> class="math display" /></p>
```` ````

View file

@ -1,12 +1,12 @@
<div id="5cf8f54d-bf3c-4db2-996d-22662a86ad43" class="cell code" <div id="5cf8f54d-bf3c-4db2-996d-22662a86ad43" class="cell code"
data-execution_count="1"> data-execution_count="1">
<div class="sourceCode" id="cb1"><pre class="sourceCode <div class="sourceCode" id="cb1"><pre
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> 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>
<div id="a0228622-9ff8-4392-9ddd-f70a90f0e106" class="cell code" <div id="a0228622-9ff8-4392-9ddd-f70a90f0e106" class="cell code"
data-execution_count="2"> data-execution_count="2">
<div class="sourceCode" id="cb2"><pre class="sourceCode <div class="sourceCode" id="cb2"><pre
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> 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> <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"> <div class="output display_data">
<p><em>you should see this when converting from ipynb to html instead of the image below.</em></p> <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"><em>α</em> ∧ <em>ω</em></span></li>
<li><span class="math inline">223</span></li> <li><span class="math inline">223</span></li>
<li><span class="math inline"><em>p</em></span>-Tree</li> <li><span class="math inline"><em>p</em></span>-Tree</li>
<li>Heres some display math: <span class="math <li>Heres some display math: <span
display">$$\frac{d}{dx}f(x)=\lim_{h\to 0}\frac{f(x+h)-f(x)}{h}$$</span></li> class="math display">$$\frac{d}{dx}f(x)=\lim_{h\to
<li>Heres one that has a line break in it: <span class="math 0}\frac{f(x+h)-f(x)}{h}$$</span></li>
inline"><em>α</em>+<em>ω</em>×<em>x</em><sup>2</sup></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> </ul>
<p>These shouldnt be math:</p> <p>These shouldnt be math:</p>
<ul> <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"><em>α</em> ∧ <em>ω</em></span></li>
<li><span class="math inline">223</span></li> <li><span class="math inline">223</span></li>
<li><span class="math inline"><em>p</em></span>-Tree</li> <li><span class="math inline"><em>p</em></span>-Tree</li>
<li>Heres some display math: <span class="math <li>Heres some display math: <span
display">$$\frac{d}{dx}f(x)=\lim_{h\to 0}\frac{f(x+h)-f(x)}{h}$$</span></li> class="math display">$$\frac{d}{dx}f(x)=\lim_{h\to
<li>Heres one that has a line break in it: <span class="math 0}\frac{f(x+h)-f(x)}{h}$$</span></li>
inline"><em>α</em>+<em>ω</em>×<em>x</em><sup>2</sup></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> </ul>
<p>These shouldnt be math:</p> <p>These shouldnt be math:</p>
<ul> <ul>