Repository: Avaiga/taipy
Pull request: fix pipe warning (#467)
Resolve #467 

Problem statement:
Missing pipe warning should be more explicit
When a user writes a visual element with a missing pipe at the end:

```python
page = "<|{data}|table|style[questions]=style_questions>"
```

The page fails to display the element (which is normal) but prompts the user with the following warning:
```
--- 1 warning(s) were found for page '/' in variable 'page' ---
 - Warning 1: Invalid tag name 'table' in line 1.
```

This warning is confusing and should instead suggest that the syntax of the visual element might be incorrect

Hints from issue discussion:

Commit message: Merge branch 'develop' into feature/gui-fix-pipe-warning

Patch to review:
diff --git a/taipy/gui/_renderers/_markdown/preproc.py b/taipy/gui/_renderers/_markdown/preproc.py
index 9b43a99a9f..a1ac7c4c9b 100644
--- a/taipy/gui/_renderers/_markdown/preproc.py
+++ b/taipy/gui/_renderers/_markdown/preproc.py
@@ -60,6 +60,9 @@ class _Preprocessor(MdPreprocessor):
     #  Note 2: Space characters after the equal sign are significative
     __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"<[^|](.*?)\|>")
+
     _gui: "Gui"
 
     @staticmethod
@@ -72,10 +75,18 @@ def _make_prop_pair(self, prop_name: str, prop_value: str) -> Tuple[str, str]:
         # Un-escape pipe character in property value
         return (prop_name, prop_value.replace("\\|", "|"))
 
+    def _validate_line(self, line: str, line_count: int) -> bool:
+        if _Preprocessor.__MISSING_LEADING_PIPE_RE.search(line) is not None:
+            _warn(f"Missing leading pipe '|' in opening tag line {line_count}: '{line}'.")
+            return False
+        return True
+
     def run(self, lines: List[str]) -> List[str]:
         new_lines = []
         tag_stack = []
         for line_count, line in enumerate(lines, start=1):
+            if not self._validate_line(line, line_count):
+                continue
             new_line = ""
             last_index = 0
             # Opening tags
@@ -100,7 +111,7 @@ def run(self, lines: List[str]) -> List[str]:
                         line += f' {property[0]}="{prop_value}"'
                     line += _MarkdownFactory._TAIPY_END + new_line_delimeter
                 else:
-                    _warn(f"Invalid tag name '{tag}' in line {line_count}.")
+                    _warn(f"Failed to recognized block tag '{tag}' in line {line_count}. Verify that you are closing the tag properly with '|>' if it is a control element.")  # noqa: E501
             # Other controls
             for m in _Preprocessor.__CONTROL_RE.finditer(line):
                 control_name, properties = self._process_control(m.group(1), line_count)


Code review comments:
diff_hunk: @@ -100,7 +111,7 @@ def run(self, lines: List[str]) -> List[str]:
                         line += f' {property[0]}="{prop_value}"'
                     line += _MarkdownFactory._TAIPY_END + new_line_delimeter
                 else:
-                    _warn(f"Invalid tag name '{tag}' in line {line_count}.")
+                    _warn(f"Failed to recognized block tag '{tag}' in line {line_count}. Verify that you are closing the tag properly with '|>' if it is a control element.")  # noqa: E501
path: taipy/gui/_renderers/_markdown/preproc.py
text: @user1:
```suggestion
                    _warn(f"Failed to recognized block tag '{tag}' in line {line_count}. Check that you are closing the tag properly with '|>' if it is a control element.")  # noqa: E501
```