# Rendering question about a list item containing a row starting with an escaped character

**URL:** <https://forum.xwiki.org/t/rendering-question-about-a-list-item-containing-a-row-starting-with-an-escaped-character/10286>\
**Category:** Help / Discuss\
**Tags:** rendering\
**Created:** [May 4, 2022, 1:11pm UTC](https://forum.xwiki.org/t/rendering-question-about-a-list-item-containing-a-row-starting-with-an-escaped-character/10286 "2022-05-04T13:11:27Z")\
**Posts on this page:** 9\
**Page:** 1

<div class="post-metadata">

**Author:** ![slauriere](https://forum.xwiki.org/user_avatar/forum.xwiki.org/slauriere/32/4425_2.png) [@slauriere](https://forum.xwiki.org/u/slauriere)\
**Post date:** [May 4, 2022, 1:11pm UTC](https://forum.xwiki.org/t/rendering-question-about-a-list-item-containing-a-row-starting-with-an-escaped-character/10286/1 "2022-05-04T13:11:27Z")

</div>

Hi everyone,

I notice that a roundtrip parsing and rendering of the text below in syntax xwiki/2.1 seems to remove the escaped character `~=`, hence turning some simple text to a title:

```auto
* Item
~= Test

```

Here’s a [demo link](https://rendering.xwiki.org/xwiki/bin/view/Main/WebHome?inputsyntax=xwiki%2F2.1&outputsyntax=xwiki%2F2.1&input=*+Item%0D%0A%7E%3D+Test%0D%0A%0D%0A%0D%0A%0D%0A%0D%0A%0D%0A%0D%0A%0D%0A%0D%0A%0D%0A#HDemo) on [rendering.xwiki.org](http://rendering.xwiki.org).

Is there anything wrong with this syntax? Or is it an issue with the rendering module?

---

<div class="post-metadata">

**Author:** ![vmassol](https://forum.xwiki.org/user_avatar/forum.xwiki.org/vmassol/32/6_2.png) [@vmassol](https://forum.xwiki.org/u/vmassol)\
**Post date:** [May 4, 2022, 1:17pm UTC](https://forum.xwiki.org/t/rendering-question-about-a-list-item-containing-a-row-starting-with-an-escaped-character/10286/2 "2022-05-04T13:17:30Z")

</div>

I’d day it’s a bug. It looks to me a bug of the heading parsing since a heading should probably require 2 NLs before it as a standalone element. If this is not correct then it’s an escaping bug.

---

<div class="post-metadata">

**Author:** ![lucaa](https://forum.xwiki.org/user_avatar/forum.xwiki.org/lucaa/32/2537_2.png) [@lucaa](https://forum.xwiki.org/u/lucaa)\
**Post date:** [May 4, 2022, 3:05pm UTC](https://forum.xwiki.org/t/rendering-question-about-a-list-item-containing-a-row-starting-with-an-escaped-character/10286/3 "2022-05-04T15:05:52Z")

</div>

> [@vmassol](#):
>
> It looks to me a bug of the heading parsing

Actually, I wrote a test in a local checkout of the rendering module, in the syntax 2.0 thing (I hope I wrote it right) and according to that test this:

```auto
* Item 1
~=~= Title

```

gets parsed into

```auto
  <list>
    <listItem>
      <word>Item</word>
      <space/>
      <word>1</word>
      <newLine/>
      <specialSymbol>=</specialSymbol>
      <specialSymbol>=</specialSymbol>
      <space/>
      <word>Title</word>
    </listItem>
  </list>

```

which is what’s expected.

Then, the content above gets rendered back into:

```auto
* Item 1
== Title

```

And of course parsing this back parses it into a heading - which yes, would require 2 NLs, indeed.

The question, to me, is why the initial re-rendering doesn’t render it back escaped, shouldn’t it? I mean shouldn’t it not render wiki syntax at all? or that depends on the context (and in this case the context is considered to be a context where the heading is not valid so it doesn’t need to escape the heading syntax)?

---

<div class="post-metadata">

**Author:** ![slauriere](https://forum.xwiki.org/user_avatar/forum.xwiki.org/slauriere/32/4425_2.png) [@slauriere](https://forum.xwiki.org/u/slauriere)\
**Post date:** [May 4, 2022, 3:11pm UTC](https://forum.xwiki.org/t/rendering-question-about-a-list-item-containing-a-row-starting-with-an-escaped-character/10286/4 "2022-05-04T15:11:28Z")

</div>

I just created [Loading...](https://jira.xwiki.org/browse/XRENDERING-661). Feel free to amend the title or description to make it closer to the actual bug if needed.

---

<div class="post-metadata">

**Author:** ![vmassol](https://forum.xwiki.org/user_avatar/forum.xwiki.org/vmassol/32/6_2.png) [@vmassol](https://forum.xwiki.org/u/vmassol)\
**Post date:** [May 4, 2022, 3:11pm UTC](https://forum.xwiki.org/t/rendering-question-about-a-list-item-containing-a-row-starting-with-an-escaped-character/10286/5 "2022-05-04T15:11:40Z")

</div>

There are 2 options to fix the bug:

- Fix the escaping in the rendering
- Fix the heading parsing (in the syntax parser) to recognize headings only if there are 2 NLs before it (so that the `==` doesn’t get parsed as a heading). In this case there’s no need to escape anything in the rendering.

Logically, standalone blocks should require 2 NLs before them, which is why I think it would be better fix but I haven’t thought about all possible consequences yet…

---

<div class="post-metadata">

**Author:** ![slauriere](https://forum.xwiki.org/user_avatar/forum.xwiki.org/slauriere/32/4425_2.png) [@slauriere](https://forum.xwiki.org/u/slauriere)\
**Post date:** [May 4, 2022, 3:13pm UTC](https://forum.xwiki.org/t/rendering-question-about-a-list-item-containing-a-row-starting-with-an-escaped-character/10286/6 "2022-05-04T15:13:54Z")

</div>

Just wondering why we expect two new lines before a heading. [This test](https://github.com/xwiki/xwiki-rendering/blob/master/xwiki-rendering-integration-tests/src/test/resources/simple/section/section3.test) does not seem to expect this, or maybe I’m misunderstanding?

---

<div class="post-metadata">

**Author:** ![vmassol](https://forum.xwiki.org/user_avatar/forum.xwiki.org/vmassol/32/6_2.png) [@vmassol](https://forum.xwiki.org/u/vmassol)\
**Post date:** [May 4, 2022, 3:14pm UTC](https://forum.xwiki.org/t/rendering-question-about-a-list-item-containing-a-row-starting-with-an-escaped-character/10286/7 "2022-05-04T15:14:29Z")

</div>

I never said we expect it, quite the opposite, we don’t ATM! And that’s a bug IMO (it’s debatable but other standalone elements require 2 NLs)

---

<div class="post-metadata">

**Author:** ![vmassol](https://forum.xwiki.org/user_avatar/forum.xwiki.org/vmassol/32/6_2.png) [@vmassol](https://forum.xwiki.org/u/vmassol)\
**Post date:** [May 4, 2022, 3:16pm UTC](https://forum.xwiki.org/t/rendering-question-about-a-list-item-containing-a-row-starting-with-an-escaped-character/10286/8 "2022-05-04T15:16:17Z")

</div>

> [@vmassol](#):
>
> Logically, standalone blocks should require 2 NLs before them, which is why I think it would be better fix but I haven’t thought about all possible consequences yet…

Well, an obvious one is that it would break a lot of existing content so we wouldn’t be able to change that in the current syntaxes (would require a `xwiki/2.2` one). Thus for the existing syntax the fix is to fix the missing escape in the rendering.

---

<div class="post-metadata">

**Author:** ![tmortagne](https://forum.xwiki.org/user_avatar/forum.xwiki.org/tmortagne/32/4930_2.png) [@tmortagne](https://forum.xwiki.org/u/tmortagne)\
**Post date:** [May 4, 2022, 3:28pm UTC](https://forum.xwiki.org/t/rendering-question-about-a-list-item-containing-a-row-starting-with-an-escaped-character/10286/9 "2022-05-04T15:28:36Z")

</div>

> [@vmassol](#):
>
> Fix the escaping in the rendering

This needs to be fixed anyway since you could have the same events from a different source.
