All Downloads are FREE. Search and download functionalities are using the official Maven repository.

land.sungbin.gfm.markdown.kt Maven / Gradle / Ivy

The newest version!
/*
 * Designed and developed by Martin Macheiner and Ji Sungbin, 2022
 *
 * Licensed under the MIT.
 * Please see full license: https://github.com/duckie-team/GfmDsl/blob/master/LICENSE
 */

package land.sungbin.gfm

import land.sungbin.gfm.tag.text

public class Markdown @PublishedApi internal constructor() {
    private val contents = mutableListOf()

    public operator fun MarkdownTag.unaryPlus() {
        contents.add(this)
    }

    public operator fun String.unaryPlus() {
        contents.add(text(this))
    }

    public override fun toString(): String = contents.joinToString(
        separator = "\n",
    ) { tag ->
        "${tag.content()}\n"
    }
}

public inline fun markdown(@GfmDsl block: Markdown.() -> Unit): Markdown {
    return Markdown().apply(block)
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy