Welcome to Codidact Meta!
Codidact Meta is the meta-discussion site for the Codidact community network and the Codidact software. Whether you have bug reports or feature requests, support questions or rule discussions that touch the whole network – this is the site for you.
Post History
Main underlying cause In addition to the delimiters I'm accustomed to using (double dollar signs to start and end a MathJax block, and single dollar signs to start and end inline MathJax) there ar...
Answer
#2: Post edited
- ## Main underlying cause
- In addition to the delimiters I'm accustomed to using (double dollar signs to start and end a MathJax block, and single dollar signs to start and end inline MathJax) there are also escaped square brackets and parentheses, which are enabled by default. These are currently active for Codidact's use of MathJax, leading to unexpected formatting of text not intended to be rendered as MathJax.
- This post is intended for understanding, not to express an opinion on what action to take. Please post a separate answer if you want to see the defaults changed, or kept the same, or any other approach. You could also mention whether your suggested approach should be applied to all Codidact communities that have MathJax enabled, or differently to different communities.
- See also [MathJax configuration](https://docs.mathjax.org/en/latest/web/configuration.html).
- ## Details
- The rest of this post is finer detail on why things look different than might be expected.
- ### Contrasting the question page and list page
Here is the question Michael mentions, in its own question page where the bug does not show, followed by the same question in a list page (in this case the tag page for "regex"), which shows the bug.- #### The question alone (rendered correctly)
- > 
- #### The question in a list (rendered incorrectly)
- > 
- ### Observations
- Experimenting a little in a development version of the site has shown the reason for the bug only appearing in list pages, and not on the individual question page. Putting the problematic string in a code block suppresses the rendering of MathJax, allowing the string to be rendered correctly in the question page. In list pages, the preview of the question omits code blocks, rendering the string as ordinary text. This allows MathJax to process the string, so the bug shows up.
- If the code block is edited out (leaving the same regex but not in a code block) then the bug shows in the individual question page too. Here is a screenshot from the development version showing the same question without the code block:
- > 
- This now closely resembles the incorrect rendering in the list page. There are two differences, both of which can be explained.
- #### Newlines
- In the modified question, the strings in parentheses before and after the part incorrectly rendered as MathJax are both on their own line, whereas in the list page they are on the same line as the surrounding text. The reason for this is that the list page question preview converts newlines to spaces, so that the preview is not split into paragraphs. The only part of the preview that breaks onto new lines is the part rendered by MathJax. For text that is intended to be displayed as MathJax, this is correct behaviour.
- #### Missing asterisks
- In the modified question the parentheses contain only a full stop / period (`.`), whereas in the list page they also contain an asterisk. The reason for this is that the list page suppresses Markdown formatting. In the question page, text surrounded by asterisks is rendered as *italics* (note that the first closing parenthesis and the second opening parenthesis are leaning to the right). In the list page, the asterisks remain asterisks, with no italics applied.
- ## Steps to reproduce
- It seems that only escaped square brackets or parentheses are necessary to trigger the bug. If they are empty they are rendered as square brackets or parentheses, but otherwise they are not rendered and their content is rendered as MathJax (as a block or inline respectively).
- ### Square brackets for a MathJax block
- 1. In a new or edited question, enter the string `\[a\]`. This does not need to be separated by newlines or spaces. It can even be in the middle of a word.
- 2. In the editor preview, notice that the "a" is rendered on its own line as MathJax.
- 3. After saving, notice that the question page shows the same bug.
- 4. In the question list, notice that the preview shows the same bug.
- ### Parentheses for inline MathJax
- 1. In a new or edited question, enter the string `\(a\)`. This does not need to be separated by newlines or spaces. It can even be in the middle of a word.
- 2. In the editor preview, notice that the "a" is rendered inline as MathJax.
- 3. After saving, notice that the question page shows the same bug.
- 4. In the question list, notice that the preview shows the same bug.
- The "a" can be replaced by anything with similar results, even a space.
- ## Not really a bug
- Since this is how MathJax is configured to behave by default, this is intended behaviour *for MathJax*. If it is considered a bug for Codidact, then the solution may be to change the configuration to something other than the default. This answer is not intended to make a decision on that, but simply to highlight the possibility.
- ## Main underlying cause
- In addition to the delimiters I'm accustomed to using (double dollar signs to start and end a MathJax block, and single dollar signs to start and end inline MathJax) there are also escaped square brackets and parentheses, which are enabled by default. These are currently active for Codidact's use of MathJax, leading to unexpected formatting of text not intended to be rendered as MathJax.
- This post is intended for understanding, not to express an opinion on what action to take. Please post a separate answer if you want to see the defaults changed, or kept the same, or any other approach. You could also mention whether your suggested approach should be applied to all Codidact communities that have MathJax enabled, or differently to different communities.
- See also [MathJax configuration](https://docs.mathjax.org/en/latest/web/configuration.html).
- ## Details
- The rest of this post is finer detail on why things look different than might be expected.
- ### Contrasting the question page and list page
- Here is the question Michael mentions, in its own question page where the bug does not show, followed by the same question in a list page (in this case the tag page for "regex", but question list pages and search results pages are affected in the same way), which shows the bug.
- #### The question alone (rendered correctly)
- > 
- #### The question in a list (rendered incorrectly)
- > 
- ### Observations
- Experimenting a little in a development version of the site has shown the reason for the bug only appearing in list pages, and not on the individual question page. Putting the problematic string in a code block suppresses the rendering of MathJax, allowing the string to be rendered correctly in the question page. In list pages, the preview of the question omits code blocks, rendering the string as ordinary text. This allows MathJax to process the string, so the bug shows up.
- If the code block is edited out (leaving the same regex but not in a code block) then the bug shows in the individual question page too. Here is a screenshot from the development version showing the same question without the code block:
- > 
- This now closely resembles the incorrect rendering in the list page. There are two differences, both of which can be explained.
- #### Newlines
- In the modified question, the strings in parentheses before and after the part incorrectly rendered as MathJax are both on their own line, whereas in the list page they are on the same line as the surrounding text. The reason for this is that the list page question preview converts newlines to spaces, so that the preview is not split into paragraphs. The only part of the preview that breaks onto new lines is the part rendered by MathJax. For text that is intended to be displayed as MathJax, this is correct behaviour.
- #### Missing asterisks
- In the modified question the parentheses contain only a full stop / period (`.`), whereas in the list page they also contain an asterisk. The reason for this is that the list page suppresses Markdown formatting. In the question page, text surrounded by asterisks is rendered as *italics* (note that the first closing parenthesis and the second opening parenthesis are leaning to the right). In the list page, the asterisks remain asterisks, with no italics applied.
- ## Steps to reproduce
- It seems that only escaped square brackets or parentheses are necessary to trigger the bug. If they are empty they are rendered as square brackets or parentheses, but otherwise they are not rendered and their content is rendered as MathJax (as a block or inline respectively).
- ### Square brackets for a MathJax block
- 1. In a new or edited question, enter the string `\[a\]`. This does not need to be separated by newlines or spaces. It can even be in the middle of a word.
- 2. In the editor preview, notice that the "a" is rendered on its own line as MathJax.
- 3. After saving, notice that the question page shows the same bug.
- 4. In the question list, notice that the preview shows the same bug.
- ### Parentheses for inline MathJax
- 1. In a new or edited question, enter the string `\(a\)`. This does not need to be separated by newlines or spaces. It can even be in the middle of a word.
- 2. In the editor preview, notice that the "a" is rendered inline as MathJax.
- 3. After saving, notice that the question page shows the same bug.
- 4. In the question list, notice that the preview shows the same bug.
- The "a" can be replaced by anything with similar results, even a space.
- ## Not really a bug
- Since this is how MathJax is configured to behave by default, this is intended behaviour *for MathJax*. If it is considered a bug for Codidact, then the solution may be to change the configuration to something other than the default. This answer is not intended to make a decision on that, but simply to highlight the possibility.
#1: Initial revision
## Main underlying cause In addition to the delimiters I'm accustomed to using (double dollar signs to start and end a MathJax block, and single dollar signs to start and end inline MathJax) there are also escaped square brackets and parentheses, which are enabled by default. These are currently active for Codidact's use of MathJax, leading to unexpected formatting of text not intended to be rendered as MathJax. This post is intended for understanding, not to express an opinion on what action to take. Please post a separate answer if you want to see the defaults changed, or kept the same, or any other approach. You could also mention whether your suggested approach should be applied to all Codidact communities that have MathJax enabled, or differently to different communities. See also [MathJax configuration](https://docs.mathjax.org/en/latest/web/configuration.html). ## Details The rest of this post is finer detail on why things look different than might be expected. ### Contrasting the question page and list page Here is the question Michael mentions, in its own question page where the bug does not show, followed by the same question in a list page (in this case the tag page for "regex"), which shows the bug. #### The question alone (rendered correctly) >  #### The question in a list (rendered incorrectly) >  ### Observations Experimenting a little in a development version of the site has shown the reason for the bug only appearing in list pages, and not on the individual question page. Putting the problematic string in a code block suppresses the rendering of MathJax, allowing the string to be rendered correctly in the question page. In list pages, the preview of the question omits code blocks, rendering the string as ordinary text. This allows MathJax to process the string, so the bug shows up. If the code block is edited out (leaving the same regex but not in a code block) then the bug shows in the individual question page too. Here is a screenshot from the development version showing the same question without the code block: >  This now closely resembles the incorrect rendering in the list page. There are two differences, both of which can be explained. #### Newlines In the modified question, the strings in parentheses before and after the part incorrectly rendered as MathJax are both on their own line, whereas in the list page they are on the same line as the surrounding text. The reason for this is that the list page question preview converts newlines to spaces, so that the preview is not split into paragraphs. The only part of the preview that breaks onto new lines is the part rendered by MathJax. For text that is intended to be displayed as MathJax, this is correct behaviour. #### Missing asterisks In the modified question the parentheses contain only a full stop / period (`.`), whereas in the list page they also contain an asterisk. The reason for this is that the list page suppresses Markdown formatting. In the question page, text surrounded by asterisks is rendered as *italics* (note that the first closing parenthesis and the second opening parenthesis are leaning to the right). In the list page, the asterisks remain asterisks, with no italics applied. ## Steps to reproduce It seems that only escaped square brackets or parentheses are necessary to trigger the bug. If they are empty they are rendered as square brackets or parentheses, but otherwise they are not rendered and their content is rendered as MathJax (as a block or inline respectively). ### Square brackets for a MathJax block 1. In a new or edited question, enter the string `\[a\]`. This does not need to be separated by newlines or spaces. It can even be in the middle of a word. 2. In the editor preview, notice that the "a" is rendered on its own line as MathJax. 3. After saving, notice that the question page shows the same bug. 4. In the question list, notice that the preview shows the same bug. ### Parentheses for inline MathJax 1. In a new or edited question, enter the string `\(a\)`. This does not need to be separated by newlines or spaces. It can even be in the middle of a word. 2. In the editor preview, notice that the "a" is rendered inline as MathJax. 3. After saving, notice that the question page shows the same bug. 4. In the question list, notice that the preview shows the same bug. The "a" can be replaced by anything with similar results, even a space. ## Not really a bug Since this is how MathJax is configured to behave by default, this is intended behaviour *for MathJax*. If it is considered a bug for Codidact, then the solution may be to change the configuration to something other than the default. This answer is not intended to make a decision on that, but simply to highlight the possibility.