summaryrefslogtreecommitdiff
path: root/src/main/kotlin/moe/nea/blog/md/ItalicsParser.kt
diff options
context:
space:
mode:
authorLinnea Gräf <nea@nea.moe>2024-03-24 15:24:05 +0100
committerLinnea Gräf <nea@nea.moe>2024-03-24 15:24:05 +0100
commitbe66c61d729fe642e3dd3ed2214990f9f2273c5e (patch)
tree9a360bc61aaedd6b69518914b1c76ed0cd512ea3 /src/main/kotlin/moe/nea/blog/md/ItalicsParser.kt
parentc57016dc5a1f502b637c2f77bcf724165387ef83 (diff)
downloadblog-infra-be66c61d729fe642e3dd3ed2214990f9f2273c5e.tar.gz
blog-infra-be66c61d729fe642e3dd3ed2214990f9f2273c5e.tar.bz2
blog-infra-be66c61d729fe642e3dd3ed2214990f9f2273c5e.zip
Fix whitespace trimming
Diffstat (limited to 'src/main/kotlin/moe/nea/blog/md/ItalicsParser.kt')
-rw-r--r--src/main/kotlin/moe/nea/blog/md/ItalicsParser.kt8
1 files changed, 4 insertions, 4 deletions
diff --git a/src/main/kotlin/moe/nea/blog/md/ItalicsParser.kt b/src/main/kotlin/moe/nea/blog/md/ItalicsParser.kt
index afecf79..30b5c38 100644
--- a/src/main/kotlin/moe/nea/blog/md/ItalicsParser.kt
+++ b/src/main/kotlin/moe/nea/blog/md/ItalicsParser.kt
@@ -23,7 +23,7 @@ object ItalicsParser : InlineParser {
val firstSequence = mutableListOf<MarkdownFormat>()
var remainingText = text.substring(firstStarCount)
var lastToken: MarkdownFormat = Begin() // TODO: dedicated begin token
- while (true) {
+ while (remainingText.isNotEmpty()) {
val (element, next) = parser.parseInlineTextOnce(lastToken, remainingText)
remainingText = next
lastToken = element
@@ -42,7 +42,7 @@ object ItalicsParser : InlineParser {
if (secondStarCount < 1) error("Invalid italics/bold sequence")
remainingText = remainingText.substring(secondStarCount)
- var firstElement = parser.collapseInlineFormat(firstSequence)
+ var firstElement = parser.collapseInlineFormat(firstSequence, false)
if (secondStarCount == 2)
firstElement = Bold(firstElement)
if (secondStarCount == 1)
@@ -57,7 +57,7 @@ object ItalicsParser : InlineParser {
val secondSequence = mutableListOf<MarkdownFormat>()
lastToken = Begin()
- while (true) {
+ while (remainingText.isNotEmpty()) {
val (element, next) = parser.parseInlineTextOnce(lastToken, remainingText)
remainingText = next
lastToken = element
@@ -79,7 +79,7 @@ object ItalicsParser : InlineParser {
if (thirdStarCount != firstStarCount - secondStarCount) {
error("Invalid italics/bold sequence")
}
- var secondElement = parser.collapseInlineFormat(secondSequence)
+ var secondElement = parser.collapseInlineFormat(secondSequence, false)
var combined: MarkdownFormat = FormatSequence(firstElement, secondElement)
if (thirdStarCount == 1)
combined = Italics(combined)