diff --git a/nodes/d2_text_nodes.py b/nodes/d2_text_nodes.py index 6435909..f53f9d2 100644 --- a/nodes/d2_text_nodes.py +++ b/nodes/d2_text_nodes.py @@ -556,59 +556,6 @@ class D2_FilenameTemplate: } -""" - -D2 Delete Comment - -""" -class D2_DeleteComment: - @classmethod - def INPUT_TYPES(cls): - return { - "required": { - "text": ("STRING", {"default": "","multiline": True}), - "type": (["# only","// only","/* */ only","# + // + /**/",],), - }, - } - - RETURN_TYPES = ("STRING",) - RETURN_NAMES = ("STRING",) - FUNCTION = "run" - CATEGORY = "D2" - - def run(self, text, type): - """ - text のコメント行を消す - type: "# only" なら行頭が「#」の行を消す - type: "// only" なら行頭が「//」の行を消す - type: "/* */ only" なら「/* 〜 */」を消す。これは複数行にも対応する - type: "# + // + /**/" なら上記3つを全て実行する - """ - - result_text = text - - if type == "# only" or type == "# + // + /**/": - # 行頭が # のコメント行を削除(行頭の空白は考慮しない) - result_text = re.sub(r'^#.*$', '', result_text, flags=re.MULTILINE) - - if type == "// only" or type == "# + // + /**/": - # 行頭が // のコメント行を削除(行頭の空白は考慮しない) - result_text = re.sub(r'^//.*$', '', result_text, flags=re.MULTILINE) - - if type == "/* */ only" or type == "# + // + /**/": - # /* */ コメントを削除(複数行対応) - result_text = re.sub(r'/\*.*?\*/', '', result_text, flags=re.DOTALL) - - # # 空行が連続する場合、1つの空行にまとめる - # result_text = re.sub(r'\n\s*\n+', '\n\n', result_text) - - # # 先頭と末尾の余分な改行を削除 - # result_text = result_text.strip() - - return { - "result": (result_text,), - } - NODE_CLASS_MAPPINGS = { @@ -618,6 +565,5 @@ NODE_CLASS_MAPPINGS = { "D2 Multi Output": D2_MultiOutput, "D2 List To String": D2_ListToString, "D2 Filename Template": D2_FilenameTemplate, - "D2 Delete Comment": D2_DeleteComment, "D2 Prompt": D2_Prompt, }