cosmere icon indicating copy to clipboard operation
cosmere copied to clipboard

Code blocks break <details> rendering

Open ghost opened this issue 2 years ago • 2 comments

Bug Description

Within a details block, rendering of code blocks seems to be broken. Adding an empty line after the opening block breaks the rendering.

How to Reproduce

Works

Input

<details>
<summary>Click here to see build profile </summary>
```xml
<test />
```
</details>

Output

<ac:structured-macro ac:name="expand"><ac:parameter ac:name="title">Click here to see build profile </ac:parameter><ac:rich-text-body><p><code>xml
&lt;test /&gt;</code></p>
</ac:rich-text-body></ac:structured-macro>

Broken

Input

(newline after xml codefences

<details>
<summary>Click here to see build profile </summary>
```xml

<test />
```
</details>

Output

<ac:structured-macro ac:name="expand"><ac:parameter ac:name="title">Click here to see build profile </ac:parameter><ac:rich-text-body><p><code>xml</p>
<p>&lt;test /&gt;</code></p>
</ac:rich-text-body></ac:structured-macro>

ghost avatar Aug 26 '22 15:08 ghost

After playing around with several ideas, I think the best way here is to highlight the error and have the user fix it. Fixing it automatically would mean rewriting the lexer of marked.

Instead, I tried https://www.npmjs.com/package/node-libxml and verifying that the XML is well-formed does the job.

mihaeu avatar Oct 10 '22 07:10 mihaeu

Hello, @mihaeu! The bug is repeated not only in code blocks. If there is an empty line between </summary> and </details> tags, rendering details in Confluence fails.

How to Reproduce

Works

Example 1:

<details>
<summary>example 1</summary>
Some text
</details>

Example 2 (this works, but doesn't work in Gitlab, Github, VsCode, and thus when publishing via site generators):

<details>
<summary>example 2</summary>
```xml
<test />
```
</details>

Broken

Example 1:

<details>
<summary>example 1</summary>

Some text
</details>

Example 2:

<details>
<summary>example 2</summary>
Some text

</details>

Example 3:

<details>
<summary>example 3</summary>

```xml
<test />
```
</details>

Example 4:

<details>
<summary>example 4</summary>
```xml
<test />
```

</details>

Example 5:

<details>
<summary>example 5</summary>
```xml

<test />
```
</details>

But

  1. If I use the <details> tag with no empty lines inside <td> tag:
<td>
<details><summary>example 6</summary>
```xml
<test />
```
</details>
</td>

an error ocurs: image

  1. With empty line:
<td>
<details><summary>example 6</summary>

```xml
<test />
```
</details>
</td>

it looks like this (without dropdown):

image

hudrid avatar Apr 11 '24 11:04 hudrid