File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -102,8 +102,8 @@ def scan_file_for_todos(
102102 if allowed_tags and tag not in allowed_tags :
103103 continue
104104
105- # Schließende Kommentarzeichen (*/ oder -->) am Zeilenende entfernen
106- text = re .sub (r'(\*/|-->)\s*$' , '' , raw_text ).strip ()
105+ # Kommentar-Endzeichen für die Anzeige entfernen, kein HTML-Sanitizer.
106+ text = re .sub (r'(\*/|--!? >)\s*$' , '' , raw_text ).strip ()
107107
108108 items .append (
109109 TodoItem (
Original file line number Diff line number Diff line change @@ -90,6 +90,32 @@ def test_scan_file_for_todos(tmp_path):
9090 assert items [2 ].line_number == 5
9191
9292
93+ def test_scan_file_comment_terminators_preserve_task_text (tmp_path ):
94+ test_file = tmp_path / "comments.html"
95+ test_file .write_text (
96+ "<!-- TODO: Standard ending -->\n "
97+ "<!-- FIXME(anna): Bang ending --!> \n "
98+ "/* BUG: C ending */\n "
99+ "<!-- NOTE: Keep <b>literal markup</b> --!>\n "
100+ "<!-- HACK: Keep unsupported ending --!!>\n "
101+ "<!-- TODO: Keep --> inside text\n " ,
102+ encoding = "utf-8" ,
103+ )
104+
105+ items = scan_file_for_todos (test_file )
106+ assert [item .text for item in items ] == [
107+ "Standard ending" ,
108+ "Bang ending" ,
109+ "C ending" ,
110+ "Keep <b>literal markup</b>" ,
111+ "Keep unsupported ending --!!>" ,
112+ "Keep --> inside text" ,
113+ ]
114+ assert items [1 ].author == "anna"
115+ assert items [1 ].line_number == 2
116+ assert items [1 ].line_text == "<!-- FIXME(anna): Bang ending --!> "
117+
118+
93119def test_scan_file_binary_and_size_limits (tmp_path ):
94120 """Prüft, dass Binärdateien und übergroße Dateien übersprungen werden."""
95121 bin_file = tmp_path / "binary.dat"
You can’t perform that action at this time.
0 commit comments