From 71cd87e239ba4ba846eb5da04e45a451b8a840cb Mon Sep 17 00:00:00 2001 From: Ilya Ryzhenkov Date: Fri, 3 Oct 2014 22:51:44 +0400 Subject: Resolve links in docs. --- src/Formats/HtmlFormatService.kt | 4 ++++ src/Formats/MarkdownFormatService.kt | 6 +++++- src/Formats/StructuredFormatService.kt | 5 +++++ 3 files changed, 14 insertions(+), 1 deletion(-) (limited to 'src/Formats') diff --git a/src/Formats/HtmlFormatService.kt b/src/Formats/HtmlFormatService.kt index 06b41518..20cd4f83 100644 --- a/src/Formats/HtmlFormatService.kt +++ b/src/Formats/HtmlFormatService.kt @@ -81,6 +81,10 @@ public open class HtmlFormatService(locationService: LocationService, return "${text}" } + override fun formatLink(text: String, href: String): String { + return "${text}" + } + override fun formatBold(text: String): String { return "${text}" } diff --git a/src/Formats/MarkdownFormatService.kt b/src/Formats/MarkdownFormatService.kt index cb1d713c..bbe0d7be 100644 --- a/src/Formats/MarkdownFormatService.kt +++ b/src/Formats/MarkdownFormatService.kt @@ -35,7 +35,11 @@ public open class MarkdownFormatService(locationService: LocationService, } override public fun formatLink(text: String, location: Location): String { - return "[${text}](${location.path})" + return "[$text](${location.path})" + } + + override fun formatLink(text: String, href: String): String { + return "[$text]($href)" } override public fun appendLine(to: StringBuilder) { diff --git a/src/Formats/StructuredFormatService.kt b/src/Formats/StructuredFormatService.kt index b974dcf8..df11b835 100644 --- a/src/Formats/StructuredFormatService.kt +++ b/src/Formats/StructuredFormatService.kt @@ -25,6 +25,7 @@ public abstract class StructuredFormatService(val locationService: LocationServi public abstract fun formatKeyword(text: String): String public abstract fun formatIdentifier(text: String): String public abstract fun formatLink(text: String, location: Location): String + public abstract fun formatLink(text: String, href: String): String public open fun formatLink(link: FormatLink): String = formatLink(formatText(link.text), link.location) public abstract fun formatBold(text: String): String public abstract fun formatCode(code: String): String @@ -47,6 +48,10 @@ public abstract class StructuredFormatService(val locationService: LocationServi val linkText = formatText(location, content.children) append(formatLink(linkText, linkTo)) } + is ContentExternalLink -> { + val linkText = formatText(location, content.children) + append(formatLink(linkText, content.href)) + } else -> append(formatText(location, content.children)) } }.toString() -- cgit