Prevent code blocks breaking when used in include system #1974

Closed
opened 2026-02-05 02:22:17 +03:00 by OVERLORD · 7 comments
Owner

Originally created by @noxtras on GitHub (Dec 12, 2020).

Describe the bug
Reusing Page Content, Include Tags - code

Steps To Reproduce
Steps to reproduce the behavior:

  1. you can't select text and code, or just code alone, to include as tags into another page.

Your Configuration (please complete the following information):

  • Exact BookStack Version (Found in settings): v0.30.5
  • PHP Version: 7.4
  • Hosting Method (Nginx/Apache/Docker): apache
Originally created by @noxtras on GitHub (Dec 12, 2020). **Describe the bug** Reusing Page Content, Include Tags - code **Steps To Reproduce** Steps to reproduce the behavior: 1. you can't select text and code, or just code alone, to include as tags into another page. **Your Configuration (please complete the following information):** - Exact BookStack Version (Found in settings): v0.30.5 - PHP Version: 7.4 - Hosting Method (Nginx/Apache/Docker): apache
OVERLORD added the 🐛 Bug label 2026-02-05 02:22:17 +03:00
Author
Owner

@ssddanbrown commented on GitHub (Dec 12, 2020):

Hi @noxtras, Are you attempting to include content with inline code or are you attempting to include an entire code block (One with line numbers and syntax highlighting).

@ssddanbrown commented on GitHub (Dec 12, 2020): Hi @noxtras, Are you attempting to include content with inline code or are you attempting to include an entire code block (One with line numbers and syntax highlighting).
Author
Owner

@noxtras commented on GitHub (Dec 12, 2020):

Hi, I have tried to include some text and a code block (the whole pre). I also tried editing the page source and add a div and span with an ID to wrap it up and add it to the other page, but no luck, it just won't save it.

@noxtras commented on GitHub (Dec 12, 2020): Hi, I have tried to include some text and a code block (the whole pre). I also tried editing the page source and add a div and span with an ID to wrap it up and add it to the other page, but no luck, it just won't save it.
Author
Owner

@ssddanbrown commented on GitHub (Dec 12, 2020):

Code blocks are a block-level element so you won't be able to include both text and a codeblock using a single include tag unless you're including the whole page.

For the includes of just a code block, we might have to make a tweak to how they're included in so that the whole block is included and not just the contents (We already do this for tables and lists).

@ssddanbrown commented on GitHub (Dec 12, 2020): Code blocks are a block-level element so you won't be able to include both text and a codeblock using a single include tag unless you're including the whole page. For the includes of just a code block, we might have to make a tweak to how they're included in so that the whole block is included and not just the contents (We already do this for tables and lists).
Author
Owner

@noxtras commented on GitHub (Dec 12, 2020):

I'm OK with two includes, Including the whole code block would be amazing.
Question: What stops me from defining my own HTML block to be included? Like 'edit source' and put the ID in manually for more content.

On a second node, I think that including everything under a header would be nice to have, too.

@noxtras commented on GitHub (Dec 12, 2020): I'm OK with two includes, Including the whole code block would be amazing. Question: What stops me from defining my own HTML block to be included? Like 'edit source' and put the ID in manually for more content. On a second node, I think that including everything under a header would be nice to have, too.
Author
Owner

@ssddanbrown commented on GitHub (Dec 12, 2020):

Question: What stops me from defining my own HTML block to be included? Like 'edit source' and put the ID in manually for more content.

You can certainly attempt this. If using the WYSIWYG editor you'll find the editor may strip things back to what it supported. The Markdown editor is more liberal in accepting HTML content. Then BookStack will do some level of filtering when content is rendered (Mostly due to security) which could affect things.

On a second node, I think that including everything under a header would be nice to have, too.

I could see that, but it will start to make the logic more complex, while the include system is something I don't want to make too complex as it'd be little utilised in most cases while introducing side affects.

@ssddanbrown commented on GitHub (Dec 12, 2020): > Question: What stops me from defining my own HTML block to be included? Like 'edit source' and put the ID in manually for more content. You can certainly attempt this. If using the WYSIWYG editor you'll find the editor may strip things back to what it supported. The Markdown editor is more liberal in accepting HTML content. Then BookStack will do some level of filtering when content is rendered (Mostly due to security) which could affect things. > On a second node, I think that including everything under a header would be nice to have, too. I could see that, but it will start to make the logic more complex, while the include system is something I don't want to make too complex as it'd be little utilised in most cases while introducing side affects.
Author
Owner

@noxtras commented on GitHub (Dec 12, 2020):

Thank you for the feedback.

@noxtras commented on GitHub (Dec 12, 2020): Thank you for the feedback.
Author
Owner

@ssddanbrown commented on GitHub (Nov 15, 2021):

I have now updated the content include system to include code blocks along with their top-level pre tags.
This change was made in e29d03ae76 and will be part of the next feature release.
Will therefore close this off.

@ssddanbrown commented on GitHub (Nov 15, 2021): I have now updated the content include system to include code blocks along with their top-level pre tags. This change was made in e29d03ae769db2bc1fe02520862c26d04cc5ea91 and will be part of the next feature release. Will therefore close this off.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/BookStack#1974