a(href = "https://google.com/") { +"HTML link" }
}
}
+ tr {
+ td { +"[imgbb=256x256]Lns12z1/robert-sparr.png[/imgbb]" }
+ td {
+ p {
+ +"Creates an embedded image:"
+ br
+ unsafe {
+ raw("<script>window.appendImageThumb('https://i.ibb.co/Lns12z1/robert-sparr.png', '${getImageSizeStyleValue(256, 256)}');</script>")
+ }
+ br
+ +"The tag param controls the width and height, much like a table cell. The size unit is viewport-responsive and has no correlation with pixels."
+ }
+ p {
+ +"A similar tag is used to embed images that are hosted on Imgur, e.g. the image at https://i.imgur.com/dd0mmQ1.png"
+ br
+ unsafe {
+ raw("<script>window.appendImageThumb('https://i.imgur.com/dd0mmQ1.png', '${getImageSizeStyleValue(250, 323)}');</script>")
+ }
+ br
+ +"can be embedded using [imgur=250x323]dd0mmQ1.png[/imgur]"
+ }
+ }
+ }
tr {
td { +"[reply](comment id)[/reply]" }
td { +"Creates a reply link to a comment" }
LANG(TextParserFormattingTag.LANG.type),
+ IMGUR(
+ TextParserTagType.Indirect { tagParam, content, _ ->
+ val imageUrl = sanitizeExtLink(content)
+ val (width, height) = getSizeParam(tagParam)
+
+ "<script>window.appendImageThumb('https://i.imgur.com/$imageUrl', '${getImageSizeStyleValue(width, height)}');</script>"
+ }
+ ),
+ IMGBB(
+ TextParserTagType.Indirect { tagParam, content, _ ->
+ val imageUrl = sanitizeExtLink(content)
+ val (width, height) = getSizeParam(tagParam)
+
+ "<script>window.appendImageThumb('https://i.ibb.co/$imageUrl', '${getImageSizeStyleValue(width, height)}');</script>"
+ }
+ ),
+
REPLY(
TextParserTagType.Indirect { _, content, _ ->
sanitizeId(content)?.let { id ->
val DOT_CHARS = Regex("\\.+")
fun sanitizeLink(html: String) = html.replace(NON_LINK_CHAR, "").replace(DOT_CHARS, ".")
+val NON_EXT_LINK_CHAR = Regex("[^#a-zA-Z\\d\\-._/]")
+fun sanitizeExtLink(html: String) = html.replace(NON_EXT_LINK_CHAR, "").replace(DOT_CHARS, ".")
+
val ID_REGEX = Regex("[A-IL-TVX-Z0-9]{24}")
fun sanitizeId(html: String) = ID_REGEX.matchEntire(html)?.value