summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorJohn MacFarlane <jgm@berkeley.edu>2022-01-20 09:17:34 -0800
committerJohn MacFarlane <jgm@berkeley.edu>2022-01-20 09:17:34 -0800
commitef8135b4a7cd6d63d49bc25977d015075337c1a6 (patch)
treeba8d9b83e77951f1da1b0862b6b2a7eab7bca319 /src
parentd9ec95e7abc71a642dd8e53b92f2bd3ae1609f10 (diff)
HTML writer: don't break lines inside code elements.
With the new (default) line wrapping of HTML, in conjunction with the default CSS which includes `code { whitespace: pre-wrap; }`, spurious line breaks could be introduced into inline code. Closes #7858.
Diffstat (limited to 'src')
-rw-r--r--src/Text/Pandoc/Writers/Blaze.hs13
1 files changed, 7 insertions, 6 deletions
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