From 42e844e5fc9ccf84cc3d92da4cb92d42491dc7e8 Mon Sep 17 00:00:00 2001 From: btea <2356281422@qq.com> Date: Sun, 24 Nov 2024 16:17:38 +0800 Subject: [PATCH] fix: revert regionRE --- src/node/utils/processIncludes.ts | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/src/node/utils/processIncludes.ts b/src/node/utils/processIncludes.ts index f8487159..c30ada68 100644 --- a/src/node/utils/processIncludes.ts +++ b/src/node/utils/processIncludes.ts @@ -12,7 +12,7 @@ export function processIncludes( includes: string[] ): string { const includesRE = //g - const regionRE = /[^{#](#[\w-]+)/ + const regionRE = /(#[\w-]+)/ const rangeRE = /\{(\d*),(\d*)\}$/ const titleRE = /(\{#+\s?[\w\s]+\})/ @@ -20,8 +20,8 @@ export function processIncludes( if (!m1.length) return m const range = m1.match(rangeRE) - const region = m1.match(regionRE) const title = m1.match(titleRE) + const region = title ? null : m1.match(regionRE) const hasMeta = !!(region || range || title) @@ -33,6 +33,9 @@ export function processIncludes( m1 = m1.slice(0, -len) // remove meta info from the include path } + console.log('m1', m1) + console.log(region, title) + const atPresent = m1[0] === '@' try { @@ -63,8 +66,9 @@ export function processIncludes( const titleName = title[0].slice(1, -1).trim() const lines = content.split(/\r?\n/) const start = lines.findIndex((line) => line === titleName) + const prefixLength = titleName.replace(/[^#]/g, '').length const end = lines.findIndex( - (line) => /#+\s?[\w\s]+/.test(line) && line !== titleName + (line, index) => line.replace(/[^#]/g, '').length === prefixLength && index > start ) if (end === -1) { content = lines.slice(start).join('\n')