From c63ec458e94c6236a0002333d852aaa838beaf1e Mon Sep 17 00:00:00 2001 From: Ignat Beresnev Date: Tue, 20 Sep 2022 14:42:28 +0200 Subject: Update `prism.js` to match new webhelp highlight colors (#2670) --- plugins/base/src/main/kotlin/renderers/html/HtmlRenderer.kt | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) (limited to 'plugins/base/src/main/kotlin/renderers/html') diff --git a/plugins/base/src/main/kotlin/renderers/html/HtmlRenderer.kt b/plugins/base/src/main/kotlin/renderers/html/HtmlRenderer.kt index cb7f58d2..dfc4e2e3 100644 --- a/plugins/base/src/main/kotlin/renderers/html/HtmlRenderer.kt +++ b/plugins/base/src/main/kotlin/renderers/html/HtmlRenderer.kt @@ -792,11 +792,18 @@ open class HtmlRenderer( TextStyle.Strong -> strong { body() } TextStyle.Var -> htmlVar { body() } TextStyle.Underlined -> underline { body() } - is TokenStyle -> span("token " + styleToApply.toString().toLowerCase()) { body() } + is TokenStyle -> span("token ${styleToApply.prismJsClass()}") { body() } else -> body() } } + private fun TokenStyle.prismJsClass(): String = when(this) { + // Prism.js parser adds Builtin token instead of Annotation + // for some reason, so we also add it for consistency and correct coloring + TokenStyle.Annotation -> "annotation builtin" + else -> this.toString().toLowerCase() + } + override fun render(root: RootPageNode) { shouldRenderSourceSetBubbles = shouldRenderSourceSetBubbles(root) super.render(root) -- cgit