Extra paragraphs when reusing entire page #2753

Closed
opened 2026-02-05 05:02:01 +03:00 by OVERLORD · 4 comments
Owner

Originally created by @vdngec on GitHub (Apr 15, 2022).

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

Originally created by @vdngec on GitHub (Apr 15, 2022). ### 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](https://user-images.githubusercontent.com/101877780/163540640-22dd0eb0-49fa-4f36-8419-59c9c6c54805.png) ![image](https://user-images.githubusercontent.com/101877780/163540682-5510bc55-c717-4b0f-9554-acf9175968e5.png) ### Browser Details _No response_ ### Exact BookStack Version v22.03.1 ### PHP Version _No response_ ### Hosting Environment Uberspace
OVERLORD added the 🐛 Bug label 2026-02-05 05:02:01 +03:00
Author
Owner

@ssddanbrown commented on GitHub (Apr 17, 2022):

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 commented on GitHub (Apr 17, 2022): 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.
Author
Owner

@sbrosl commented on GitHub (Dec 12, 2022):

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 commented on GitHub (Dec 12, 2022): 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!
Author
Owner

@ChriFo commented on GitHub (Jun 30, 2023):

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 commented on GitHub (Jun 30, 2023): My workaround is the following snippet added to `Custom HTML Head Content` in `Settings > Customization`: ```html <style> /* remove empty p on macro use */ p:empty { display: none } </style> ```
Author
Owner

@ssddanbrown commented on GitHub (Nov 28, 2023):

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 commented on GitHub (Nov 28, 2023): 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.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/BookStack#2753