exportMarkdown

Johannes Thorn Ralf D. Müller

1 minute to read

About This Task

The exportMarkdown task can be used to include markdown files into the documentation. It scans the /src/docs directory for markdown (*.md) files and converts them into Asciidoc files. The converted files can then be referenced from within the /build-folder.

Source

Show source code of scripts/exportMarkdown.gradle or go directly to GitHub · docToolchain/scripts/exportMarkdown.gradle.
scripts/exportMarkdown.gradle
task exportMarkdown(
        description: 'exports all markdown files to AsciiDoc',
        group: 'docToolchain',
        type: Copy
) {
    from srcDir

    include("**/*.md") //include only markdown files
    includeEmptyDirs = false
    rename(/(.+).md/, '$1.adoc') //rename all files from *.md to *.adoc
    filter(Markdown2AdocFilter) // convert the content of the files

    into targetDir
}

class Markdown2AdocFilter extends FilterReader {
    Markdown2AdocFilter(Reader input) {
        super(new StringReader(nl.jworks.markdown_to_asciidoc.Converter.convertMarkdownToAsciiDoc(input.text)))
    }
}