Skip to documentation
SLOP

tiny.zen.renderCode

Reference tiny.zen renderCode

Defined in code.

Called byCallstest sourcelib.zen.src.codetest: code gives authored wide blocks...test sourcelib.zen.src.codetest: code places typed anchors on ex...test sourcelib.zen.src.codetest: code rejects invalid and out of...test sourcelib.zen.src.codetest: code renders highlighted titled...private sourcelib.zen.src.markdownflushFenceprivate sourcelib.zen.src.codeappendLinesprivate sourcelib.zen.src.codehasOptionprivate sourcelib.zen.src.codeoptionValuecodeparseInfohtmlappendAttributeEscapedhtmlappendEscapedcoderender
Static calls · unresolved targets: 2 · external targets: 1.

Source

Source: lib/zen/src/code.zig:31

zig
pub fn render(    allocator: Allocator,    out: *std.ArrayList(u8),    info_text: []const u8,    source: []const u8,    options: Options,) !void {    const info = parseInfo(info_text);    const anchors = optionValue(info_text, "anchors") orelse "";    const exact_source = hasOption(info_text, "source", "exact");    const wide = exact_source or hasOption(info_text, "role", "wide");    try out.appendSlice(allocator, "<div class=\"zen-code-block");    if (options.word_wrap) {        try out.appendSlice(allocator, " zen-code-wrap");    } else {        try out.appendSlice(allocator, " zen-code-nowrap");    }    if (!options.line_numbers) try out.appendSlice(allocator, " zen-code-no-lines");    if (exact_source) {        try out.appendSlice(allocator, " zen-source-listing zen-role-wide");    } else if (wide) {        try out.appendSlice(allocator, " zen-code-longform zen-role-wide");    } else {        try out.appendSlice(allocator, " zen-code-example zen-role-reading");    }    try out.append(allocator, '"');    if (info.language.len != 0) {        try out.appendSlice(allocator, " data-language=\"");        try html.appendAttributeEscaped(out, allocator, info.language);        try out.append(allocator, '"');    }    if (exact_source) {        try out.appendSlice(allocator, " data-source=\"exact\"");    }    try out.append(allocator, '>');    if ((options.titles and info.title.len != 0) or (options.language_labels and info.language.len != 0)) {        try out.appendSlice(allocator, "<div class=\"zen-code-header\">");        if (options.titles and info.title.len != 0) {            try out.appendSlice(allocator, "<span class=\"zen-code-title\">");            try html.appendEscaped(out, allocator, info.title);            try out.appendSlice(allocator, "</span>");        }        if (options.language_labels and info.language.len != 0) {            try out.appendSlice(allocator, "<span class=\"zen-code-language\">");            try html.appendEscaped(out, allocator, info.language);            try out.appendSlice(allocator, "</span>");        }        try out.appendSlice(allocator, "</div>");    }    try out.appendSlice(allocator, "<pre class=\"zen-code\"><code");    if (info.language.len != 0) {        try out.appendSlice(allocator, " class=\"language-");        try html.appendAttributeEscaped(out, allocator, info.language);        try out.append(allocator, '"');    }    try out.append(allocator, '>');    try appendLines(allocator, out, info.language, source, anchors, options);    try out.appendSlice(allocator, "</code></pre></div>\n");}

Source: lib/zen/src/root.zig:175

zig
/// Appends escaped, optionally highlighted code-block HTML to caller-owned output.pub const renderCode = code.render;

Audit

Definitions1
Public names2
Members0
Version26.7.0
Revisiondaab053ee433