diff --git a/README.md b/README.md index ccd0d41..969a037 100644 --- a/README.md +++ b/README.md @@ -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 --- diff --git a/html-preprocessor b/html-preprocessor index 16008c4..4ab0e0b 100755 --- a/html-preprocessor +++ b/html-preprocessor @@ -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, } """