diff options
author | Dmitry Jemerov <yole@jetbrains.com> | 2016-03-31 21:04:27 +0200 |
---|---|---|
committer | Dmitry Jemerov <yole@jetbrains.com> | 2016-03-31 21:04:27 +0200 |
commit | 792ae5c4099c7a37815888cd1313404375453eea (patch) | |
tree | e548045fd0095415f3d530149ca0385bd9831aa0 /core/src/main/kotlin | |
parent | 07a6e686db79bf7279381bccad79a0d4842f95c2 (diff) | |
download | dokka-792ae5c4099c7a37815888cd1313404375453eea.tar.gz dokka-792ae5c4099c7a37815888cd1313404375453eea.tar.bz2 dokka-792ae5c4099c7a37815888cd1313404375453eea.zip |
Don't lose line breaks in code blocks. Resolves #54
Diffstat (limited to 'core/src/main/kotlin')
4 files changed, 10 insertions, 10 deletions
diff --git a/core/src/main/kotlin/Formats/HtmlFormatService.kt b/core/src/main/kotlin/Formats/HtmlFormatService.kt index 6ac2a405..ebc4ce22 100644 --- a/core/src/main/kotlin/Formats/HtmlFormatService.kt +++ b/core/src/main/kotlin/Formats/HtmlFormatService.kt @@ -27,9 +27,9 @@ open class HtmlFormatService @Inject constructor(@Named("folders") locationServi return "<span class=\"identifier\"$id>${formatText(text)}</span>" } - override fun appendBlockCode(to: StringBuilder, line: String, language: String) { + override fun appendBlockCode(to: StringBuilder, lines: List<String>, language: String) { to.append("<pre><code>") - to.append(line) + to.append(lines.joinToString("\n")) to.append("</code></pre>") } diff --git a/core/src/main/kotlin/Formats/KotlinWebsiteFormatService.kt b/core/src/main/kotlin/Formats/KotlinWebsiteFormatService.kt index 9a739216..56544165 100644 --- a/core/src/main/kotlin/Formats/KotlinWebsiteFormatService.kt +++ b/core/src/main/kotlin/Formats/KotlinWebsiteFormatService.kt @@ -107,12 +107,12 @@ class KotlinWebsiteFormatService @Inject constructor(locationService: LocationSe to.appendln("\n</td>") } - override fun appendBlockCode(to: StringBuilder, line: String, language: String) { + override fun appendBlockCode(to: StringBuilder, lines: List<String>, language: String) { if (language.isNotEmpty()) { - super.appendBlockCode(to, line, language) + super.appendBlockCode(to, lines, language) } else { to.append("<pre markdown=\"1\">") - to.append(line.trimStart()) + to.append(lines.joinToString { "\n" }.trimStart()) to.append("</pre>") } } diff --git a/core/src/main/kotlin/Formats/MarkdownFormatService.kt b/core/src/main/kotlin/Formats/MarkdownFormatService.kt index 4f5b9751..21470141 100644 --- a/core/src/main/kotlin/Formats/MarkdownFormatService.kt +++ b/core/src/main/kotlin/Formats/MarkdownFormatService.kt @@ -67,10 +67,10 @@ open class MarkdownFormatService(locationService: LocationService, appendLine(to) } - override fun appendBlockCode(to: StringBuilder, line: String, language: String) { + override fun appendBlockCode(to: StringBuilder, lines: List<String>, language: String) { appendLine(to) - to.appendln("``` ${language}") - to.appendln(line) + to.appendln(if (language.isEmpty()) "```" else "``` $language") + to.appendln(lines.joinToString("\n")) to.appendln("```") appendLine(to) } diff --git a/core/src/main/kotlin/Formats/StructuredFormatService.kt b/core/src/main/kotlin/Formats/StructuredFormatService.kt index 85b7d3c1..15a4dfba 100644 --- a/core/src/main/kotlin/Formats/StructuredFormatService.kt +++ b/core/src/main/kotlin/Formats/StructuredFormatService.kt @@ -16,7 +16,7 @@ abstract class StructuredFormatService(locationService: LocationService, val linkExtension: String = extension) : FormatService { val locationService: LocationService = locationService.withExtension(linkExtension) - abstract fun appendBlockCode(to: StringBuilder, line: String, language: String) + abstract fun appendBlockCode(to: StringBuilder, lines: List<String>, language: String) abstract fun appendHeader(to: StringBuilder, text: String, level: Int = 1) abstract fun appendParagraph(to: StringBuilder, text: String) abstract fun appendLine(to: StringBuilder, text: String = "") @@ -92,7 +92,7 @@ abstract class StructuredFormatService(locationService: LocationService, } } is ContentParagraph -> appendParagraph(to, formatText(location, content.children)) - is ContentBlockCode -> appendBlockCode(to, formatText(location, content.children), content.language) + is ContentBlockCode -> appendBlockCode(to, content.children.map { formatText(location, it) }, content.language) is ContentHeading -> appendHeader(to, formatText(location, content.children), content.level) is ContentBlock -> to.append(formatText(location, content.children)) } |