<html><head><meta name="color-scheme" content="light dark"></head><body><pre style="word-wrap: break-word; white-space: pre-wrap;"># Remove parts of code enclosed in %latex/%endlatex tags

$latexonly = 0;

while(&lt;&gt;)
{
    $latexonly = 1 if /^%latex/i;
    $latexonly = 0 if /^%endlatex/i;
    

    if($latexonly) {
	if(/^%!(.*)/)
	{
	    print $1;
	}
    }
    else {
	print;
    }
}
</pre></body></html>