Skip to content

Provide a way to override/extend rendering of a specific language's code blocks in HTML format #3244

@IgnatBeresnev

Description

@IgnatBeresnev

Background

Dokka plugins may want to provide their own implementations for how certain HTML elements are rendered. It is possible to do now by overriding specific functions inside HtmlRenderer, such as buildHeader().

However, if a plugin wants to add some additional / optional / conditional rendering, it's very difficult to do it in backward-compatible manner (see #2435 for more details).

For example, the dokka-mermaid plugin only needs to provide an implementation for the mermaid language code blocks, while everything else (including the default behaviour) should stay the same.

Task

Rendering of HTML code blocks (HtmlRenderer#buildCodeBlock) should be extracted into a separate HTML-only extension point, similar to how CustomTagContentProvider is implemented.

For any given language x, if no extension is found that knows how to render it, it should be rendered in the default way (same logic as exists now).

Metadata

Metadata

Assignees

Labels

enhancementAn issue for a feature or an overall improvementformat: htmlAn issue/PR related to Dokka's default HTML output formathtml: backendAn issue/PR that affects the HTML format, but requires changes in common (content) Kotlin codeplugin-apiEverything related to Dokka's plugin API

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions