summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorLinnea Gräf <nea@nea.moe>2024-04-29 16:11:35 +0200
committerLinnea Gräf <nea@nea.moe>2024-04-29 16:11:35 +0200
commit1ff704d63c057f0fca37b27cf0259e3c5af7299f (patch)
treec8073191cf879c449c97b63f58cabcefefaa4674 /src
parent9513802ef7637a469c72a2dedd68d5bf9215ba4d (diff)
downloadblog-infra-1ff704d63c057f0fca37b27cf0259e3c5af7299f.tar.gz
blog-infra-1ff704d63c057f0fca37b27cf0259e3c5af7299f.tar.bz2
blog-infra-1ff704d63c057f0fca37b27cf0259e3c5af7299f.zip
Allow inlining italics
Diffstat (limited to 'src')
-rw-r--r--src/main/kotlin/moe/nea/blog/md/ItalicsParser.kt7
-rw-r--r--src/test/kotlin/moe/nea/blog/md/test/TestItalics.kt6
2 files changed, 11 insertions, 2 deletions
diff --git a/src/main/kotlin/moe/nea/blog/md/ItalicsParser.kt b/src/main/kotlin/moe/nea/blog/md/ItalicsParser.kt
index 6fce529..5448f5f 100644
--- a/src/main/kotlin/moe/nea/blog/md/ItalicsParser.kt
+++ b/src/main/kotlin/moe/nea/blog/md/ItalicsParser.kt
@@ -2,7 +2,7 @@ package moe.nea.blog.md
object ItalicsParser : InlineParser {
override fun detect(lookback: MarkdownFormat, rest: String): Boolean {
- return (lookback is Whitespace || lookback is Begin) && "\\*+[^* ].*".toRegex().matches(rest)
+ return "\\*+[^* ].*".toRegex().matches(rest)
}
override val specialSyntax: Set<Char>
@@ -43,7 +43,10 @@ object ItalicsParser : InlineParser {
}
// TODO: better begin
- val (secondSequence, _remainingText) = parser.parseInlineTextUntil(remainingText, Begin()) { lookback, remaining ->
+ val (secondSequence, _remainingText) = parser.parseInlineTextUntil(
+ remainingText,
+ Begin()
+ ) { lookback, remaining ->
lookback !is Whitespace && remaining.startsWith("*")
}
remainingText = _remainingText
diff --git a/src/test/kotlin/moe/nea/blog/md/test/TestItalics.kt b/src/test/kotlin/moe/nea/blog/md/test/TestItalics.kt
index dee92bd..01bd49e 100644
--- a/src/test/kotlin/moe/nea/blog/md/test/TestItalics.kt
+++ b/src/test/kotlin/moe/nea/blog/md/test/TestItalics.kt
@@ -15,6 +15,12 @@ class TestItalics : MarkdownTest() {
}
@Test
+ fun testBeginningInTheMiddleOfTheWord() {
+ assertInlineFormat("inoneword<i>italic</i>", "inoneword*italic*")
+ assertInlineFormat("<i>multiple</i>inoneword<i>italic</i>", "*multiple*inoneword*italic*")
+ }
+
+ @Test
fun otherMarkdownInItalics() {
assertInlineFormat(
"<i><link target=https://nea.moe><b>test</b></link></i>",