aboutsummaryrefslogtreecommitdiff
path: root/src/Formats
diff options
context:
space:
mode:
Diffstat (limited to 'src/Formats')
-rw-r--r--src/Formats/HtmlFormatService.kt4
-rw-r--r--src/Formats/MarkdownFormatService.kt6
-rw-r--r--src/Formats/StructuredFormatService.kt5
3 files changed, 14 insertions, 1 deletions
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 "<a href=\"${location.path}\">${text}</a>"
}
+ override fun formatLink(text: String, href: String): String {
+ return "<a href=\"${href}\">${text}</a>"
+ }
+
override fun formatBold(text: String): String {
return "<b>${text}</b>"
}
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()