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

mdoc.internal.livereload.SimpleHtml.scala Maven / Gradle / Ivy

There is a newer version: 2.6.1
Show newest version
package mdoc.internal.livereload

import com.vladsch.flexmark.html.HtmlRenderer
import com.vladsch.flexmark.parser.Parser
import mdoc.internal.markdown.Markdown

object SimpleHtml {

  def fromMarkdown(markdown: String, filename: String, url: String): String = {
    val settings = Markdown.plainSettings()
    val parser = Parser.builder(settings).build()
    val renderer = HtmlRenderer.builder(settings).build()
    val document = parser.parse(markdown)
    val body = renderer.render(document)
    val toc = TableOfContents(document)
    wrapHtmlBody(body, toc, filename, url)
  }

  def wrapHtmlBody(
      body: String,
      tableOfContents: TableOfContents,
      title: String,
      url: String
  ): String = {
    val toc = tableOfContents.toHTML(fromLevel = 2, toLevel = 3, indent = "      ")
    s"""


    $title
    
    
    
    
    
    


  
$body
""" } }




© 2015 - 2024 Weber Informatics LLC | Privacy Policy