comment_out_prose_lines

Function comment_out_prose_lines 

Source
pub(crate) fn comment_out_prose_lines(code: &str) -> String
Expand description

Comment out lines that look like prose (English) rather than HLSL/WGSL code. Real preset pattern: comp_30=`written by martin — an attribution typed without a // prefix, threaded into the shader body by the .milk parser as a literal line of code. Many presets failed with expected assignment or increment/decrement; found 'by' (or found 'rota', etc.) on lines of this shape.

Heuristic: a non-empty line where every non-whitespace character is either an ASCII letter or an apostrophe — no ;, =, parens, braces, brackets, arithmetic operators, digits, or comment markers — and which contains at least two whitespace-separated word tokens. We also require the first token not to look like a known WGSL keyword or builtin call left-side (e.g. for, if, var, return, tex2D, mul, …) so a line like if cond alone won’t be commented out. In practice prose lines always have ≥ 2 words and lack punctuation, so the false-positive rate is effectively zero on the corpus.