diff options
Diffstat (limited to 'doc/pages/demo/pygments')
-rw-r--r-- | doc/pages/demo/pygments/index.xml | 66 |
1 files changed, 66 insertions, 0 deletions
diff --git a/doc/pages/demo/pygments/index.xml b/doc/pages/demo/pygments/index.xml new file mode 100644 index 0000000..361c6ab --- /dev/null +++ b/doc/pages/demo/pygments/index.xml @@ -0,0 +1,66 @@ +<page xmlns="https://rub.parody"> +<title>Pygments demo</title> +<description>Code snippets to demonstrate syntax highlighting</description> +<date>2022-12-26</date> +<category>demo</category> +<category>aoc</category> +<markdown> +Syntax highlighting for D using Pygments: + +<highlight lang="d"><![CDATA[ +import core.stdc.stdio : getchar, printf; + +extern(C) void main() +{ + slide: for (auto q = 0u, i = 1u; q & 0xffu ^ '\n'; ++i) + { + q <<= 8u; + q |= getchar(); + if (i < 4) + continue; + + auto p = cast(ubyte*) &q; + for (auto s = 0u, j = 0u; j < 4u; ++j) + { + auto b = 1u << (p[j] & 0x1fu); + if (s & b) + continue slide; + s |= b; + } + + printf("%d\n", i); + break; + } +} +]]></highlight> + +The same but let Pygments guess the language: + +<highlight><![CDATA[ +import core.stdc.stdio : getchar, printf; + +extern(C) void main() +{ + slide: for (auto q = 0u, i = 1u; q & 0xffu ^ '\n'; ++i) + { + q <<= 8u; + q |= getchar(); + if (i < 4) + continue; + + auto p = cast(ubyte*) &q; + for (auto s = 0u, j = 0u; j < 4u; ++j) + { + auto b = 1u << (p[j] & 0x1fu); + if (s & b) + continue slide; + s |= b; + } + + printf("%d\n", i); + break; + } +} +]]></highlight> +</markdown> +</page> |