summaryrefslogtreecommitdiff
path: root/test/syntax/code/d
diff options
context:
space:
mode:
authorShaun McCance <shaunm@redhat.com>2016-01-03 12:33:26 -0500
committerShaun McCance <shaunm@redhat.com>2016-01-03 12:33:26 -0500
commitff740f6c5e64a7ac213b7b3b9f7f47cb0c080e23 (patch)
tree9c629a4140c348778d9e7443964ce56b062d82de /test/syntax/code/d
parentb28bc251ba9d0f223673dacec2b5fa993fc73693 (diff)
downloadyelp-xsl-ff740f6c5e64a7ac213b7b3b9f7f47cb0c080e23.tar.gz
Switch to highlight.js and revamp color stylesheet
Switching from the dead jQuery.syntax to the actively maintained highlight.js for syntax highlighting. highlight.js doesn't require jQuery, doesn't break inline markup, and has nicely namespaced class names that avoid clashes with classes used elsewhere in these stylesheets. Previously, we included the JavaScript for syntax highlighting, but didn't provide any CSS to specify colors, leaving a large chunk of work to users to get syntax highlighting visible. This is because the colors defined in color.xsl weren't useful as text colors. This commit introduces a new color system which includes background, foreground, and accent shades for six colors, as well as multiple shades of gray. Many of these colors can now be automatically computed, thanks to color algorithms built into the XSLT.
Diffstat (limited to 'test/syntax/code/d')
-rw-r--r--test/syntax/code/d44
1 files changed, 44 insertions, 0 deletions
diff --git a/test/syntax/code/d b/test/syntax/code/d
new file mode 100644
index 00000000..92cc8d84
--- /dev/null
+++ b/test/syntax/code/d
@@ -0,0 +1,44 @@
+#!/usr/bin/rdmd
+// Computes average line length for standard input.
+import std.stdio;
+
+/+
+ this is a /+ nesting +/ comment
++/
+
+enum COMPILED_ON = __TIMESTAMP__; // special token
+
+enum character = '©';
+enum copy_valid = '&copy;';
+enum backslash_escaped = '\\';
+
+// string literals
+enum str = `hello "world"!`;
+enum multiline = r"lorem
+ipsum
+dolor"; // wysiwyg string, no escapes here allowed
+enum multiline2 = "sit
+amet
+\"adipiscing\"
+elit.";
+enum hex = x"66 6f 6f"; // same as "foo"
+
+#line 5
+
+// float literals
+enum f = [3.14f, .1, 1., 1e100, 0xc0de.01p+100];
+
+static if (something == true) {
+ import std.algorithm;
+}
+
+void main() pure nothrow @safe {
+ ulong lines = 0;
+ double sumLength = 0;
+ foreach (line; stdin.byLine()) {
+ ++lines;
+ sumLength += line.length;
+ }
+ writeln("Average line length: ",
+ lines ? sumLength / lines : 0);
+}