Skip to content

Commit d4946ad

Browse files
committed
fix: regexps for unusual numbering when splitting; plugin description
1 parent 9ad9f9e commit d4946ad

File tree

2 files changed

+7
-7
lines changed

2 files changed

+7
-7
lines changed

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"name": "logseq13-missing-commands",
33
"version": "1.1.0",
4-
"description": "🪚 Sorting blocks, auto heading, split by sentences, remove numbering, etc.",
4+
"description": "🪚 Sorting blocks, tabular view, auto complete in search, split by sentences, remove numbering, etc.",
55
"author": "stdword",
66
"repository": "https://github.com/stdword/logseq13-missing-commands.git",
77
"license": "MIT",

src/commands.ts

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -265,15 +265,15 @@ export function splitByWords(text: string): IBatchBlock[] {
265265
export function magicSplit(text: string): IBatchBlock[] {
266266
// add special types of ordered lists for parser to recognize it
267267
// (1) → 1)
268-
text = text.replaceAll(/^(\s*)\((\d+\)\s)/gm, '$1$2')
269-
// (1.2.3) → 1) and 1.2.3) → 1)
270-
text = text.replaceAll(/^(\s*)\(?(\d+\.)+\d+\)\s/gm, '$11) ')
268+
text = text.replaceAll(/^(\s*)\((\d{1,3}\)\s)/gm, '$1$2')
271269
// 1.2.3. → 1)
272-
text = text.replaceAll(/^(\s*)(\d+\.)+\d+\.\s/gm, '$11) ')
270+
text = text.replaceAll(/^(\s*)((\d|\p{Lowercase_Letter}){1,3}\.){2,10}\s/gmiu, '$11) ') // $11 means $1 and 1
271+
// (1.2.3) → 1) and 1.2.3) → 1)
272+
text = text.replaceAll(/^(\s*)\(?((\d|\p{Lowercase_Letter}){1,3}\.){1,10}(\d|\p{Lowercase_Letter}){1,3}\)\s/gmiu, '$11) ')
273273
// a) → 1) and (a) → 1)
274-
text = text.replaceAll(/^(\s*)\(?([a-z]+)\)\s/gmi, '$11) ')
274+
text = text.replaceAll(/^(\s*)\(?(\p{Lowercase_Letter}{1,3})\)\s/gmiu, '$11) ')
275275
// a. → 1)
276-
text = text.replaceAll(/^(\s*)([a-z]+)\.\s/gmi, '$11) ')
276+
text = text.replaceAll(/^(\s*)(\p{Lowercase_Letter}{1,3})\.\s/gmiu, '$11) ')
277277

278278
const tokens = md.parse(text, {})
279279
console.debug(p`Parsed tokens`, Array.from(tokens))

0 commit comments

Comments
 (0)