PowerDocs online help Help

registerBlockRenderer Method

This method is used to create custom markdown renderers.

Parameters

  • string: The name of the custom renderer

  • string: The identifier to be used in Markdown to enter the custom renderer

  • function: The function to be called when the compiler will parse this kind of block, it must return a string

Examples

This code snippet is taken from this extension:
https://github.com/sebbouez/PowerDocs/tree/main/extensions/swagger-methods

import { PowerDocsExtension } from "PowerDocs.Lib"; var ext = PowerDocsExtension.create(); function renderSwaggerMethod(arg) { // the "arg" argument will contain the HTTP method // the markdown block will look like this: // ::: swagger-method GET // // ::: let html = "<div class='swagger-method http-method-" + arg + "'>"; html += "<span class='leftPart'>" + arg + "</span>"; html += "<span class='rightPart'>@content</span>"; html += "</div>"; return html; } ext.registerBlockRenderer("Swagger method block", "swagger-method", renderSwaggerMethod);
Last modified: 08 avril 2024