Incorrectly parsing LaTex in page list #2289

Closed
opened 2026-02-05 03:34:30 +03:00 by OVERLORD · 3 comments
Owner

Originally created by @jacobm001 on GitHub (Jun 10, 2021).

Describe the bug

When viewing the chapter listing of a book, I've noticed that some code can be incorrectly parsed as LaTex. In my minimal reproducible example, I've created a page that contains nothing but a title, brief summary, and a code block containing a regular expression.

This displays fine at the page level, but displaying within the page listing causes the contents to display as LaTex.

Steps To Reproduce

Steps to reproduce the behavior:

  1. Create a new page.
  2. Fill the title
  3. Put a code block towards the very top and fill it with text like (\[A-Z\]\[a-z\]+)+Exception
  4. View the page in the chapter listing.

Expected behavior

No LaTex parsing.

Screenshots

Page content and display:

image

Incorrect page listing

image

Your Configuration (please complete the following information):

  • Exact BookStack Version (Found in settings): v21.05.1
  • PHP Version: 7.3.27
  • Hosting Method (Nginx/Apache/Docker): docker - linuxserver/bookstack

Additional context

Originally created by @jacobm001 on GitHub (Jun 10, 2021). **Describe the bug** When viewing the chapter listing of a book, I've noticed that some code can be incorrectly parsed as LaTex. In my minimal reproducible example, I've created a page that contains nothing but a title, brief summary, and a code block containing a regular expression. This displays fine at the page level, but displaying within the page listing causes the contents to display as LaTex. **Steps To Reproduce** Steps to reproduce the behavior: 1. Create a new page. 2. Fill the title 3. Put a code block towards the very top and fill it with text like `(\[A-Z\]\[a-z\]+)+Exception` 4. View the page in the chapter listing. **Expected behavior** No LaTex parsing. **Screenshots** Page content and display: ![image](https://user-images.githubusercontent.com/2245023/121546294-09305b80-c9c0-11eb-8297-4e78452f1fcb.png) Incorrect page listing ![image](https://user-images.githubusercontent.com/2245023/121545988-d4240900-c9bf-11eb-9a0e-95a57325bcc5.png) **Your Configuration (please complete the following information):** - Exact BookStack Version (Found in settings): v21.05.1 - PHP Version: 7.3.27 - Hosting Method (Nginx/Apache/Docker): docker - linuxserver/bookstack **Additional context**
Author
Owner

@jacobm001 commented on GitHub (Jun 10, 2021):

Shortly after producing the MRE and posting here, I remembered I added the custom header below to more easily display math in my notes... so I guess this is my fault. As this doesn't present problems at any other point, I would like to raise the suggestion that we leave the code block tags within the page listing.

<script type="text/javascript" id="MathJax-script" async
  src="https://cdn.jsdelivr.net/npm/mathjax@3/es5/tex-mml-chtml.js">
</script>
@jacobm001 commented on GitHub (Jun 10, 2021): Shortly after producing the MRE and posting here, I remembered I added the custom header below to more easily display math in my notes... so I guess this is my fault. As this doesn't present problems at any other point, I would like to raise the suggestion that we leave the code block tags within the page listing. ```js <script type="text/javascript" id="MathJax-script" async src="https://cdn.jsdelivr.net/npm/mathjax@3/es5/tex-mml-chtml.js"> </script> ```
Author
Owner

@ssddanbrown commented on GitHub (Jun 11, 2021):

Hi @jacobm001, I will therefore close off this issue since we don't do any LaTex parsing by default in BookStack.

I would like to raise the suggestion that we leave the code block tags within the page listing.

I wouldn't want to go down that path as it'll greatly complicate the logic to truncate the content at a fixed length. I think the best way to solve this would be to configure MathJax to only parse within page content (And not all parts of the UI). From my quick testing I believe this can be achieved by adding something like the below before your MathJax script:

<script>
window.MathJax = {
  startup: {
    elements: ['.page-content']
  }
};
</script>
@ssddanbrown commented on GitHub (Jun 11, 2021): Hi @jacobm001, I will therefore close off this issue since we don't do any LaTex parsing by default in BookStack. > I would like to raise the suggestion that we leave the code block tags within the page listing. I wouldn't want to go down that path as it'll greatly complicate the logic to truncate the content at a fixed length. I think the best way to solve this would be to configure MathJax to only parse within page content (And not all parts of the UI). From my quick testing I believe this can be achieved by adding something like the below **_before_** your MathJax script: ```html <script> window.MathJax = { startup: { elements: ['.page-content'] } }; </script> ```
Author
Owner

@jacobm001 commented on GitHub (Jun 11, 2021):

That, actually solved my problem completely. Thank you.

@jacobm001 commented on GitHub (Jun 11, 2021): That, actually solved my problem completely. Thank you.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/BookStack#2289