Mark links in comments as UGC
authorLanius Trolling <lanius@laniustrolling.dev>
Thu, 28 Dec 2023 18:18:35 +0000 (13:18 -0500)
committerLanius Trolling <lanius@laniustrolling.dev>
Thu, 28 Dec 2023 18:18:35 +0000 (13:18 -0500)
src/jvmMain/kotlin/info/mechyrdia/lore/parser_tags.kt

index 60479cdeb34f472c58440b1d6f1585417257535b..7f1d52420cb2740e6404ea1012e8c6cb83350f29 100644 (file)
@@ -393,7 +393,15 @@ enum class TextParserCommentTags(val type: TextParserTagType<Unit>) {
        TR(TextParserFormattingTag.TR.type),
        TD(TextParserFormattingTag.TD.type),
        TH(TextParserFormattingTag.TH.type),
-       URL(TextParserFormattingTag.EXTLINK.type),
+       URL(TextParserTagType.Direct(
+               { tagParam, _ ->
+                       val url = tagParam?.let { TextParserState.censorText(it) }
+                       val attr = url?.let { " href=\"$it\" rel=\"ugc nofollow\"" } ?: ""
+                       
+                       "<a$attr>"
+               },
+               { "</a>" },
+       )),
        
        LANG(TextParserFormattingTag.LANG.type),
        
@@ -417,7 +425,7 @@ enum class TextParserCommentTags(val type: TextParserTagType<Unit>) {
        REPLY(
                TextParserTagType.Indirect { _, content, _ ->
                        sanitizeId(content)?.let { id ->
-                               "<a href=\"/comment/view/$id\">&gt;&gt;$id</a>"
+                               "<a href=\"/comment/view/$id\" rel=\"ugc\">&gt;&gt;$id</a>"
                        } ?: "[reply]$content[/reply]"
                }
        ),