From ef8135b4a7cd6d63d49bc25977d015075337c1a6 Mon Sep 17 00:00:00 2001 From: John MacFarlane Date: Thu, 20 Jan 2022 09:17:34 -0800 Subject: 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. --- src/Text/Pandoc/Writers/Blaze.hs | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) (limited to 'src') 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 + " go False mempty content + t | t == " 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 == " ChoiceString -- ^ String to render -- cgit v1.2.3