Skip to content

Commit 9682e73

Browse files
committed
fix: indent list with 3 spaces
This fixes the issues with more than two levels of list on dev.to. Closes #8
1 parent bdd5f71 commit 9682e73

File tree

7 files changed

+22
-23
lines changed

7 files changed

+22
-23
lines changed

src/commonMain/kotlin/ch/derlin/bitdowntoc/BitGenerator.kt

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@ object BitGenerator {
77
private const val tocMarker = "[TOC]"
88

99
private val headerRegex = Regex("(#+) +([^ ]+.*)")
10-
private val codeRegex = Regex("^```\\w* *$")
1110

1211
data class Params(
1312
val indentChars: String = BitOptions.indentChars.default,

src/commonMain/kotlin/ch/derlin/bitdowntoc/Toc.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ class Toc(
4040
val minIndent = if (trimTocIndent) entries.minOf { it.indent } else 0
4141
return entries.joinToString("\n") { (indent, text, link) ->
4242
(indent - minIndent).let {
43-
" ".repeat(it * 2) + "${indentCharacters[it % indentCharacters.length]} [$text](#$link)"
43+
" ".repeat(it * 3) + "${indentCharacters[it % indentCharacters.length]} [$text](#$link)"
4444
}
4545
}
4646
}

src/commonTest/kotlin/ch.derlin.bitdowntoc/GenerateTest.kt

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ class GenerateTest {
5454
<!-- TOC start (generated with $BITDOWNTOC_URL) -->
5555
5656
- [heading](#heading)
57-
* [subheading](#subheading)
57+
* [subheading](#subheading)
5858
- [heading](#heading-1)
5959
6060
<!-- TOC end -->
@@ -146,7 +146,7 @@ class GenerateTest {
146146
<!-- TOC start (generated with $BITDOWNTOC_URL) -->
147147
148148
- [heading](#heading)
149-
* [subheading](#subheading)
149+
* [subheading](#subheading)
150150
- [heading](#heading-1)
151151
152152
<!-- TOC end -->
@@ -208,7 +208,7 @@ class GenerateTest {
208208
assertEquals(
209209
"""
210210
- [Some readme](#some-readme)
211-
* [hello](#hello)
211+
* [hello](#hello)
212212
213213
<a name="some-readme"></a>
214214
# Some readme
@@ -277,7 +277,7 @@ class GenerateTest {
277277
<!-- TOC start (generated with $BITDOWNTOC_URL) -->
278278
279279
- [h1](#h1)
280-
* [h2](#h2)
280+
* [h2](#h2)
281281
282282
<!-- TOC end -->
283283

src/commonTest/kotlin/ch.derlin.bitdowntoc/UpdateAnchorsTest.kt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ class UpdateAnchorsTest {
3737
<!-- TOC start (generated with $BITDOWNTOC_URL) -->
3838
3939
- [modified heading](#modified-heading)
40-
* [sub heading different](#sub-heading-different)
40+
* [sub heading different](#sub-heading-different)
4141
- [Hello World !](#hello-world-)
4242
4343
<!-- TOC end -->
@@ -87,7 +87,7 @@ class UpdateAnchorsTest {
8787
<!-- TOC start (generated with $BITDOWNTOC_URL) -->
8888
8989
- [modified heading](#modified-heading)
90-
* [sub heading different](#sub-heading-different)
90+
* [sub heading different](#sub-heading-different)
9191
- [Hello World !](#hello-world-)
9292
9393
<!-- TOC end -->

src/jvmTest/resources/output.md

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
11
<!-- TOC start (generated with https://github.com/derlin/bitdowntoc) -->
22

33
- [A heading with spaces](#a-heading-with-spaces)
4-
* [Some '??&%' strange :) characters](#some-strange-characters)
5-
* [😋 Get Emoji — All Emojis to Copy and 📋 Paste 👌](#-get-emoji-all-emojis-to-copy-and-paste-)
6-
+ [Russian text is not supported](#russian-text-is-not-supported)
7-
- [dès la matinée, ça gït](#dès-la-matinée-ça-gït)
4+
* [Some '??&%' strange :) characters](#some-strange-characters)
5+
* [😋 Get Emoji — All Emojis to Copy and 📋 Paste 👌](#-get-emoji-all-emojis-to-copy-and-paste-)
6+
+ [Russian text is not supported](#russian-text-is-not-supported)
7+
- [dès la matinée, ça gït](#dès-la-matinée-ça-gït)
88
- [this is a duplicate](#this-is-a-duplicate)
99
- [this is a duplicate](#this-is-a-duplicate-1)
1010
- [this is a duplicate](#this-is-a-duplicate-2)
11-
* [?)= ALKJDFEEE*ç](#-alkjdfeeeç)
11+
* [?)= ALKJDFEEE*ç](#-alkjdfeeeç)
1212

1313
<!-- TOC end -->
1414

src/jvmTest/resources/toc-github.md

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
<!-- TOC start (generated with https://github.com/derlin/bitdowntoc) -->
22

33
- [A heading with spaces](#a-heading---with---spaces)
4-
* [Some '??&%' strange :) characters](#some--strange--characters)
5-
* [😋 Get Emoji — All Emojis to Copy and 📋 Paste 👌](#-get-emoji--all-emojis-to-copy-and--paste-)
6-
+ [Russian text is not supported](#russian-text-is-not-supported)
7-
- [dès la matinée, ça gït](#dès-la-matinée-ça-gït)
4+
* [Some '??&%' strange :) characters](#some--strange--characters)
5+
* [😋 Get Emoji — All Emojis to Copy and 📋 Paste 👌](#-get-emoji--all-emojis-to-copy-and--paste-)
6+
+ [Russian text is not supported](#russian-text-is-not-supported)
7+
- [dès la matinée, ça gït](#dès-la-matinée-ça-gït)
88
- [this is a duplicate](#this-is-a-duplicate)
99
- [this is a duplicate](#this-is-a-duplicate-1)
1010
- [this is a duplicate](#this-is---a-duplicate)
11-
* [?)= ALKJDFEEE*ç](#-alkjdfeeeç)
11+
* [?)= ALKJDFEEE*ç](#-alkjdfeeeç)
1212

1313
<!-- TOC end -->

src/jvmTest/resources/toc-gitlab.md

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
<!-- TOC start (generated with https://github.com/derlin/bitdowntoc) -->
22

33
- [A heading with spaces](#a-heading-with-spaces)
4-
* [Some '??&%' strange :) characters](#some-strange-characters)
5-
* [😋 Get Emoji — All Emojis to Copy and 📋 Paste 👌](#-get-emoji-all-emojis-to-copy-and-paste-)
6-
+ [Russian text is not supported](#russian-text-is-not-supported)
7-
- [dès la matinée, ça gït](#dès-la-matinée-ça-gït)
4+
* [Some '??&%' strange :) characters](#some-strange-characters)
5+
* [😋 Get Emoji — All Emojis to Copy and 📋 Paste 👌](#-get-emoji-all-emojis-to-copy-and-paste-)
6+
+ [Russian text is not supported](#russian-text-is-not-supported)
7+
- [dès la matinée, ça gït](#dès-la-matinée-ça-gït)
88
- [this is a duplicate](#this-is-a-duplicate)
99
- [this is a duplicate](#this-is-a-duplicate-1)
1010
- [this is a duplicate](#this-is-a-duplicate-2)
11-
* [?)= ALKJDFEEE*ç](#-alkjdfeeeç)
11+
* [?)= ALKJDFEEE*ç](#-alkjdfeeeç)
1212

1313
<!-- TOC end -->

0 commit comments

Comments
 (0)