Skip to content

Commit 04d3629

Browse files
committed
fix: fixed space issues in headers translated with RTL issues
1 parent 1bb91fa commit 04d3629

File tree

1 file changed

+15
-0
lines changed

1 file changed

+15
-0
lines changed

index.js

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -599,6 +599,21 @@ class Mandarin {
599599
'$2 $1'
600600
);
601601

602+
// Fix custom IDs that are embedded within heading text
603+
result = result.replace(
604+
/^(#{1,6})\s+(.+?)(\{#[^}]+\})(.+?)$/gm,
605+
(match, hashes, beforeText, customId, afterText) => {
606+
// Remove any extra } characters and trim both parts
607+
const cleanAfterText = afterText.replace(/^}+/, '').trim();
608+
const cleanBeforeText = beforeText.trim();
609+
610+
// Concatenate directly and normalize spaces
611+
const combinedText = `${cleanBeforeText}${cleanAfterText}`.replace(/\s+/g, ' ').trim();
612+
613+
return `${hashes} ${combinedText} ${customId}`;
614+
}
615+
);
616+
602617
debug('writing file', localizedFilePath);
603618
await writeFile(localizedFilePath, result);
604619
})

0 commit comments

Comments
 (0)