Repository: Avaiga/taipy

Issue:
[🐛 BUG] Issue with center tag
### What went wrong? 🤔

Using center tags along with visual elements will break the UI.

```
--- 1 warning(s) were found for page '/' in variable 'md' ---
 - Warning 1: Missing leading pipe '|' in opening tag line 2: '<center> <|Hello|text|> </center>'.
--------------------------------------------------------------
```

The workaround is to:

```
md = """
<center> <|Hello|text|> </center>
"""
```

->

```
md = """
<center>
<|Hello|text|>
</center>
"""
```

### Expected Behavior

It shouldn't break like in 3.1 and should center the viz element. It should be backported.

### Steps to Reproduce Issue

```python
from taipy import Gui

md = """
<center> <|Hello|text|> </center>
"""

Gui(md).run()
```

### Screenshots

![image](https://github.com/user-attachments/assets/7b1fe943-e595-4e42-8433-2a634580266f)

### Version of Taipy

4.0

### Acceptance Criteria

- [ ] A unit test reproducing the bug is added.
- [ ] Any new code is covered by a unit tested.
- [ ] Check code coverage is at least 90%.
- [ ] The bug reporter validated the fix.
- [ ] Related issue(s) in taipy-doc are created for documentation and Release Notes are updated.


### Code of Conduct

- [X] I have checked the [existing issues](https://github.com/Avaiga/taipy/issues?q=is%3Aissue+).
- [ ] I am willing to work on this issue (optional)

Hints from issue comments:
@naaa760: Hello @FlorianJacta 
I am sorry the screenshot is not visible.@FlorianJacta: It is @naaa760 . This is the screenshot; there is nothing when there should be something@jrobinAV: ThIs looks like a markdown parsing issue and not a center tag issue.@kiranraoboinapally: @FlorianJacta 

from taipy import Gui

md = """
<center>
<|Hello|text|>
</center>
"""

Gui(md).run()

Try this@FredLL-Avaiga: [center tag is not supported in HTML5](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/center)

but I'll look into it

Solution patch:
diff --git a/taipy/gui/_renderers/_markdown/preproc.py b/taipy/gui/_renderers/_markdown/preproc.py
index d819074be..2f5a4f7de 100644
--- a/taipy/gui/_renderers/_markdown/preproc.py
+++ b/taipy/gui/_renderers/_markdown/preproc.py
@@ -61,7 +61,7 @@ class _Preprocessor(MdPreprocessor):
     __PROPERTY_RE = re.compile(r"((?:don'?t|not?)\s+)?([a-zA-Z][\.a-zA-Z_$0-9]*(?:\[(?:.*?)\])?)\s*(?:=(.*))?$")
 
     # Error syntax detection regex
-    __MISSING_LEADING_PIPE_RE = re.compile(r"^<[^|](.*?)\|>")
+    __MISSING_LEADING_PIPE_RE = re.compile(r"^<[^|]([^>]*?)\|>")
 
     _gui: "Gui"
 


Test patch:
diff --git a/tests/gui/renderers/test_md_parsing.py b/tests/gui/renderers/test_md_parsing.py
index 62877cc34..b5d955646 100644
--- a/tests/gui/renderers/test_md_parsing.py
+++ b/tests/gui/renderers/test_md_parsing.py
@@ -52,3 +52,9 @@ def test_md_link(gui: Gui, helpers):
     md_string = "[content](link)"
     expected_list = ["<a", 'href="link"', "content</a>"]
     helpers.test_control_md(gui, md_string, expected_list)
+
+
+def test_html_in_md(gui: Gui, helpers):
+    md_string = "<center> <|Hello|text|> </center>"
+    expected_list = ["<center>", "<div", "Hello", "</div>", "</center>"]
+    helpers.test_control_md(gui, md_string, expected_list)