penzai.treescope.html_escaping.heuristic_strip_javascript_comments(js_source: str) str[source]#

Heuristically removes javascript comments.

Transforms a string by removing anything between “/” and “/”, and anything between “//” and the next newline. This will remove Javascript comments. Note that this operates directly on the unparsed string and is not guaranteed to preserve the semantics of the original program (for instance, it will still replace “comments” that appear inside string literals). However, it works well enough for simple Javascript logic.


js_source – String to strip comments from.


Version of the input string with things that look like Javascript comments removed.