Convert Markdown to Asciidoc
As part of migration you might need to convert Markdown to AsciiDoc OR maybe you have tools that only produce Markdown and you need to have the final result in AsciiDoc because your documentation system is built upon a standardised documentation markup language.
Using kramdown-asciidoc this is possible and that tool is offered as part of the larger Asciidoctor Gradle plugin suite.
As this tool is not using AsciiDoc as its input sources it has a different DSL to the rest of the configuration model.
-
Groovy
plugins {
id 'org.asciidoctor.kramdown' version '5.1.0'
}
kramdownAsciidoc {
toolchains {
kramdown { (1)
format = 'parse' (2)
useKramdownAsciidoc('2.1.1') (3)
useJRuby('9.1.2.3') (4)
registeredOutputFormatters {
asciidoc { (5)
diagramLanguages = ['plantuml'] (6)
diagramLanguages 'mermaid' (7)
passthruHtml = true (8)
wrap = 'preserve` (9)
headingOffset = 2 (10)
autoLinks = true (11)
autoIds {
prefix = 'foo' (12)
separator = ',' (13)
dropLazyValues = true (14)
generate = true (15)
}
attributes { (16)
add 'foo', 'bar'
}
}
}
}
}
publications {
main {
sourceSet {
sourceDir = 'src/docs/markdown' (17)
imagesDir = 'path/images' (18)
}
output 'kramdown', 'asciidoc' (19)
output 'kramdown', 'asciidoc', 'foo' (20)
}
}
}
| 1 | The default toolchain is called kramdoc. |
| 2 | Sets the format to parse.
One of gfm, markdown or kramdoc.
String is case-insensitive.
Default is gfm. |
| 3 | Override the default version of Kramdown. |
| 4 | Override the default version of JRuby. |
| 5 | Configure one or more output formatters.
The conventions plugin org.asciidoctor.kramdown will add an output formatter called asciidoc. |
| 6 | Set the source languages to interpret as diagrams.
If not set, the defaults are plantuml and mermaid. |
| 7 | Add more source language to treat as diagrams. |
| 8 | Whether to pass HTML through as-is or convert it to Asciidoc syntax where possible.
The default is to convert to HTML i.e. true. |
| 9 | Set how lines are wrapped in the AsciiDoc document.
One of preserve, none or ventilate.
The default is preserve. |
| 10 | Changes the heading offset. The number can be negative or positive. |
| 11 | Whether to automatically convert bare URLs into links. The default is to convert. |
| 12 | The prefix to use for auto-generated section title IDs. Anything convertible to a string can be supplied. |
| 13 | The separator char to use for auto-generated section title IDs. |
| 14 | Whether to drop IDs that match the values of auto-generated IDs. |
| 15 | Whether to auto-generate IDs for all section titles. The default is not to generate IDs. |
| 16 | Add attributes to the AsciiDoc document header. |
| 17 | There is no default setting for the source directory and it needs to be set here. |
| 18 | Optionally, set the imagesdir attribute in the AsciiDoc document header and remove the value from the start of image paths. |
| 19 | Create an output by specifying the toolchain to use and the output formatter name. |
| 20 | You can also specify an alias for the output name |