highlightDCode

Takes a piece of D code and outputs a sequence of HTML elements useful for syntax highlighting.

The output will contain <span> elements with the class attribute set to the kind of entity that it contains. The class names are kept compatible with the ones used for Google's prettify library: "typ", "kwd", "com", "str", "lit", "pun", "pln", "spc"

The only addition is "spc", which denotes a special token sequence starting with a "#", such as "#line" or "#!/bin/sh".

Note that this function will only perform actual syntax highlighting if the libdparse package is available as a DUB dependency.

1 void main(string[] args)
2 {
3 	#line 2
4 	import std.stdio; // yeah
5 	writefln("Hello, "~"World!");
6 	Package pack;
7 	ddox.entities.Module mod;
8 }
  1. void highlightDCode(ref R dst, string code, scope IdentifierRenderCallback ident_render = null)
    void
    highlightDCode
    (
    R
    )
    (
    ref R dst
    ,
    string code
    ,
    scope IdentifierRenderCallback ident_render = null
    )
    if (
    isOutputRange!(R, char)
    )
  2. string highlightDCode(string str, IdentifierRenderCallback ident_render = null)

Parameters

dst
Type: R

Output range where to write the HTML output

code
Type: string

The D source code to process

ident_render

Optional delegate to customize how (qualified) identifiers are rendered

Meta