-
Notifications
You must be signed in to change notification settings - Fork 31
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Also improve formatting. Co-authored-by: Fabian Illner <fabian.illner@dm.de>
- Loading branch information
1 parent
f346218
commit b72f3e0
Showing
3 changed files
with
24 additions
and
24 deletions.
There are no files selected for viewing
23 changes: 23 additions & 0 deletions
23
src/main/kotlin/nl/avisi/structurizr/site/generatr/site/model/Asciidoctor.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,30 @@ | ||
package nl.avisi.structurizr.site.generatr.site.model | ||
|
||
import org.asciidoctor.Asciidoctor | ||
import org.asciidoctor.ast.ContentNode | ||
import org.asciidoctor.ast.Document | ||
import org.asciidoctor.ast.StructuralNode | ||
import org.asciidoctor.converter.ConverterFor | ||
import org.asciidoctor.converter.StringConverter | ||
|
||
val asciidoctor: Asciidoctor = Asciidoctor.Factory.create().apply { | ||
javaConverterRegistry().register(AsciiDocTextConverter::class.java) | ||
} | ||
|
||
@ConverterFor("text") | ||
class AsciiDocTextConverter( | ||
backend: String?, | ||
opts: Map<String?, Any?>? | ||
) : StringConverter(backend, opts) { | ||
override fun convert(node: ContentNode, transform: String?, o: Map<Any?, Any?>?): String? { | ||
val transform1 = transform ?: node.nodeName | ||
return if (node is Document) | ||
node.content.toString() | ||
else if (node is org.asciidoctor.ast.Section) | ||
"${node.title}\n${node.content}" | ||
else if (transform1 == "preamble" || transform1 == "paragraph") | ||
(node as StructuralNode).content as String | ||
else | ||
null | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters