Skip to content

monosoul/markdown-page-generator-gradle-plugin

Repository files navigation

Markdown to HTML Page Generator Gradle Plugin

This Gradle plugin's goal is to provide a way of using the maven markdown-page-generator-plugin by Marko Wallin (walokra).

Build Status GitHub Release Gradle Plugins Release license

Gradle Plugin Portal page

Gradle compatibility table

Plugin version Gradle version
>= 2.3.1.0 >= 6.8.3
2.3.0.0 >= 4.9
2.1.0.1 >= 4.9
2.1.0 >= 5.0

Getting Started

To apply the plugin simply add it to the plugins block of your build script:

plugins {
  id("com.github.monosoul.markdown.page.generator") version "2.4.0.0"
}

Or using legacy plugin application method:

buildscript {
  repositories {
    maven {
      url = uri("https://plugins.gradle.org/m2/")
    }
  }
  dependencies {
    classpath("gradle.plugin.com.github.monosoul:markdown-page-generator-gradle-plugin:2.4.0.0")
  }
}

apply(plugin = "com.github.monosoul.markdown.page.generator")

Prerequisites

Just Gradle, nothing else is needed.

Usage example

Using Kotlin DSL:

plugins {
  id("com.github.monosoul.markdown.page.generator") version "2.4.0.0"
}

tasks {

    named<GenerateHtmlTask>("generateHtml") {
        dependsOn(processResources)

        val encoding = "UTF-8"

        recursiveInput.set(true)
        pegdownExtensions.set("TABLES,FENCED_CODE_BLOCKS")
        inputEncoding.set(encoding)
        outputEncoding.set(encoding)

        val sourceDir = project.layout.buildDirectory.dir("resources/main/markdown")
        val outputDir = project.layout.buildDirectory.dir("html")

        inputDirectory.set(sourceDir)
        outputDirectory.set(outputDir)
        headerHtmlFile.set(sourceDir.file("header.html"))
        footerHtmlFile.set(sourceDir.file("footer.html"))
        transformRelativeMarkdownLinks.set(true)
    }
}

This way execution of the task named generateHtml would also cause the task processResources execution so processed resources would be used for the html generation.

Configuration options

You can find the detailed configuration options description in the the maven markdown-page-generator-plugin's readme.

License

The software is licensed under the Apache-2.0 License.