Skip to content

Commit

Permalink
Fix non-pretty HTML output
Browse files Browse the repository at this point in the history
  • Loading branch information
ileasile committed May 4, 2020
1 parent 9c1b127 commit 55c9d6c
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion src/main/kotlin/org/ileasile/kformat/visitors/HtmlVisitor.kt
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,14 @@ class HtmlVisitor(
private val pretty: Boolean = false
) :
AbstractAdaptableVisitor<String>() {
private val joiner = if (pretty) "\n" else ""

override fun visitSimpleText(block: SimpleTextBlock): String = block.content

override fun visitFormatText(block: FormatTextBlock): String =
StringTagsStack().apply {
addFormat(block.format)
this.contents = block.children.joinToString("\n", transform = this@HtmlVisitor::visitChild)
this.contents = block.children.joinToString(joiner, transform = this@HtmlVisitor::visitChild)
}.run {
if (pretty)
finalizeIndent()
Expand Down

0 comments on commit 55c9d6c

Please sign in to comment.