From 8f87e4186728a51aea97bced328f2afbd6ba8008 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Stig-=C3=98rjan=20Smelror?= Date: Thu, 1 Feb 2024 13:49:29 +0100 Subject: [PATCH] _html: Refine python script --- qsgen2 | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/qsgen2 b/qsgen2 index ec90daa..ce7912a 100755 --- a/qsgen2 +++ b/qsgen2 @@ -877,12 +877,14 @@ def replace_qstags(match): } return qstag_dict.get(qstag, qstag) # Replace or return unchanged -# Define the regular expression pattern for QStags -pattern = r'(?<=^|\s)(#(?!link|image|ytvideo|updated|version)\w+)' - +# Define the regular expression pattern for QStags, excluding specific ones +pattern = r'(?<=\s)(#(?!link|image|ytvideo|updated|version)\w+)' # Replace QStags using the defined function result = re.sub(pattern, replace_qstags, '''$content''', flags=re.MULTILINE) +# Handle QStags at the beginning of lines separately +result = re.sub(r'^(#(?!link|image|ytvideo|updated|version)\w+)', replace_qstags, result, flags=re.MULTILINE) + print(result) EOF )