diff --git a/build.bat b/build.bat new file mode 100644 index 0000000..0c82aa4 --- /dev/null +++ b/build.bat @@ -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 diff --git a/highlighter.d b/highlighter.d index b1030dd..0cb9579 100644 --- a/highlighter.d +++ b/highlighter.d @@ -10,12 +10,6 @@ import std.stdio; import std.array; import stdx.d.lexer; -void writeSpan(string cssClass, string value) -{ - stdout.write(``, value.replace("&", "&").replace("<", "<"), ``); -} - - // http://ethanschoonover.com/solarized void highlight(R)(TokenRange!R tokens, string fileName) { @@ -54,11 +48,29 @@ html { background-color: #fdf6e3; color: #002b36; } else if (isOperator(t.type)) writeSpan("op", t.value); 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("\n"); } +void writeSpan(string cssClass, string value) +{ + version(Windows) + stdout.write(``, value.replace("&", "&").replace("<", "<").replace("\r", ""), ``); + else + stdout.write(``, value.replace("&", "&").replace("<", "<"), ``); +} + /+void main(string[] args) { LexerConfig config;