minor refactor

This commit is contained in:
Elijah 2024-10-04 17:21:42 +00:00
parent 89b3891be8
commit 4b35680409

View File

@ -779,10 +779,11 @@ class ShikiHighLevelCodeBlock(ShikiCodeBlock):
raise VarTypeError(
f"code should be string literal or a StringVar type. Got {type(code)} instead."
)
regex_pattern = r"[\/#]+ *\[!code.*?\]"
if isinstance(code, Var):
return string_replace_operation(
code, StringVar(_js_expr=r"/[\/#]+ *\[!code.*?\]/g", _var_type=str), ""
code, StringVar(_js_expr=f"/{regex_pattern}/g", _var_type=str), ""
)
if isinstance(code, str):
return re.sub(r"[\/#]+ *\[!code.*?\]", "", code)