BookStack icon indicating copy to clipboard operation
BookStack copied to clipboard

Extra paragraphs when reusing entire page

Open vdngec opened this issue 3 years ago • 1 comments

Describe the Bug

When reusing the content of an entire page, extra paragrapshs are added before and after the content.

Steps to Reproduce

  1. Edit a page
  2. Reuse the content of an entire page

Expected Behaviour

No extra paragraphs should be added around the contents. The page should be reused directly without blanks before and after

Screenshots or Additional Context

image image

Browser Details

No response

Exact BookStack Version

v22.03.1

PHP Version

No response

Hosting Environment

Uberspace

vdngec avatar Apr 15 '22 07:04 vdngec

Thanks for reporting @vdngec. Can confirm this behaviour. Is due to this system causing nested p tags which are then split out by the browser in an attempt to auto-correct the structure.

Will be tricky to properly address, as will not a more intensive parser solution, especially so when the include tag may be surrounded or within other sections. Can be worked around by manually altering the wrapping tag to be a div instead.

ssddanbrown avatar Apr 17 '22 13:04 ssddanbrown

Hi,

I'd like to +1 and report experiencing the same issue. I've also noticed that the collapsible block seems to add similar spacing at the beginning and end if re-using page content in a collapsible block (for example a collapsible block containing just {{@4}} and nothing else will have extra spacing at the top and bottom that is not present on page @4 and that is not present in the collapsible block)

We are using v22.11

Thanks!

sbrosl avatar Dec 12 '22 20:12 sbrosl

My workaround is the following snippet added to Custom HTML Head Content in Settings > Customization:

<style>
/* remove empty p on macro use */
p:empty {
  display: none
}
</style>

ChriFo avatar Jun 30 '23 07:06 ChriFo

Within #4688 I've significantly changed how includes are handled. They're now parsed and rendered in a DOM-aware manner, and there's now logic to promote/split/clean-up content to handle it a bit better, including promoting block content to land outside of paragraph tags. The implemented logic is quite specific so somewhat limited (Following all rules of HTML would be very complex) but it should now avoid issues like this in the vast majority of cases.

The changes added will be part of the next feature release.

ssddanbrown avatar Nov 27 '23 22:11 ssddanbrown