Fix various spacing things
authorLanius Trolling <lanius@laniustrolling.dev>
Sun, 31 Mar 2024 16:09:25 +0000 (12:09 -0400)
committerLanius Trolling <lanius@laniustrolling.dev>
Sun, 31 Mar 2024 16:09:25 +0000 (12:09 -0400)
src/jvmMain/kotlin/info/mechyrdia/lore/parser.kt
src/jvmMain/kotlin/info/mechyrdia/lore/parser_tags.kt

index 26ea99d097fa1a9b8d0f64dc05cc2f527000d67c..2b6cf90be001beecc44155408df4f8590efe712b 100644 (file)
@@ -39,7 +39,7 @@ sealed class TextParserState<TContext>(
                        else
                                "</p><p>"
                } else
-                       "<br/>"
+                       "<br/><br/>"
                
                appendTextRaw(newline)
        }
@@ -103,7 +103,7 @@ sealed class TextParserState<TContext>(
                                PlainText(scope, "", insideTags, internalState)
                        } else if (newText.endsWith('\n')) {
                                appendText(newText.removeSuffix("\n"))
-                               appendTextRaw("<br/>")
+                               appendTextRaw("<br/><br/>")
                                NoFormatText(scope, "", insideTags, internalState)
                        } else
                                NoFormatText(scope, newText, insideTags, internalState)
index e37dc197797c6b05cda182c37eee7592529dc7fa..35177c57e57e1022e590a210bac4ed17d954e097 100644 (file)
@@ -542,4 +542,4 @@ fun headerContentToAnchor(content: String) = headerContentToLabel(content).repla
 fun imagePathToOpenGraphValue(path: String) = "https://mechyrdia.info/assets/images/${sanitizeLink(path)}"
 fun descriptionContentToPlainText(content: String) = TextParserState.uncensorText(content.replace(INSIDE_TAG_TEXT, ""))
 
-fun commentToPlainText(contentRaw: String) = TextParserState.uncensorText(TextParserState.parseText(contentRaw, TextParserCommentTagsPlainText.asTags, Unit).replace("<p>", "").replace("</p>", "").replace("<br/>", ""))
+fun commentToPlainText(contentRaw: String) = TextParserState.uncensorText(TextParserState.parseText(contentRaw, TextParserCommentTagsPlainText.asTags, Unit).replace("<p>", " ").replace("</p>", " ").replace("<br/>", " ").replace(Regex("\\s+"), " "))