Skip to content

Instantly share code, notes, and snippets.

@lavcraft
Created September 14, 2016 17:33
Show Gist options
  • Save lavcraft/6d733cb8d410522972b85c3d3b094968 to your computer and use it in GitHub Desktop.
Save lavcraft/6d733cb8d410522972b85c3d3b094968 to your computer and use it in GitHub Desktop.
buildscript {
repositories { jcenter() }
dependencies { classpath 'org.pegdown:pegdown:1.5.0' }
}
import org.pegdown.PegDownProcessor
task md {
def mp = new PegDownProcessor(org.pegdown.Extensions.ALL)
ext.outputDir = new File(buildDir, 'readme_html')
ext.outputFile = new File(outputDir, 'readme.html')
inputs.file file("README.md")
outputs.dir outputDir
outputs.dir outputFile
doLast {
def html = mp.markdownToHtml(file('README.md').text)
outputDir.mkdirs()
outputFile << """
<html>
<head><meta charset=\"utf-8\"></head>
$html
</html>
"""
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment