Compare commits
No commits in common. "ca60a1b02c177e32e1704869935833c60adad1bb" and "8ff1093877b871162db68d2ddf2333af4c87d03b" have entirely different histories.
ca60a1b02c
...
8ff1093877
13
README.md
13
README.md
@ -97,19 +97,6 @@ Same as `set`, but it returns the value of the variable that is being set. This
|
||||
### default
|
||||
Same as `set`, but it sets the variable's value only if it has no value yet.
|
||||
|
||||
### unset
|
||||
Unset a variable
|
||||
|
||||
**Synopsis**:
|
||||
Unset `varname`, it will no longer be defined and can therefor be set with `default` again.
|
||||
`<!-- #unset varname -->`
|
||||
|
||||
**Argument**:
|
||||
Name of the variable
|
||||
|
||||
**Return Value**:
|
||||
Empty string
|
||||
|
||||
---
|
||||
|
||||
### comment
|
||||
|
@ -273,7 +273,7 @@ def cmd_return(args: str, variables:dict[str, str]={}) -> str:
|
||||
# pdebug(f"cmd_set: varname='{args[:space]}, 'arg='{args[space+1:]}', variables='{variables}'")
|
||||
if not (space > 0 and space < len(args)-1):
|
||||
variables[args] = ""
|
||||
pdebug(f"cmd_set: Setting to empty string: {args}")
|
||||
pdebug(f"cmd_set: Setting to emptry string: {args}")
|
||||
else:
|
||||
varname = args[:space]
|
||||
variables[varname] = ""
|
||||
@ -308,14 +308,6 @@ def cmd_set(args: str, variables:dict[str, str]={}) -> str:
|
||||
cmd_return(args, variables)
|
||||
return ""
|
||||
|
||||
def cmd_unset(args: str, variables:dict[str, str]={}) -> str:
|
||||
variable = args.strip(' ')
|
||||
if variable not in variables:
|
||||
pdebug(f"unset: variable '{variable}' is not set", level=error_levels["light"])
|
||||
else:
|
||||
variables.pop(variable)
|
||||
return ""
|
||||
|
||||
def cmd_default(args: str, variables:dict[str, str]={}) -> str:
|
||||
separator = args.find(' ')
|
||||
if args[:separator] not in variables:
|
||||
@ -339,9 +331,8 @@ def cmd_warning(args: str, variables:dict[str, str]={}) -> str:
|
||||
command2function:dict[str, Callable[[str, dict[str,str]], str]] = {
|
||||
"include": cmd_include,
|
||||
"section": cmd_section,
|
||||
"return": cmd_return,
|
||||
"set": cmd_set,
|
||||
"unset": cmd_unset,
|
||||
"return": cmd_return,
|
||||
"default": cmd_default,
|
||||
"comment": cmd_comment,
|
||||
"uncomment": cmd_uncomment,
|
||||
@ -660,8 +651,6 @@ if __name__ == "__main__":
|
||||
target_html = file.read()
|
||||
|
||||
output_html = parse_file(target_html, variables, not args.preserve_comments)
|
||||
# remove empty lines
|
||||
output_html = re.sub(r"[\t\r ]*\n(?:[\t\r ]*\n[\t\r ]*)+", r"\n", output_html)
|
||||
|
||||
# pdebug(f"Output: {output_html}")
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user