mirror of
https://github.com/mermaid-js/mermaid.git
synced 2025-10-09 17:19:45 +02:00
Cleanup
This commit is contained in:
@@ -39,12 +39,6 @@ export function splitWordToFitWidth(
|
|||||||
word: MarkdownWord
|
word: MarkdownWord
|
||||||
): [MarkdownWord, MarkdownWord] {
|
): [MarkdownWord, MarkdownWord] {
|
||||||
const characters = splitTextToChars(word.content);
|
const characters = splitTextToChars(word.content);
|
||||||
if (characters.length === 0) {
|
|
||||||
return [
|
|
||||||
{ content: '', type: word.type },
|
|
||||||
{ content: '', type: word.type },
|
|
||||||
];
|
|
||||||
}
|
|
||||||
return splitWordToFitWidthRecursion(checkFit, [], characters, word.type);
|
return splitWordToFitWidthRecursion(checkFit, [], characters, word.type);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -54,8 +48,6 @@ function splitWordToFitWidthRecursion(
|
|||||||
remainingChars: string[],
|
remainingChars: string[],
|
||||||
type: MarkdownWordType
|
type: MarkdownWordType
|
||||||
): [MarkdownWord, MarkdownWord] {
|
): [MarkdownWord, MarkdownWord] {
|
||||||
// eslint-disable-next-line no-console
|
|
||||||
console.error({ usedChars, remainingChars });
|
|
||||||
if (remainingChars.length === 0) {
|
if (remainingChars.length === 0) {
|
||||||
return [
|
return [
|
||||||
{ content: usedChars.join(''), type },
|
{ content: usedChars.join(''), type },
|
||||||
@@ -94,8 +86,6 @@ function splitLineToFitWidthRecursion(
|
|||||||
lines: MarkdownLine[] = [],
|
lines: MarkdownLine[] = [],
|
||||||
newLine: MarkdownLine = []
|
newLine: MarkdownLine = []
|
||||||
): MarkdownLine[] {
|
): MarkdownLine[] {
|
||||||
// eslint-disable-next-line no-console
|
|
||||||
console.error({ words, lines, newLine });
|
|
||||||
// Return if there is nothing left to split
|
// Return if there is nothing left to split
|
||||||
if (words.length === 0) {
|
if (words.length === 0) {
|
||||||
// If there is a new line, add it to the lines
|
// If there is a new line, add it to the lines
|
||||||
@@ -110,8 +100,6 @@ function splitLineToFitWidthRecursion(
|
|||||||
words.shift();
|
words.shift();
|
||||||
}
|
}
|
||||||
const nextWord: MarkdownWord = words.shift() ?? { content: ' ', type: 'normal' };
|
const nextWord: MarkdownWord = words.shift() ?? { content: ' ', type: 'normal' };
|
||||||
|
|
||||||
// const nextWordWithJoiner: MarkdownWord = { ...nextWord, content: joiner + nextWord.content };
|
|
||||||
const lineWithNextWord: MarkdownLine = [...newLine];
|
const lineWithNextWord: MarkdownLine = [...newLine];
|
||||||
if (joiner !== '') {
|
if (joiner !== '') {
|
||||||
lineWithNextWord.push({ content: joiner, type: 'normal' });
|
lineWithNextWord.push({ content: joiner, type: 'normal' });
|
||||||
@@ -128,7 +116,7 @@ function splitLineToFitWidthRecursion(
|
|||||||
// There was text in newLine, so add it to lines and push nextWord back into words.
|
// There was text in newLine, so add it to lines and push nextWord back into words.
|
||||||
lines.push(newLine);
|
lines.push(newLine);
|
||||||
words.unshift(nextWord);
|
words.unshift(nextWord);
|
||||||
} else {
|
} else if (nextWord.content) {
|
||||||
// There was no text in newLine, so we need to split nextWord
|
// There was no text in newLine, so we need to split nextWord
|
||||||
const [line, rest] = splitWordToFitWidth(checkFit, nextWord);
|
const [line, rest] = splitWordToFitWidth(checkFit, nextWord);
|
||||||
lines.push([line]);
|
lines.push([line]);
|
||||||
|
Reference in New Issue
Block a user