修正 .docx 佔位符跨 run 匹配:允許 <w:r> 帶屬性
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -130,7 +130,7 @@ async function removeWorkDir(workDir) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Word 會把佔位符拆成多個 run,用這個 pattern 允許相鄰字元之間出現 run 邊界 XML
|
// Word 會把佔位符拆成多個 run,用這個 pattern 允許相鄰字元之間出現 run 邊界 XML
|
||||||
const RUN_BOUNDARY = '(?:</w:t></w:r>(?:<w:bookmarkStart[^/]*/?>|<w:bookmarkEnd[^/]*/?>)*<w:r>(?:<w:rPr>[\\s\\S]*?</w:rPr>)?<w:t[^>]*>)?';
|
const RUN_BOUNDARY = '(?:</w:t></w:r[^>]*>(?:<w:bookmarkStart[^/]*/?>|<w:bookmarkEnd[^/]*/?>)*<w:r[^>]*>(?:<w:rPr>[\\s\\S]*?</w:rPr>)?<w:t[^>]*>)?';
|
||||||
|
|
||||||
function buildPlaceholderPattern(placeholder) {
|
function buildPlaceholderPattern(placeholder) {
|
||||||
const chars = [...placeholder].map((c) => c.replace(/[.*+?^${}()|[\]\\]/g, '\\$&'));
|
const chars = [...placeholder].map((c) => c.replace(/[.*+?^${}()|[\]\\]/g, '\\$&'));
|
||||||
|
|||||||
Reference in New Issue
Block a user