diff options
Diffstat (limited to 'plugins/base/src/main/kotlin/renderers/html/HtmlRenderer.kt')
-rw-r--r-- | plugins/base/src/main/kotlin/renderers/html/HtmlRenderer.kt | 36 |
1 files changed, 36 insertions, 0 deletions
diff --git a/plugins/base/src/main/kotlin/renderers/html/HtmlRenderer.kt b/plugins/base/src/main/kotlin/renderers/html/HtmlRenderer.kt index 53222325..439a8fbe 100644 --- a/plugins/base/src/main/kotlin/renderers/html/HtmlRenderer.kt +++ b/plugins/base/src/main/kotlin/renderers/html/HtmlRenderer.kt @@ -27,6 +27,7 @@ open class HtmlRenderer( ) { val additionalClasses = node.style.joinToString(" ") { it.toString().toLowerCase() } return when { + ContentKind.shouldBePlatformTagged(node.dci.kind) -> wrapPlatformTagged(node, pageContext) { childrenCallback() } node.dci.kind == ContentKind.Symbol -> div("symbol $additionalClasses") { childrenCallback() } node.dci.kind == ContentKind.BriefComment -> div("brief $additionalClasses") { childrenCallback() } node.style.contains(TextStyle.Paragraph) -> p(additionalClasses) { childrenCallback() } @@ -35,6 +36,23 @@ open class HtmlRenderer( } } + private fun FlowContent.wrapPlatformTagged( + node: ContentGroup, + pageContext: ContentPage, + childrenCallback: FlowContent.() -> Unit + ) { + div("platform-tagged"){ + node.platforms.forEach { + div("platform-tag ${it.platformType.name}"){ + text(it.platformType.key.toUpperCase()) + } + } + div("content"){ + childrenCallback() + } + } + } + override fun FlowContent.buildPlatformDependent(content: PlatformHintedContent, pageContext: ContentPage) { val distinct = content.platforms.map { it to createHTML(prettyPrint = false).div { @@ -97,6 +115,22 @@ open class HtmlRenderer( } } + private fun TR.buildPlatformTags( + node: ContentGroup + ) { + if(ContentKind.shouldBePlatformTagged(node.dci.kind)) { + td { + div("platform-tagged"){ + node.platforms.forEach { + div(("platform-tag ${it.platformType.key}")) { + text(it.platformType.key.toUpperCase()) + } + } + } + } + } + } + override fun FlowContent.buildTable( node: ContentTable, pageContext: ContentPage, @@ -122,12 +156,14 @@ open class HtmlRenderer( it.build(this, pageContext, platformRestriction) } } + buildPlatformTags(it) } } } } } + override fun FlowContent.buildHeader(level: Int, content: FlowContent.() -> Unit) { when (level) { 1 -> h1(block = content) |