Skip to content

Commit

Permalink
Merge branch 'feature/improve-text-splitting-with-intl-segmenter' of h…
Browse files Browse the repository at this point in the history
…ttps://github.com/mRcOol7/mermaid into feature/improve-text-splitting-with-intl-segmenter
  • Loading branch information
mRcOol7 committed Oct 8, 2024
2 parents 30e916a + 238e1a4 commit 5de21c4
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions packages/mermaid/src/rendering-util/splitText.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ export function splitLineToWords(text: string): string[] {
(s) => s.segment // Change: Locale-aware word splitting.
);
}

// Fallback: Split by spaces, adding back spaces manually.
const words = text.split(' ');
const wordsWithSpaces = words.flatMap((s) => [s, ' ']).filter((s) => s);
Expand Down Expand Up @@ -62,7 +62,7 @@ function splitWordToFitWidthRecursion(
}
const [nextChar, ...rest] = remainingChars;
const newWord = [...usedChars, nextChar];

// Check if the word with the next character still fits.
if (checkFit([{ content: newWord.join(''), type }])) {
return splitWordToFitWidthRecursion(checkFit, newWord, rest, type); // Continue recursion.
Expand Down Expand Up @@ -122,7 +122,7 @@ function splitLineToFitWidthRecursion(

const nextWord: MarkdownWord = words.shift() ?? { content: ' ', type: 'normal' };
const lineWithNextWord: MarkdownLine = [...newLine];

// Handle spaces between words.
if (joiner !== '') {
lineWithNextWord.push({ content: joiner, type: 'normal' });
Expand Down

0 comments on commit 5de21c4

Please sign in to comment.