Skip to content

Commit 31588d2

Browse files
committed
feat!: replace em-dash's current replacement with en-dash. add em-dash as --
1 parent f439ed8 commit 31588d2

File tree

4 files changed

+14
-6
lines changed

4 files changed

+14
-6
lines changed

quarkdown-core/src/main/kotlin/com/quarkdown/core/lexer/patterns/TextSymbolReplacement.kt

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,11 +28,16 @@ enum class TextSymbolReplacement(
2828
TRADEMARK('', "\\(TM\\)".toRegex()),
2929

3030
/**
31-
* `-` -> `—`
31+
* `--` -> `—`
32+
*/
33+
EM_DASH('', "--".toRegex()),
34+
35+
/**
36+
* `-` -> `–`
3237
*
3338
* It must be surrounded by a word character and a space on both sides.
3439
*/
35-
EM_DASH('', "(?<=\\w\\s)-(?=\\s\\w)".toRegex()),
40+
EN_DASH('', "(?<=\\w\\s)-(?=\\s\\w)".toRegex()),
3641

3742
/**
3843
* `...` -> `…`

quarkdown-core/src/test/kotlin/com/quarkdown/core/LexerTest.kt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -394,6 +394,8 @@ class LexerTest {
394394
assertIs<PlainTextToken>(tokens.next())
395395
assertSymbolEquals(TextSymbolReplacement.SINGLE_LEFT_ARROW)
396396
assertIs<PlainTextToken>(tokens.next())
397+
assertSymbolEquals(TextSymbolReplacement.EN_DASH)
398+
assertIs<PlainTextToken>(tokens.next())
397399
assertSymbolEquals(TextSymbolReplacement.ELLIPSIS)
398400
assertIs<PlainTextToken>(tokens.next()) // Soft line break
399401
assertSymbolEquals(TextSymbolReplacement.TYPOGRAPHIC_LEFT_APOSTROPHE)
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
Hi... this is some text lexed by the Quarkdown (C) flavor - the Turing complete Markdown - which is iamgio's project.
2-
3-1 is 2, which is not 4 => 2 != 4 -> also, 4 <= 8, and 8 >= 4 <- interesting...
1+
Hi... this is some text lexed by the Quarkdown (C) flavor--the Turing-complete Markdown -- which is iamgio's project.
2+
3-1 is 2, which is not 4 => 2 != 4 -> also, 4 <= 8, and 8 >= 4 <- interesting - I should do something about it...
33
'Quarkdown's' source is available on 'GitHub'! "Stars" are much appreciated (TM)
44
This is a "test".

quarkdown-test/src/test/kotlin/com/quarkdown/test/TextTest.kt

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -66,14 +66,15 @@ class TextTest {
6666
execute(
6767
"""
6868
> This is a **"quote"** with 'text *replacement*'.
69-
> This is a feature of Quarkdown - the Turing complete Markdown - by iamgio (C) 2024.
69+
> This is a feature of Quarkdown--the Turing complete Markdown--by iamgio (C) 2024 - all rights reserved.
7070
> => Quarkdown != other Markdown flavors... <-
7171
""".trimIndent(),
7272
) {
7373
assertEquals(
7474
"<blockquote><p>" +
7575
"This is a <strong>&ldquo;quote&rdquo;</strong> with &lsquo;text <em>replacement</em>&rsquo;.<br />" +
76-
"This is a feature of Quarkdown &mdash; the Turing complete Markdown &mdash; by iamgio &copy; 2024.\n" +
76+
"This is a feature of Quarkdown&mdash;the Turing complete Markdown&mdash;by iamgio &copy; 2024 " +
77+
"&ndash; all rights reserved.\n" +
7778
"&rArr; Quarkdown &ne; other Markdown flavors&hellip; &larr;" +
7879
"</p></blockquote>",
7980
it,

0 commit comments

Comments
 (0)