From 5b85a1245ad410636ec15981b3c45fbd451f0b46 Mon Sep 17 00:00:00 2001 From: Mara Date: Fri, 12 Jan 2024 03:52:22 +0100 Subject: [PATCH] fix: bug caused by html in codeblocks --- custom_attributes/plugin.py | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/custom_attributes/plugin.py b/custom_attributes/plugin.py index 935a93c..75ce587 100644 --- a/custom_attributes/plugin.py +++ b/custom_attributes/plugin.py @@ -39,7 +39,6 @@ def convert_hashtags(config: Dict[str, str], line: str) -> str: css = read_custom(config) token = re.findall(r"#[\w\-_\/]+", line) token = list(set(token)) - print(token) for tag in token: if tag in css: clean_line = line.replace(tag, "") @@ -90,18 +89,21 @@ def convert_text_attributes(markdown: str, config: Dict[str, str]) -> str: markdown = "" code_blocks = False for line in files_contents: - if code_blocks and ( + if not code_blocks and ( line.startswith("```") - or re.search("", line) - or re.search(r"^\s*```", line) + or (re.search("<.*?>", line) and not re.search("", line)) + or re.search(r"^\s*```(.*)", line) ): - code_blocks = False - elif ( + code_blocks = True + print("START OF BLOCK ----- ", line) + elif code_blocks and ( line.startswith("```") - or re.search("<.*?>", line) + or re.search("", line) or re.search(r"^\s*```", line) ): - code_blocks = True + code_blocks = False + print("END OF BLOCK ----- ", line) + elif ( re.search(r"#\w+", line) and not re.search(r"(`|\[{2}|\()(.*)#(.*)(`|]{2}|\))", line)