From 468e219ca88a0ce6a8af4785cb1d75b853107152 Mon Sep 17 00:00:00 2001 From: Bad Manners Date: Wed, 15 Nov 2023 17:04:37 -0300 Subject: [PATCH] Improve documentation on `[if][/if][else][/else]` tags --- README.md | 2 +- description.py | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index 0262c56..b5adb98 100644 --- a/README.md +++ b/README.md @@ -68,4 +68,4 @@ There are also special tags to link to yourself or other users automatically. Th [generic=https://github.com/BadMannersXYZ]Bad Manners[/generic] can be used as the innermost tag with a mandatory URL attribute and default username, and is similar to the URL tag, but it can be nested within other profile links. Those other profile links get used only at their respective websites. ``` -Another special set of tags is `[if][/if]` and `[else][/else]`. The if tag receives a parameter for the condition (i.e. `[if=parameter==value]...[/if]` or `[if=parameter!=value]...[/if]`) to check on the current transformer, and lets you show or omit generated content respectively. The else tag is optional but must appear immediately after an if tag (no whitespace in-between), and displays whenever the condition is false instead. For now, the if tag only accepts the `site` parameter (eg. `[if=site==fa]...[/if][else]...[/else]` or `[if=site!=furaffinity]...[/if]`). +Another special set of tags is `[if][/if]` or `[if][/if][else][/else]`. The if tag receives a parameter for the condition (i.e. `[if=parameter==value]...[/if]` or `[if=parameter!=value]...[/if]`) to check on the current transformer, and lets you show or omit generated content respectively. The else tag is optional but must appear immediately after an if tag (no characters or whitespace in-between), and displays whenever the condition is false instead. For now, the if tag only accepts the `site` parameter (eg. `[if=site==fa]...[/if][else]...[/else]` or `[if=site!=furaffinity]...[/if][else]...[/else]`). diff --git a/description.py b/description.py index cfb8090..0adeac1 100644 --- a/description.py +++ b/description.py @@ -121,14 +121,14 @@ class UploadTransformer(lark.Transformer): def if_tag(self, data: typing.Tuple[str, str, str]): condition, truthy_document, falsy_document = data - equality_condition = condition.split('==') + equality_condition = condition.split('==', 1) if len(equality_condition) == 2 and equality_condition[1].strip(): conditional_test = f'transformer_matches_{equality_condition[0].strip()}' if hasattr(self, conditional_test): if getattr(self, conditional_test)(equality_condition[1].strip()): return truthy_document or '' return falsy_document or '' - inequality_condition = condition.split('!=') + inequality_condition = condition.split('!=', 1) if len(inequality_condition) == 2 and inequality_condition[1].strip(): conditional_test = f'transformer_matches_{inequality_condition[0].strip()}' if hasattr(self, conditional_test):