registerBlockRenderer Method
This method is used to create custom markdown renderers.
Parameters
string: The name of the custom rendererstring: The identifier to be used in Markdown to enter the custom rendererfunction: The function to be called when the compiler will parse this kind of block, it must return astring
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