From 7bf119168658627dbddcc6753b79a5f921519782 Mon Sep 17 00:00:00 2001 From: John MacFarlane Date: Mon, 10 Jan 2022 10:40:49 -0800 Subject: [PATCH] HTML writer: don't break attributes values when wrapping. --- src/Text/Pandoc/Writers/Blaze.hs | 6 +++--- test/command/3534.md | 18 +++++++++--------- test/command/3752.md | 8 ++++---- test/command/5627.md | 16 ++++++++-------- test/command/5650.md | 8 ++++---- test/command/5655.md | 8 ++++---- test/ipynb/rank.out.html | 8 ++++---- test/writer.html4 | 9 +++++---- test/writer.html5 | 9 +++++---- 9 files changed, 46 insertions(+), 44 deletions(-) diff --git a/src/Text/Pandoc/Writers/Blaze.hs b/src/Text/Pandoc/Writers/Blaze.hs index 8233043a3..692e89e27 100644 --- a/src/Text/Pandoc/Writers/Blaze.hs +++ b/src/Text/Pandoc/Writers/Blaze.hs @@ -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 "" go wrap attrs (Append h1 h2) = go wrap attrs h1 <> go wrap attrs h2 diff --git a/test/command/3534.md b/test/command/3534.md index 42dca9207..41bf9a5ff 100644 --- a/test/command/3534.md +++ b/test/command/3534.md @@ -2,9 +2,9 @@ % pandoc -f latex -t html I want to explain the interface of \lstinline[language=Java]{public class MyClass}. ^D -

I want to explain the interface of public class -MyClass.

+

I want to explain the interface of public class MyClass.

``` @@ -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 -

I want to explain the interface of public class -MyClass.

+

I want to explain the interface of public class MyClass.

``` @@ -56,9 +56,9 @@ MyClass.

% pandoc -f latex -t html I want to explain the interface of \mintinline{java}|public class MyClass|. ^D -

I want to explain the interface of public class -MyClass.

+

I want to explain the interface of public class MyClass.

``` diff --git a/test/command/3752.md b/test/command/3752.md index 7db581cfe..bac81b1a1 100644 --- a/test/command/3752.md +++ b/test/command/3752.md @@ -32,8 +32,8 @@ A spider: [spider] ^D

Chapter one

A spider: spider

-

Another spider: another
-spider

+

Another spider:

The moon: moon

Link to spider picture.

URL left alone: absolute.

^D

Chapter one

A spider: spider

-

Another spider: another
-spider

+

Another spider:

The moon: moon

Link to spider picture.

URL left alone: Two -->something<!--

  • Three
  • -
    --><!--<script>alert('Escaped!')</script>
    -
    Something
    +
    --><!--<script>alert('Escaped!')</script>
    +
    Something
    ``` ``` @@ -48,10 +48,10 @@ Something
  • -->something<!--
  • bye -->something else<!--
  • -
    --><!--<script>alert('Escaped!')</script>
    -
    Something
    +
    --><!--<script>alert('Escaped!')</script>
    +
    Something
    ``` ``` diff --git a/test/command/5650.md b/test/command/5650.md index 1e96aeaa4..c333d5bcd 100644 --- a/test/command/5650.md +++ b/test/command/5650.md @@ -5,8 +5,8 @@ a b ``` ^D -
    a
    +
    a
     b
    ```` @@ -17,8 +17,8 @@ a b ``` ^D -
    a
    +
    a
     b
    ```` diff --git a/test/command/5655.md b/test/command/5655.md index 72ad46e5e..e9fb1b628 100644 --- a/test/command/5655.md +++ b/test/command/5655.md @@ -4,8 +4,8 @@ $T_n={n+1 \choose 2}$ ^D

    +alt="T_n={n+1 \choose 2}" title="T_n={n+1 \choose 2}" +class="math inline" />

    ```` ```` @@ -14,7 +14,7 @@ $$T_n={n+1 \choose 2}$$ ^D

    +alt="T_n={n+1 \choose 2}" title="T_n={n+1 \choose 2}" +class="math display" />

    ```` diff --git a/test/ipynb/rank.out.html b/test/ipynb/rank.out.html index a82fe8bbc..44c1fb72d 100644 --- a/test/ipynb/rank.out.html +++ b/test/ipynb/rank.out.html @@ -1,12 +1,12 @@
    -
    import matplotlib.pyplot as plt
    +
    import matplotlib.pyplot as plt
    -
    fig, ax = plt.subplots(figsize=(1, 1), dpi=4)
    +
    fig, ax = plt.subplots(figsize=(1, 1), dpi=4)
     ax.imshow([[0, 1], [2, 3]]);

    you should see this when converting from ipynb to html instead of the image below.

    diff --git a/test/writer.html4 b/test/writer.html4 index 1e255fa70..c8ea04e98 100644 --- a/test/writer.html4 +++ b/test/writer.html4 @@ -595,10 +595,11 @@ href="http://example.com/?foo=1&bar=2">quoted link”.

  • α ∧ ω
  • 223
  • p-Tree
  • -
  • Here’s some display math: $$\frac{d}{dx}f(x)=\lim_{h\to 0}\frac{f(x+h)-f(x)}{h}$$
  • -
  • Here’s one that has a line break in it: α + ω × x2.
  • +
  • Here’s some display math: $$\frac{d}{dx}f(x)=\lim_{h\to +0}\frac{f(x+h)-f(x)}{h}$$
  • +
  • Here’s one that has a line break in it: α + ω × x2.
  • These shouldn’t be math:

      diff --git a/test/writer.html5 b/test/writer.html5 index d8e89b3e2..988fc1da5 100644 --- a/test/writer.html5 +++ b/test/writer.html5 @@ -598,10 +598,11 @@ href="http://example.com/?foo=1&bar=2">quoted link”.

    • α ∧ ω
    • 223
    • p-Tree
    • -
    • Here’s some display math: $$\frac{d}{dx}f(x)=\lim_{h\to 0}\frac{f(x+h)-f(x)}{h}$$
    • -
    • Here’s one that has a line break in it: α + ω × x2.
    • +
    • Here’s some display math: $$\frac{d}{dx}f(x)=\lim_{h\to +0}\frac{f(x+h)-f(x)}{h}$$
    • +
    • Here’s one that has a line break in it: α + ω × x2.

    These shouldn’t be math: