parent
42cf96c6d2
commit
bfeb20776e
|
@ -0,0 +1 @@
|
||||||
|
dmd main.d stats.d imports.d highlighter.d ctags.d astprinter.d stdx/d/lexer.d stdx/d/parser.d stdx/d/entities.d stdx/d/ast.d -wi -ofdscanner
|
|
@ -10,12 +10,6 @@ import std.stdio;
|
||||||
import std.array;
|
import std.array;
|
||||||
import stdx.d.lexer;
|
import stdx.d.lexer;
|
||||||
|
|
||||||
void writeSpan(string cssClass, string value)
|
|
||||||
{
|
|
||||||
stdout.write(`<span class="`, cssClass, `">`, value.replace("&", "&").replace("<", "<"), `</span>`);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
// http://ethanschoonover.com/solarized
|
// http://ethanschoonover.com/solarized
|
||||||
void highlight(R)(TokenRange!R tokens, string fileName)
|
void highlight(R)(TokenRange!R tokens, string fileName)
|
||||||
{
|
{
|
||||||
|
@ -54,11 +48,29 @@ html { background-color: #fdf6e3; color: #002b36; }
|
||||||
else if (isOperator(t.type))
|
else if (isOperator(t.type))
|
||||||
writeSpan("op", t.value);
|
writeSpan("op", t.value);
|
||||||
else
|
else
|
||||||
stdout.write(t.value.replace("<", "<"));
|
{
|
||||||
|
version(Windows)
|
||||||
|
{
|
||||||
|
// Stupid Windows automatically does a LF → CRLF, so CRLF → CRCRLF, which is obviously wrong.
|
||||||
|
// Strip out the CR characters here to avoid this.
|
||||||
|
stdout.write(t.value.replace("<", "<").replace("\r", ""));
|
||||||
|
}
|
||||||
|
else
|
||||||
|
stdout.write(t.value.replace("<", "<");
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
stdout.writeln("</pre>\n</body></html>");
|
stdout.writeln("</pre>\n</body></html>");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void writeSpan(string cssClass, string value)
|
||||||
|
{
|
||||||
|
version(Windows)
|
||||||
|
stdout.write(`<span class="`, cssClass, `">`, value.replace("&", "&").replace("<", "<").replace("\r", ""), `</span>`);
|
||||||
|
else
|
||||||
|
stdout.write(`<span class="`, cssClass, `">`, value.replace("&", "&").replace("<", "<"), `</span>`);
|
||||||
|
}
|
||||||
|
|
||||||
/+void main(string[] args)
|
/+void main(string[] args)
|
||||||
{
|
{
|
||||||
LexerConfig config;
|
LexerConfig config;
|
||||||
|
|
Loading…
Reference in New Issue