From a383eef7a6e37fe2b1bf0c416f69d4253f943980 Mon Sep 17 00:00:00 2001 From: Niklas Fasching Date: Fri, 26 Jun 2020 18:53:57 +0200 Subject: [PATCH] html: Remove cosmetic whitespace inside p tags All tags are put on a line by themselves to help with visual diffing. Apparently this extra cosmetic whitespace causes problems inside p tags for ppl who want to use `white-space: pre`. Not much hurt for visual diffing in removing cosmetic whitespace for just p tags and can't think of anything that would break because of this right now. So let's do it and wait for things to break. --- blorg/testdata/public/about.html | 7 +- blorg/testdata/public/post.html | 4 +- org/html_writer.go | 5 +- org/testdata/blocks.html | 77 +++------- org/testdata/captions.html | 13 +- org/testdata/footnotes.html | 77 +++------- org/testdata/footnotes_in_headline.html | 26 +--- org/testdata/headlines.html | 53 ++----- org/testdata/inline.html | 135 +++++----------- org/testdata/keywords.html | 7 +- org/testdata/latex.html | 36 ++--- org/testdata/lists.html | 142 +++++------------ org/testdata/misc.html | 195 +++++++----------------- org/testdata/options.html | 6 +- org/testdata/paragraphs.html | 10 +- 15 files changed, 216 insertions(+), 577 deletions(-) diff --git a/blorg/testdata/public/about.html b/blorg/testdata/public/about.html index 22918e8..9cdf912 100644 --- a/blorg/testdata/public/about.html +++ b/blorg/testdata/public/about.html @@ -24,13 +24,10 @@ -

-About -

+

About

-and some content -

+and some content

diff --git a/blorg/testdata/public/post.html b/blorg/testdata/public/post.html index c800cc4..470962e 100644 --- a/blorg/testdata/public/post.html +++ b/blorg/testdata/public/post.html @@ -24,9 +24,7 @@ -

-some post -

+

some post

diff --git a/org/html_writer.go b/org/html_writer.go index 3a5f97a..bfc002a 100644 --- a/org/html_writer.go +++ b/org/html_writer.go @@ -411,11 +411,8 @@ func (w *HTMLWriter) WriteParagraph(p Paragraph) { return } w.WriteString("

") - if _, ok := p.Children[0].(LineBreak); !ok { - w.WriteString("\n") - } WriteNodes(w, p.Children...) - w.WriteString("\n

\n") + w.WriteString("

\n") } func (w *HTMLWriter) WriteExample(e Example) { diff --git a/org/testdata/blocks.html b/org/testdata/blocks.html index 642dc6d..cf1db87 100644 --- a/org/testdata/blocks.html +++ b/org/testdata/blocks.html @@ -61,27 +61,18 @@ are also supported note that /inline/ *markup* ignored
+

Mongodb is webscale. (source: mongodb-is-web-scale)

-Mongodb is webscale. (source: mongodb-is-web-scale) -

-

-blocks like the quote block parse their content and can contain -

+blocks like the quote block parse their content and can contain

@@ -135,31 +121,21 @@ console.log("Hello World!") -

-this unindented line is outside of the list item -

+

this unindented line is outside of the list item