mihaeu / cosmere

Sync your markdown files to Confluence
https://mihaeu.github.io/cosmere/
MIT License
36 stars 10 forks source link

Code blocks break <details> rendering #34

Open ghost opened 2 years ago

ghost commented 2 years ago

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>
mihaeu commented 2 years ago

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.

hudrid commented 7 months ago

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 />

## Broken
Example 1:
```html
<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 />

Example 4:
````html
<details>
<summary>example 4</summary>
```xml
<test />

Example 5:
````html
<details>
<summary>example 5</summary>
```xml

<test />

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

an error ocurs:
![image](https://github.com/mihaeu/cosmere/assets/55594483/be7fb6b0-a2ad-41f0-809c-5699062338da)

2. With empty line:
````html
<td>
<details><summary>example 6</summary>

```xml
<test />


it looks like this (without dropdown):

![image](https://github.com/mihaeu/cosmere/assets/55594483/f2df3c28-f0e9-4704-9b12-a16dbd120105)