Skip to content

Latest commit

 

History

History
131 lines (93 loc) · 3.67 KB

README.md

File metadata and controls

131 lines (93 loc) · 3.67 KB

commonmark-kotlinx-html

Small library that provides an ability to render commonmark-java parsing result into kotlinx.html stream

Download Kotlin GitHub license

KotlinxHtmlRenderer

The main part of this library.

For general information please read commonmark-java readme

Get

repositories {
    jcenter()
}

dependencies {
    implementation("ru.krikun.commonmark:commonmark-kotlinx-html:0.1.2")
}

Usage

createHTML().html {
    body {
        val document: Document = ... // Parse document using commonmark-java parser.
        val renderer = buildKotlinxHtmlRenderer()

        renderer.render(document, stream)
    }
} 

or use kotlin extension function:

div {
    val document: Document = ... // Parse document using commonmark-java parser.
    render(document)
}

Extension

For general information about extensions see commonmark-java readme

Note: commonmark-kotlinx-html extensions use internal implementation of parsing part from original commonmark-java extensions. So you don't need add original extension to the parser. Use commonmark-kotlinx-html extension instead.

Heading anchor

Enables adding auto generated "id" attributes to heading tags.

Use HeadingAnchorKotlinxHtmlExtension

dependencies {
    implementation("ru.krikun.commonmark:commonmark-kotlinx-html-heading-anchor:0.1.2")
}

Also, see commonmark-java description.

Ins

Enables underlining of text by enclosing it in ++.

Use InsKotlinxHtmlExtension

dependencies {
    implementation("ru.krikun.commonmark:commonmark-kotlinx-html-ins:0.1.2")
}

Also, see commonmark-java description.

Strikethrough

Enables strikethrough of text by enclosing it in ~~.

Use StrikethroughKotlinxHtmlExtension.

dependencies {
    implementation("ru.krikun.commonmark:commonmark-kotlinx-html-strikethrough:0.1.2")
}

Also, see commonmark-java description.

Tables

Enables tables using pipes as in GitHub Flavored Markdown.

Use TablesKotlinxHtmlExtension

dependencies {
    implementation("ru.krikun.commonmark:commonmark-kotlinx-html-tables:0.1.2")
}

Also, see commonmark-java description.

Dependencies

Dependency Version
kotlin-jvm 1.4.10
kotlinx.html 0.7.2
commonmark-java 0.15.2

License

Copyright 2020 OlegKrikun

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

   http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.