diff --git a/src/Text/Pandoc/Writers/Blaze.hs b/src/Text/Pandoc/Writers/Blaze.hs
index 692e89e27..ff6d1da87 100644
--- a/src/Text/Pandoc/Writers/Blaze.hs
+++ b/src/Text/Pandoc/Writers/Blaze.hs
@@ -30,9 +30,13 @@ layoutMarkup = go True mempty
        in literal open'
             <> attrs
             <> char '>'
-            <> (if allowsWrap open'
-                   then go wrap mempty content
-                   else flush $ go False mempty content)
+            <> (case open' of
+                  "<code" -> go False mempty content
+                  t | t == "<pre" ||
+                      t == "<style" ||
+                      t == "<script" ||
+                      t == "<textarea" -> flush $ go False mempty content
+                    | otherwise -> go wrap mempty content)
             <> literal (getText close)
     go wrap attrs (CustomParent tag content) =
         char '<'
@@ -77,9 +81,6 @@ layoutMarkup = go True mempty
     go _ _ (Empty _) = mempty
     space' wrap = if wrap then space else char ' '
 
-allowsWrap :: T.Text -> Bool
-allowsWrap t =
-  not (t == "<pre" || t == "<style" || t == "<script" || t == "<textarea")
 
 fromChoiceString :: Bool                  -- ^ Allow wrapping
                  -> ChoiceString          -- ^ String to render
diff --git a/test/command/3534.md b/test/command/3534.md
index 41bf9a5ff..1ba332683 100644
--- a/test/command/3534.md
+++ b/test/command/3534.md
@@ -3,8 +3,7 @@
 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>
+class="sourceCode java"><span class="kw">public</span> <span class="kw">class</span> MyClass</code>.</p>
 
 ```
 
@@ -12,8 +11,8 @@ class="kw">class</span> MyClass</code>.</p>
 % pandoc -f latex -t html
 I want to explain the interface of \lstinline{public class MyClass}.
 ^D
-<p>I want to explain the interface of <code>public class
-MyClass</code>.</p>
+<p>I want to explain the interface of
+<code>public class MyClass</code>.</p>
 
 ```
 
@@ -47,8 +46,7 @@ I want to explain the interface of \lstinline[language=Java]{public class MyClas
 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>
+class="sourceCode java"><span class="kw">public</span> <span class="kw">class</span> MyClass</code>.</p>
 
 ```
 
@@ -57,8 +55,7 @@ class="kw">class</span> MyClass</code>.</p>
 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>
+class="sourceCode java"><span class="kw">public</span> <span class="kw">class</span> MyClass</code>.</p>
 
 ```
 
diff --git a/test/command/7858.md b/test/command/7858.md
new file mode 100644
index 000000000..dc2f107ec
--- /dev/null
+++ b/test/command/7858.md
@@ -0,0 +1,6 @@
+```
+% pandoc -t html --columns=50 --wrap=auto
+`neuth asontue stheuosnt aeosunth asnoetuh asneotuh snatehou snatoehu sntahe ousntahoe unstaheou sntaheou aoeu sthoeu sntaoeusnth ansoetuhs atoeuh saonteu`
+^D
+<p><code>neuth asontue stheuosnt aeosunth asnoetuh asneotuh snatehou snatoehu sntahe ousntahoe unstaheou sntaheou aoeu sthoeu sntaoeusnth ansoetuhs atoeuh saonteu</code></p>
+```