added error, warning

This commit is contained in:
matthias@arch 2023-09-15 14:03:16 +02:00
parent 9c5b9e0fa2
commit 4cbbd2961e
2 changed files with 14 additions and 4 deletions

View File

@ -117,7 +117,7 @@ This can be useful when you want to look at the unprocessed html without variabl
### conditionals
To turn on or off entire blocks, `if`, `elif` can `else` be used.
These commands must not be in multi-line comments.
These commands can not be nested and must not appear in multi-line comments.
Logical and `&&` and logical or `||` can be used to chain conditions.
If a condition is true, the corresponding block is included while all other blocks are deleted.
@ -133,6 +133,7 @@ If a condition is true, the corresponding block is included while all other bloc
```
**Argument** Condition for `if` and `elif`, ignored for `else` and `endif`
**Return Value** Empty String
---

View File

@ -69,11 +69,11 @@ exit_on_error_level = error_levels["serious"]
"""
************************************************************ UTILITY ************************************************************
"""
DEBUG = True
DEBUG = False
def pdebug(*args, **keys):
if DEBUG: print(*args, **keys)
TRACE = True
TRACE = False
def ptrace(*args, **keys):
if TRACE: print(*args, **keys)
@ -283,6 +283,13 @@ def cmd_comment(args: str, variables:dict[str, str]={}) -> str:
def cmd_uncomment(args: str, variables:dict[str, str]={}) -> str:
return args
def cmd_error(args: str, variables:dict[str, str]={}) -> str:
error(f"Encounted 'error' command: {args}", level=error_levels["critical"])
return ""
def cmd_warning(args: str, variables:dict[str, str]={}) -> str:
error(f"Encounted 'warning' command: {args}", level=error_levels["light"])
return ""
command2function:dict[str, Callable[[str, dict[str,str]], str]] = {
"include": cmd_include,
@ -291,7 +298,9 @@ command2function:dict[str, Callable[[str, dict[str,str]], str]] = {
"default": cmd_default,
"comment": cmd_comment,
"uncomment": cmd_uncomment,
"sidenav": Sidenav.cmd_sidenav
"sidenav": Sidenav.cmd_sidenav,
"warning": cmd_warning,
"error": cmd_error,
}
"""