From 9b912c4a5949ba444cdd2390f6d5072c6e5d049b Mon Sep 17 00:00:00 2001 From: Sidharth Vinod Date: Wed, 26 Apr 2023 10:11:19 +0530 Subject: [PATCH 01/22] handleMarkdown JS -> TS --- ...{handle-markdown-text.spec.js => handle-markdown-text.spec.ts} | 0 .../{handle-markdown-text.js => handle-markdown-text.ts} | 0 2 files changed, 0 insertions(+), 0 deletions(-) rename packages/mermaid/src/rendering-util/{handle-markdown-text.spec.js => handle-markdown-text.spec.ts} (100%) rename packages/mermaid/src/rendering-util/{handle-markdown-text.js => handle-markdown-text.ts} (100%) diff --git a/packages/mermaid/src/rendering-util/handle-markdown-text.spec.js b/packages/mermaid/src/rendering-util/handle-markdown-text.spec.ts similarity index 100% rename from packages/mermaid/src/rendering-util/handle-markdown-text.spec.js rename to packages/mermaid/src/rendering-util/handle-markdown-text.spec.ts diff --git a/packages/mermaid/src/rendering-util/handle-markdown-text.js b/packages/mermaid/src/rendering-util/handle-markdown-text.ts similarity index 100% rename from packages/mermaid/src/rendering-util/handle-markdown-text.js rename to packages/mermaid/src/rendering-util/handle-markdown-text.ts From 4d3e5e42e1f663c616568fac6ff8fd6b986a65e5 Mon Sep 17 00:00:00 2001 From: Sidharth Vinod Date: Wed, 26 Apr 2023 10:30:13 +0530 Subject: [PATCH 02/22] Use mdast-util-from-markdown instead of simple-markdown --- docs/config/setup/modules/mermaidAPI.md | 16 +- docs/syntax/flowchart.md | 52 +- packages/mermaid/src/docs/syntax/flowchart.md | 37 +- packages/mermaid/src/mermaidAPI.ts | 8 +- .../mermaid/src/rendering-util/createText.js | 14 - .../handle-markdown-text.spec.ts | 566 +++++++++++------- .../rendering-util/handle-markdown-text.ts | 81 +-- pnpm-lock.yaml | 147 +++-- 8 files changed, 533 insertions(+), 388 deletions(-) diff --git a/docs/config/setup/modules/mermaidAPI.md b/docs/config/setup/modules/mermaidAPI.md index 683850fd3..ef04c10c3 100644 --- a/docs/config/setup/modules/mermaidAPI.md +++ b/docs/config/setup/modules/mermaidAPI.md @@ -96,7 +96,7 @@ mermaid.initialize(config); #### Defined in -[mermaidAPI.ts:673](https://github.com/mermaid-js/mermaid/blob/master/packages/mermaid/src/mermaidAPI.ts#L673) +[mermaidAPI.ts:667](https://github.com/mermaid-js/mermaid/blob/master/packages/mermaid/src/mermaidAPI.ts#L667) ## Functions @@ -127,7 +127,7 @@ Return the last node appended #### Defined in -[mermaidAPI.ts:312](https://github.com/mermaid-js/mermaid/blob/master/packages/mermaid/src/mermaidAPI.ts#L312) +[mermaidAPI.ts:306](https://github.com/mermaid-js/mermaid/blob/master/packages/mermaid/src/mermaidAPI.ts#L306) --- @@ -153,7 +153,7 @@ the cleaned up svgCode #### Defined in -[mermaidAPI.ts:263](https://github.com/mermaid-js/mermaid/blob/master/packages/mermaid/src/mermaidAPI.ts#L263) +[mermaidAPI.ts:257](https://github.com/mermaid-js/mermaid/blob/master/packages/mermaid/src/mermaidAPI.ts#L257) --- @@ -179,7 +179,7 @@ the string with all the user styles #### Defined in -[mermaidAPI.ts:192](https://github.com/mermaid-js/mermaid/blob/master/packages/mermaid/src/mermaidAPI.ts#L192) +[mermaidAPI.ts:186](https://github.com/mermaid-js/mermaid/blob/master/packages/mermaid/src/mermaidAPI.ts#L186) --- @@ -202,7 +202,7 @@ the string with all the user styles #### Defined in -[mermaidAPI.ts:240](https://github.com/mermaid-js/mermaid/blob/master/packages/mermaid/src/mermaidAPI.ts#L240) +[mermaidAPI.ts:234](https://github.com/mermaid-js/mermaid/blob/master/packages/mermaid/src/mermaidAPI.ts#L234) --- @@ -229,7 +229,7 @@ with an enclosing block that has each of the cssClasses followed by !important; #### Defined in -[mermaidAPI.ts:176](https://github.com/mermaid-js/mermaid/blob/master/packages/mermaid/src/mermaidAPI.ts#L176) +[mermaidAPI.ts:170](https://github.com/mermaid-js/mermaid/blob/master/packages/mermaid/src/mermaidAPI.ts#L170) --- @@ -295,7 +295,7 @@ Put the svgCode into an iFrame. Return the iFrame code #### Defined in -[mermaidAPI.ts:291](https://github.com/mermaid-js/mermaid/blob/master/packages/mermaid/src/mermaidAPI.ts#L291) +[mermaidAPI.ts:285](https://github.com/mermaid-js/mermaid/blob/master/packages/mermaid/src/mermaidAPI.ts#L285) --- @@ -320,4 +320,4 @@ Remove any existing elements from the given document #### Defined in -[mermaidAPI.ts:362](https://github.com/mermaid-js/mermaid/blob/master/packages/mermaid/src/mermaidAPI.ts#L362) +[mermaidAPI.ts:356](https://github.com/mermaid-js/mermaid/blob/master/packages/mermaid/src/mermaidAPI.ts#L356) diff --git a/docs/syntax/flowchart.md b/docs/syntax/flowchart.md index d10b2c6c5..a923e7c7c 100644 --- a/docs/syntax/flowchart.md +++ b/docs/syntax/flowchart.md @@ -55,7 +55,45 @@ flowchart LR id1[This is the text in the box] ``` -## Graph +#### Unicode text + +Use `"` to enclose the unicode text. + +```mermaid-example +flowchart LR + id["This ❤ Unicode"] +``` + +```mermaid +flowchart LR + id["This ❤ Unicode"] +``` + +#### Markdown formatting + +Use double quotes and backticks "\` text \`" to enclose the markdown text. + +```mermaid-example +%%{init: {"flowchart": {"htmlLabels": false}} }%% +flowchart LR + markdown["`This **is** _Markdown_`"] + newLines["`Line1 + Line 2 + Line 3`"] + markdown --> newLines +``` + +```mermaid +%%{init: {"flowchart": {"htmlLabels": false}} }%% +flowchart LR + markdown["`This **is** _Markdown_`"] + newLines["`Line1 + Line 2 + Line 3`"] + markdown --> newLines +``` + +### Direction This statement declares the direction of the Flowchart. @@ -83,15 +121,13 @@ flowchart LR Start --> Stop ``` -## Flowchart Orientation - Possible FlowChart orientations are: -- TB - top to bottom -- TD - top-down/ same as top to bottom -- BT - bottom to top -- RL - right to left -- LR - left to right +- TB - Top to bottom +- TD - Top-down/ same as top to bottom +- BT - Bottom to top +- RL - Right to left +- LR - Left to right ## Node shapes diff --git a/packages/mermaid/src/docs/syntax/flowchart.md b/packages/mermaid/src/docs/syntax/flowchart.md index bdc4a2fa0..0e048a942 100644 --- a/packages/mermaid/src/docs/syntax/flowchart.md +++ b/packages/mermaid/src/docs/syntax/flowchart.md @@ -39,7 +39,30 @@ flowchart LR id1[This is the text in the box] ``` -## Graph +#### Unicode text + +Use `"` to enclose the unicode text. + +```mermaid-example +flowchart LR + id["This ❤ Unicode"] +``` + +#### Markdown formatting + +Use double quotes and backticks "\` text \`" to enclose the markdown text. + +```mermaid-example +%%{init: {"flowchart": {"htmlLabels": false}} }%% +flowchart LR + markdown["`This **is** _Markdown_`"] + newLines["`Line1 + Line 2 + Line 3`"] + markdown --> newLines +``` + +### Direction This statement declares the direction of the Flowchart. @@ -57,15 +80,13 @@ flowchart LR Start --> Stop ``` -## Flowchart Orientation - Possible FlowChart orientations are: -- TB - top to bottom -- TD - top-down/ same as top to bottom -- BT - bottom to top -- RL - right to left -- LR - left to right +- TB - Top to bottom +- TD - Top-down/ same as top to bottom +- BT - Bottom to top +- RL - Right to left +- LR - Left to right ## Node shapes diff --git a/packages/mermaid/src/mermaidAPI.ts b/packages/mermaid/src/mermaidAPI.ts index 5e9d0ead6..e96407638 100644 --- a/packages/mermaid/src/mermaidAPI.ts +++ b/packages/mermaid/src/mermaidAPI.ts @@ -154,13 +154,7 @@ export const encodeEntities = function (text: string): string { * @returns */ export const decodeEntities = function (text: string): string { - let txt = text; - - txt = txt.replace(/fl°°/g, '&#'); - txt = txt.replace(/fl°/g, '&'); - txt = txt.replace(/¶ß/g, ';'); - - return txt; + return text.replace(/fl°°/g, '&#').replace(/fl°/g, '&').replace(/¶ß/g, ';'); }; // append !important; to each cssClass followed by a final !important, all enclosed in { } diff --git a/packages/mermaid/src/rendering-util/createText.js b/packages/mermaid/src/rendering-util/createText.js index a5438b562..d9ba1b9cd 100644 --- a/packages/mermaid/src/rendering-util/createText.js +++ b/packages/mermaid/src/rendering-util/createText.js @@ -1,7 +1,4 @@ -import { select } from 'd3'; import { log } from '../logger.js'; -import { getConfig } from '../config.js'; -import { evaluate } from '../diagrams/common/common.js'; import { decodeEntities } from '../mermaidAPI.js'; import { markdownToHTML, markdownToLines } from '../rendering-util/handle-markdown-text.js'; /** @@ -207,17 +204,6 @@ export const createText = ( return vertexNode; } else { const structuredText = markdownToLines(text); - const special = ['"', "'", '.', ',', ':', ';', '!', '?', '(', ')', '[', ']', '{', '}']; - let lastWord; - structuredText.forEach((line) => { - line.forEach((word) => { - if (special.includes(word.content) && lastWord) { - lastWord.content += word.content; - word.content = ''; - } - lastWord = word; - }); - }); const svgLabel = createFormattedText(width, el, structuredText, addSvgBackground); return svgLabel; } diff --git a/packages/mermaid/src/rendering-util/handle-markdown-text.spec.ts b/packages/mermaid/src/rendering-util/handle-markdown-text.spec.ts index 5e74a9956..877ea9b25 100644 --- a/packages/mermaid/src/rendering-util/handle-markdown-text.spec.ts +++ b/packages/mermaid/src/rendering-util/handle-markdown-text.spec.ts @@ -1,253 +1,391 @@ -// import { test } from 'vitest'; -import { markdownToLines, markdownToHTML } from './handle-markdown-text'; -import { test } from 'vitest'; +import { markdownToLines, markdownToHTML } from './handle-markdown-text.js'; +import { test, expect } from 'vitest'; -test('markdownToLines - Basic test', () => { - const input = `This is regular text +describe('markdownToLines', () => { + test('Basic test', () => { + const input = `This is regular text Here is a new line There is some words **with a bold** section Here is a line *with an italic* section`; - const expectedOutput = [ + const output = markdownToLines(input); + expect(output).toMatchInlineSnapshot(` [ - { content: 'This', type: 'normal' }, - { content: 'is', type: 'normal' }, - { content: 'regular', type: 'normal' }, - { content: 'text', type: 'normal' }, - ], - [ - { content: 'Here', type: 'normal' }, - { content: 'is', type: 'normal' }, - { content: 'a', type: 'normal' }, - { content: 'new', type: 'normal' }, - { content: 'line', type: 'normal' }, - ], - [ - { content: 'There', type: 'normal' }, - { content: 'is', type: 'normal' }, - { content: 'some', type: 'normal' }, - { content: 'words', type: 'normal' }, - { content: 'with', type: 'strong' }, - { content: 'a', type: 'strong' }, - { content: 'bold', type: 'strong' }, - { content: 'section', type: 'normal' }, - ], - [ - { content: 'Here', type: 'normal' }, - { content: 'is', type: 'normal' }, - { content: 'a', type: 'normal' }, - { content: 'line', type: 'normal' }, - { content: 'with', type: 'em' }, - { content: 'an', type: 'em' }, - { content: 'italic', type: 'em' }, - { content: 'section', type: 'normal' }, - ], - ]; + [ + { + "content": "This", + "type": "normal", + }, + { + "content": "is", + "type": "normal", + }, + { + "content": "regular", + "type": "normal", + }, + { + "content": "text", + "type": "normal", + }, + ], + [ + { + "content": "Here", + "type": "normal", + }, + { + "content": "is", + "type": "normal", + }, + { + "content": "a", + "type": "normal", + }, + { + "content": "new", + "type": "normal", + }, + { + "content": "line", + "type": "normal", + }, + ], + [ + { + "content": "There", + "type": "normal", + }, + { + "content": "is", + "type": "normal", + }, + { + "content": "some", + "type": "normal", + }, + { + "content": "words", + "type": "normal", + }, + { + "content": "with", + "type": "strong", + }, + { + "content": "a", + "type": "strong", + }, + { + "content": "bold", + "type": "strong", + }, + { + "content": "section", + "type": "normal", + }, + ], + [ + { + "content": "Here", + "type": "normal", + }, + { + "content": "is", + "type": "normal", + }, + { + "content": "a", + "type": "normal", + }, + { + "content": "line", + "type": "normal", + }, + { + "content": "with", + "type": "emphasis", + }, + { + "content": "an", + "type": "emphasis", + }, + { + "content": "italic", + "type": "emphasis", + }, + { + "content": "section", + "type": "normal", + }, + ], + ] + `); + }); - const output = markdownToLines(input); - expect(output).toEqual(expectedOutput); -}); + test('Empty input', () => { + const input = ''; + const expectedOutput = [[]]; + const output = markdownToLines(input); + expect(output).toEqual(expectedOutput); + }); -test('markdownToLines - Empty input', () => { - const input = ''; - const expectedOutput = [[]]; - const output = markdownToLines(input); - expect(output).toEqual(expectedOutput); -}); - -test('markdownToLines - No formatting', () => { - const input = `This is a simple test + test('No formatting', () => { + const input = `This is a simple test with no formatting`; - const expectedOutput = [ - [ - { content: 'This', type: 'normal' }, - { content: 'is', type: 'normal' }, - { content: 'a', type: 'normal' }, - { content: 'simple', type: 'normal' }, - { content: 'test', type: 'normal' }, - ], - [ - { content: 'with', type: 'normal' }, - { content: 'no', type: 'normal' }, - { content: 'formatting', type: 'normal' }, - ], - ]; + const expectedOutput = [ + [ + { content: 'This', type: 'normal' }, + { content: 'is', type: 'normal' }, + { content: 'a', type: 'normal' }, + { content: 'simple', type: 'normal' }, + { content: 'test', type: 'normal' }, + ], + [ + { content: 'with', type: 'normal' }, + { content: 'no', type: 'normal' }, + { content: 'formatting', type: 'normal' }, + ], + ]; - const output = markdownToLines(input); - expect(output).toEqual(expectedOutput); -}); + const output = markdownToLines(input); + expect(output).toEqual(expectedOutput); + }); -test('markdownToLines - Only bold formatting', () => { - const input = `This is a **bold** test`; + test('Only bold formatting', () => { + const input = `This is a **bold** test`; - const expectedOutput = [ - [ - { content: 'This', type: 'normal' }, - { content: 'is', type: 'normal' }, - { content: 'a', type: 'normal' }, - { content: 'bold', type: 'strong' }, - { content: 'test', type: 'normal' }, - ], - ]; + const expectedOutput = [ + [ + { content: 'This', type: 'normal' }, + { content: 'is', type: 'normal' }, + { content: 'a', type: 'normal' }, + { content: 'bold', type: 'strong' }, + { content: 'test', type: 'normal' }, + ], + ]; - const output = markdownToLines(input); - expect(output).toEqual(expectedOutput); -}); + const output = markdownToLines(input); + expect(output).toEqual(expectedOutput); + }); -test('markdownToLines - paragraph 1', () => { - const input = `**Start** with + test('paragraph 1', () => { + const input = `**Start** with a second line`; - const expectedOutput = [ - [ - { content: 'Start', type: 'strong' }, - { content: 'with', type: 'normal' }, - ], - [ - { content: 'a', type: 'normal' }, - { content: 'second', type: 'normal' }, - { content: 'line', type: 'normal' }, - ], - ]; + const expectedOutput = [ + [ + { content: 'Start', type: 'strong' }, + { content: 'with', type: 'normal' }, + ], + [ + { content: 'a', type: 'normal' }, + { content: 'second', type: 'normal' }, + { content: 'line', type: 'normal' }, + ], + ]; - const output = markdownToLines(input); - expect(output).toEqual(expectedOutput); -}); + const output = markdownToLines(input); + expect(output).toEqual(expectedOutput); + }); -test('markdownToLines - paragraph', () => { - const input = `**Start** with + test('paragraph', () => { + const input = `**Start** with a second line`; - const expectedOutput = [ + const expectedOutput = [ + [ + { content: 'Start', type: 'strong' }, + { content: 'with', type: 'normal' }, + ], + [ + { content: 'a', type: 'normal' }, + { content: 'second', type: 'normal' }, + { content: 'line', type: 'normal' }, + ], + ]; + + const output = markdownToLines(input); + expect(output).toEqual(expectedOutput); + }); + + test('Only italic formatting', () => { + const input = `This is an *italic* test`; + const output = markdownToLines(input); + expect(output).toMatchInlineSnapshot(` [ - { content: 'Start', type: 'strong' }, - { content: 'with', type: 'normal' }, - ], + [ + { + "content": "This", + "type": "normal", + }, + { + "content": "is", + "type": "normal", + }, + { + "content": "an", + "type": "normal", + }, + { + "content": "italic", + "type": "emphasis", + }, + { + "content": "test", + "type": "normal", + }, + ], + ] + `); + }); + + test('Mixed formatting', () => { + const input = `*Italic* and **bold** formatting`; + const output = markdownToLines(input); + expect(output).toMatchInlineSnapshot(` [ - { content: 'a', type: 'normal' }, - { content: 'second', type: 'normal' }, - { content: 'line', type: 'normal' }, - ], - ]; + [ + { + "content": "Italic", + "type": "emphasis", + }, + { + "content": "and", + "type": "normal", + }, + { + "content": "bold", + "type": "strong", + }, + { + "content": "formatting", + "type": "normal", + }, + ], + ] + `); + }); - const output = markdownToLines(input); - expect(output).toEqual(expectedOutput); -}); - -test('markdownToLines - Only italic formatting', () => { - const input = `This is an *italic* test`; - - const expectedOutput = [ - [ - { content: 'This', type: 'normal' }, - { content: 'is', type: 'normal' }, - { content: 'an', type: 'normal' }, - { content: 'italic', type: 'em' }, - { content: 'test', type: 'normal' }, - ], - ]; - - const output = markdownToLines(input); - expect(output).toEqual(expectedOutput); -}); - -it('markdownToLines - Mixed formatting', () => { - const input = `*Italic* and **bold** formatting`; - - const expectedOutput = [ - [ - { content: 'Italic', type: 'em' }, - { content: 'and', type: 'normal' }, - { content: 'bold', type: 'strong' }, - { content: 'formatting', type: 'normal' }, - ], - ]; - - const output = markdownToLines(input); - expect(output).toEqual(expectedOutput); -}); - -it('markdownToLines - Mixed formatting', () => { - const input = `The dog in **the** hog... a *very long text* about it + test('Mixed formatting with newline', () => { + const input = `The dog in **the** hog... a *very long text* about it Word!`; - const expectedOutput = [ + const output = markdownToLines(input); + expect(output).toMatchInlineSnapshot(` [ - { content: 'The', type: 'normal' }, - { content: 'dog', type: 'normal' }, - { content: 'in', type: 'normal' }, - { content: 'the', type: 'strong' }, - { content: 'hog', type: 'normal' }, - { content: '.', type: 'normal' }, - { content: '.', type: 'normal' }, - { content: '.', type: 'normal' }, - { content: 'a', type: 'normal' }, - { content: 'very', type: 'em' }, - { content: 'long', type: 'em' }, - { content: 'text', type: 'em' }, - { content: 'about', type: 'normal' }, - { content: 'it', type: 'normal' }, - ], - [ - { content: 'Word', type: 'normal' }, - { content: '!', type: 'normal' }, - ], - ]; - - const output = markdownToLines(input); - expect(output).toEqual(expectedOutput); + [ + { + "content": "The", + "type": "normal", + }, + { + "content": "dog", + "type": "normal", + }, + { + "content": "in", + "type": "normal", + }, + { + "content": "the", + "type": "strong", + }, + { + "content": "hog...", + "type": "normal", + }, + { + "content": "a", + "type": "normal", + }, + { + "content": "very", + "type": "emphasis", + }, + { + "content": "long", + "type": "emphasis", + }, + { + "content": "text", + "type": "emphasis", + }, + { + "content": "about", + "type": "normal", + }, + { + "content": "it", + "type": "normal", + }, + ], + [ + { + "content": "Word!", + "type": "normal", + }, + ], + ] + `); + }); }); -test('markdownToHTML - Basic test', () => { - const input = `This is regular text +describe('markdownToHTML', () => { + test('Basic test', () => { + const input = `This is regular text Here is a new line There is some words **with a bold** section Here is a line *with an italic* section`; - const expectedOutput = `

This is regular text
Here is a new line
There is some words with a bold section
Here is a line with an italic section

`; + const output = markdownToHTML(input); + expect(output).toMatchInlineSnapshot( + '"

This is regular text
Here is a new line
There is some words with a bold section
Here is a line with an italic section

"' + ); + }); - const output = markdownToHTML(input); - expect(output).toEqual(expectedOutput); -}); + test('Empty input', () => { + const input = ''; + const expectedOutput = ''; + const output = markdownToHTML(input); + expect(output).toEqual(expectedOutput); + }); -test('markdownToHTML - Empty input', () => { - const input = ''; - const expectedOutput = ''; - const output = markdownToHTML(input); - expect(output).toEqual(expectedOutput); -}); - -test('markdownToHTML - No formatting', () => { - const input = `This is a simple test + test('No formatting', () => { + const input = `This is a simple test with no formatting`; - const expectedOutput = `

This is a simple test
with no formatting

`; - const output = markdownToHTML(input); - expect(output).toEqual(expectedOutput); -}); - -test('markdownToHTML - Only bold formatting', () => { - const input = `This is a **bold** test`; - - const expectedOutput = `

This is a bold test

`; - const output = markdownToHTML(input); - expect(output).toEqual(expectedOutput); -}); - -test('markdownToHTML - Only italic formatting', () => { - const input = `This is an *italic* test`; - - const expectedOutput = `

This is an italic test

`; - const output = markdownToHTML(input); - expect(output).toEqual(expectedOutput); -}); - -test('markdownToHTML - Mixed formatting', () => { - const input = `*Italic* and **bold** formatting`; - - const expectedOutput = `

Italic and bold formatting

`; - const output = markdownToHTML(input); - expect(output).toEqual(expectedOutput); + const expectedOutput = `

This is a simple test
with no formatting

`; + const output = markdownToHTML(input); + expect(output).toEqual(expectedOutput); + }); + + test('Only bold formatting', () => { + const input = `This is a **bold** test`; + + const expectedOutput = `

This is a bold test

`; + const output = markdownToHTML(input); + expect(output).toEqual(expectedOutput); + }); + + test('Only italic formatting', () => { + const input = `This is an *italic* test`; + + const expectedOutput = `

This is an italic test

`; + const output = markdownToHTML(input); + expect(output).toEqual(expectedOutput); + }); + + test('Mixed formatting', () => { + const input = `*Italic* and **bold** formatting`; + const expectedOutput = `

Italic and bold formatting

`; + const output = markdownToHTML(input); + expect(output).toEqual(expectedOutput); + // const expectedOutput = 'this text has some special characters: `<p>hi</p>`'; + expect( + markdownToHTML('this text has some special characters: `

hi

`') + ).toMatchInlineSnapshot('"

this text has some special characters:

"'); + }); }); diff --git a/packages/mermaid/src/rendering-util/handle-markdown-text.ts b/packages/mermaid/src/rendering-util/handle-markdown-text.ts index 93704b2fe..3a7319922 100644 --- a/packages/mermaid/src/rendering-util/handle-markdown-text.ts +++ b/packages/mermaid/src/rendering-util/handle-markdown-text.ts @@ -1,61 +1,52 @@ -import SimpleMarkdown from '@khanacademy/simple-markdown'; +import { fromMarkdown } from 'mdast-util-from-markdown'; +import type { Content } from 'mdast'; +import { dedent } from 'ts-dedent'; -/** - * - * @param markdown - */ -function preprocessMarkdown(markdown) { +function preprocessMarkdown(markdown: string): string { // Replace multiple newlines with a single newline const withoutMultipleNewlines = markdown.replace(/\n{2,}/g, '\n'); // Remove extra spaces at the beginning of each line - const withoutExtraSpaces = withoutMultipleNewlines.replace(/^\s+/gm, ''); + const withoutExtraSpaces = dedent(withoutMultipleNewlines); return withoutExtraSpaces; } -/** - * - * @param markdown - */ -export function markdownToLines(markdown) { - const preprocessedMarkdown = preprocessMarkdown(markdown); - const mdParse = SimpleMarkdown.defaultBlockParse; - const syntaxTree = mdParse(preprocessedMarkdown); +interface Word { + content: string; + type: string; +} - let lines = [[]]; +type Line = Word[]; + +export function markdownToLines(markdown: string): Line[] { + const preprocessedMarkdown = preprocessMarkdown(markdown); + const { children } = fromMarkdown(preprocessedMarkdown); + const lines: Line[] = [[]]; let currentLine = 0; - /** - * - * @param node - * @param parentType - */ - function processNode(node, parentType) { + function processNode(node: Content, parentType?: string) { if (node.type === 'text') { - const textLines = node.content.split('\n'); - + const textLines = node.value.split('\n'); textLines.forEach((textLine, index) => { if (index !== 0) { currentLine++; lines.push([]); } - - // textLine.split(/ (?=[^!"#$%&'()*+,-./:;<=>?@[\]^_`{|}~]+)/).forEach((word) => { textLine.split(' ').forEach((word) => { if (word) { lines[currentLine].push({ content: word, type: parentType || 'normal' }); } }); }); - } else if (node.type === 'strong' || node.type === 'em') { - node.content.forEach((contentNode) => { + } else if (node.type === 'strong' || node.type === 'emphasis') { + node.children.forEach((contentNode) => { processNode(contentNode, node.type); }); } } - syntaxTree.forEach((treeNode) => { + children.forEach((treeNode) => { if (treeNode.type === 'paragraph') { - treeNode.content.forEach((contentNode) => { + treeNode.children.forEach((contentNode) => { processNode(contentNode); }); } @@ -64,31 +55,21 @@ export function markdownToLines(markdown) { return lines; } -/** - * - * @param markdown - */ -export function markdownToHTML(markdown) { - const mdParse = SimpleMarkdown.defaultBlockParse; - const syntaxTree = mdParse(markdown); +export function markdownToHTML(markdown: string): string { + const { children } = fromMarkdown(markdown); - /** - * - * @param node - */ - function output(node) { + function output(node: Content): string { if (node.type === 'text') { - return node.content.replace(/\n/g, '
'); + return node.value.replace(/\n/g, '
'); } else if (node.type === 'strong') { - return `${node.content.map(output).join('')}`; - } else if (node.type === 'em') { - return `${node.content.map(output).join('')}`; + return `${node.children.map(output).join('')}`; + } else if (node.type === 'emphasis') { + return `${node.children.map(output).join('')}`; } else if (node.type === 'paragraph') { - return `

${node.content.map(output).join('')}

`; - } else { - return ''; + return `

${node.children.map(output).join('')}

`; } + return ''; } - return syntaxTree.map(output).join(''); + return children.map(output).join(''); } diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 51762eb2d..12ea827e9 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -214,6 +214,9 @@ importers: lodash-es: specifier: ^4.17.21 version: 4.17.21 + mdast-util-from-markdown: + specifier: ^1.3.0 + version: 1.3.0 non-layered-tidy-tree-layout: specifier: ^2.0.2 version: 2.0.2 @@ -331,7 +334,7 @@ importers: version: 1.0.0 vitepress: specifier: ^1.0.0-alpha.72 - version: 1.0.0-alpha.72(@algolia/client-search@4.14.2)(@types/node@18.16.0)(react-dom@16.14.0)(react@16.14.0) + version: 1.0.0-alpha.72(@algolia/client-search@4.14.2)(react-dom@16.14.0)(react@16.14.0) vitepress-plugin-search: specifier: ^1.0.4-alpha.20 version: 1.0.4-alpha.20(flexsearch@0.7.31)(vitepress@1.0.0-alpha.72)(vue@3.2.47) @@ -733,6 +736,7 @@ packages: dependencies: '@applitools/eg-frpc': 1.0.2 '@applitools/eg-socks5-proxy-server': 0.5.4 + '@applitools/execution-grid-tunnel': 1.0.24 '@applitools/logger': 1.1.48 dotenv: 16.0.3 encoding: 0.1.13 @@ -1097,7 +1101,7 @@ packages: '@babel/traverse': 7.19.1 '@babel/types': 7.19.0 convert-source-map: 1.8.0 - debug: 4.3.4(supports-color@8.1.1) + debug: 4.3.4 gensync: 1.0.0-beta.2 json5: 2.2.1 lodash: 4.17.21 @@ -1374,7 +1378,7 @@ packages: '@babel/helper-split-export-declaration': 7.18.6 '@babel/parser': 7.19.1 '@babel/types': 7.19.0 - debug: 4.3.4(supports-color@8.1.1) + debug: 4.3.4 globals: 11.12.0 transitivePeerDependencies: - supports-color @@ -2162,7 +2166,7 @@ packages: engines: {node: ^12.22.0 || ^14.17.0 || >=16.0.0} dependencies: ajv: 6.12.6 - debug: 4.3.4(supports-color@8.1.1) + debug: 4.3.4 espree: 9.5.1 globals: 13.19.0 ignore: 5.2.0 @@ -2204,7 +2208,7 @@ packages: engines: {node: '>=10.10.0'} dependencies: '@humanwhocodes/object-schema': 1.2.1 - debug: 4.3.4(supports-color@8.1.1) + debug: 4.3.4 minimatch: 3.1.2 transitivePeerDependencies: - supports-color @@ -2935,7 +2939,6 @@ packages: resolution: {integrity: sha512-9AonUzyTjXXhEOa0DnqpzZi6VHlqKMswga9EXjpXnnqxwLtdvPPtlO8evrI5D9S6asFRCQ6v+wpiUKbw+vKqyg==} dependencies: '@types/ms': 0.7.31 - dev: true /@types/dompurify@3.0.2: resolution: {integrity: sha512-YBL4ziFebbbfQfH5mlC+QTJsvh0oJUrWbmxKMyEdL7emlHJqGR2Qb34TEFKj+VCayBvjKy3xczMFNhugThUsfQ==} @@ -3088,7 +3091,6 @@ packages: resolution: {integrity: sha512-Y/uImid8aAwrEA24/1tcRZwpxX3pIFTSilcNDKSPn+Y2iDywSEachzRuvgAYYLR3wpGXAsMbv5lvKLDZLeYPAw==} dependencies: '@types/unist': 2.0.6 - dev: true /@types/mdurl@1.0.2: resolution: {integrity: sha512-eC4U9MlIcu2q0KQmXszyn5Akca/0jrQmwDRgpAMJai7qBWq4amIQhZyNau4VYGtCeALvW1/NtjzJJ567aZxfKA==} @@ -3110,7 +3112,6 @@ packages: /@types/ms@0.7.31: resolution: {integrity: sha512-iiUgKzV9AuaEkZqkOLDIvlQiL6ltuZd9tGcW3gwpnX8JbuiuhFlEGmmFXEXkN50Cvq7Os88IY2v0dkDqXYWVgA==} - dev: true /@types/node-fetch@2.6.2: resolution: {integrity: sha512-DHqhlq5jeESLy19TYhLakJ07kNumXWjcDdxXsLUMJZ6ue8VZJj4kLPQVE/2mdHh3xZziNF1xppu5lwmS53HR+A==} @@ -3225,7 +3226,6 @@ packages: /@types/unist@2.0.6: resolution: {integrity: sha512-PBjIUxZHOuj0R15/xuwJYjFi+KZdNFrehocChv4g5hu6aFroHue8m0lBP0POdK2nKzbw0cgV1mws8+V/JAcEkQ==} - dev: true /@types/uuid@9.0.1: resolution: {integrity: sha512-rFT3ak0/2trgvp4yYZo5iKFEPsET7vKydKF+VRCxlQ9bpheehyAJH89dAkaLEq/j/RZXJIqcgsmPJKUP1Z28HA==} @@ -3281,7 +3281,7 @@ packages: '@typescript-eslint/scope-manager': 5.59.0 '@typescript-eslint/type-utils': 5.59.0(eslint@8.39.0)(typescript@5.0.4) '@typescript-eslint/utils': 5.59.0(eslint@8.39.0)(typescript@5.0.4) - debug: 4.3.4(supports-color@8.1.1) + debug: 4.3.4 eslint: 8.39.0 grapheme-splitter: 1.0.4 ignore: 5.2.0 @@ -3306,7 +3306,7 @@ packages: '@typescript-eslint/scope-manager': 5.59.0 '@typescript-eslint/types': 5.59.0 '@typescript-eslint/typescript-estree': 5.59.0(typescript@5.0.4) - debug: 4.3.4(supports-color@8.1.1) + debug: 4.3.4 eslint: 8.39.0 typescript: 5.0.4 transitivePeerDependencies: @@ -3333,7 +3333,7 @@ packages: dependencies: '@typescript-eslint/typescript-estree': 5.59.0(typescript@5.0.4) '@typescript-eslint/utils': 5.59.0(eslint@8.39.0)(typescript@5.0.4) - debug: 4.3.4(supports-color@8.1.1) + debug: 4.3.4 eslint: 8.39.0 tsutils: 3.21.0(typescript@5.0.4) typescript: 5.0.4 @@ -3357,7 +3357,7 @@ packages: dependencies: '@typescript-eslint/types': 5.59.0 '@typescript-eslint/visitor-keys': 5.59.0 - debug: 4.3.4(supports-color@8.1.1) + debug: 4.3.4 globby: 11.1.0 is-glob: 4.0.3 semver: 7.5.0 @@ -3402,7 +3402,7 @@ packages: vite: ^4.0.0 vue: ^3.2.25 dependencies: - vite: 4.2.2(@types/node@18.16.0) + vite: 4.2.2 vue: 3.2.47 dev: true @@ -3881,7 +3881,7 @@ packages: resolution: {integrity: sha512-RZNwNclF7+MS/8bDg70amg32dyeZGZxiDuQmZxKLAlQjr3jGyLx+4Kkk58UO7D2QdgFIQCovuSuZESne6RG6XQ==} engines: {node: '>= 6.0.0'} dependencies: - debug: 4.3.4(supports-color@8.1.1) + debug: 4.3.4 transitivePeerDependencies: - supports-color dev: true @@ -4171,7 +4171,7 @@ packages: resolution: {integrity: sha512-AOhBxyLVdpOad3TujtC9kL/9r3HnTkxwQ5ggOsYrvvZP1cCFvzHWJd5XxZDFuTn+IN8vkKSG5SEJrd27vCSbeA==} dependencies: archy: 1.0.0 - debug: 4.3.4(supports-color@8.1.1) + debug: 4.3.4 fastq: 1.13.0 queue-microtask: 1.2.3 transitivePeerDependencies: @@ -4619,7 +4619,6 @@ packages: /character-entities@2.0.2: resolution: {integrity: sha512-shx7oQ0Awen/BRIdkjkvz54PnEEI/EjwXDSIZp86/KKdbafHh1Df/RYGBhn4hbe2+uKC9FnT5UCEdyPz3ai9hQ==} - dev: true /character-reference-invalid@1.1.4: resolution: {integrity: sha512-mKKUkUbhPpQlCOfIuZkvSEgktjPFIsZKRRbC6KWVEMvlzblj3i3asQv5ODsrwt0N3pHAEvjP8KTQPHkp0+6jOg==} @@ -5182,7 +5181,7 @@ packages: engines: {node: '>=14'} dependencies: '@cspell/cspell-service-bus': 6.31.1 - node-fetch: 2.6.9(encoding@0.1.13) + node-fetch: 2.6.9 transitivePeerDependencies: - encoding dev: true @@ -5731,6 +5730,17 @@ packages: ms: 2.1.2 dev: true + /debug@4.3.4: + resolution: {integrity: sha512-PRWFHuSU3eDtQJPvnNY7Jcket1j0t5OuOsFzPPzsekD52Zl8qUfFIPEiswXqIvHWGVHOgX+7G/vCNNhehwxfkQ==} + engines: {node: '>=6.0'} + peerDependencies: + supports-color: '*' + peerDependenciesMeta: + supports-color: + optional: true + dependencies: + ms: 2.1.2 + /debug@4.3.4(supports-color@8.1.1): resolution: {integrity: sha512-PRWFHuSU3eDtQJPvnNY7Jcket1j0t5OuOsFzPPzsekD52Zl8qUfFIPEiswXqIvHWGVHOgX+7G/vCNNhehwxfkQ==} engines: {node: '>=6.0'} @@ -5770,7 +5780,6 @@ packages: resolution: {integrity: sha512-O8x12RzrUF8xyVcY0KJowWsmaJxQbmy0/EtnNtHRpsOcT7dFk5W598coHqBVpmWo1oQQfsCqfCmkZN5DJrZVdg==} dependencies: character-entities: 2.0.2 - dev: true /decompress-response@6.0.0: resolution: {integrity: sha512-aW35yZM6Bb/4oJlZncMH2LCoZtJXTRxES17vE3hoRiowU2kWHaJKFkSBDnDR+cm9J+9QhXmREyIfv0pji9ejCQ==} @@ -5850,7 +5859,6 @@ packages: /dequal@2.0.3: resolution: {integrity: sha512-0je+qPKHEMohvfRTCEo3CrPG6cAzAYgmzKyxRiYSSDkS6eGJdyVJm7WaYA5ECaAD9wLB2T4EEeymA5aFVcYXCA==} engines: {node: '>=6'} - dev: true /destroy@1.2.0: resolution: {integrity: sha512-2sJGJTaXIIaR1w4iJSNoN0hnMY7Gpc/n8D4qSCJw8QqFWXf7cuAgnEHxBpweaVcPevC2l3KpjYCx3NypQQgaJg==} @@ -5879,7 +5887,6 @@ packages: /diff@5.1.0: resolution: {integrity: sha512-D+mk+qE8VC/PAUrlAU34N+VfXev0ghe5ywmpqrawphmVZc1bEfn56uo9qpyGp1p4xpzOHkSW4ztBd6L7Xx4ACw==} engines: {node: '>=0.3.1'} - dev: true /dir-glob@3.0.1: resolution: {integrity: sha512-WkrWp9GR4KXfKGYzOLmTuGVi1UWFfws377n9cc55/tb6DuqyF6pcQ5AbiHEshaDpY9v6oaSr2XCDidGmMwdzIA==} @@ -6210,7 +6217,7 @@ packages: '@es-joy/jsdoccomment': 0.37.1 are-docs-informative: 0.0.2 comment-parser: 1.3.1 - debug: 4.3.4(supports-color@8.1.1) + debug: 4.3.4 escape-string-regexp: 4.0.0 eslint: 8.39.0 esquery: 1.5.0 @@ -6328,7 +6335,7 @@ packages: ajv: 6.12.6 chalk: 4.1.2 cross-spawn: 7.0.3 - debug: 4.3.4(supports-color@8.1.1) + debug: 4.3.4 doctrine: 3.0.0 escape-string-regexp: 4.0.0 eslint-scope: 7.2.0 @@ -6792,7 +6799,7 @@ packages: dependencies: chalk: 4.1.2 commander: 5.1.0 - debug: 4.3.4(supports-color@8.1.1) + debug: 4.3.4 transitivePeerDependencies: - supports-color dev: true @@ -6849,7 +6856,7 @@ packages: debug: optional: true dependencies: - debug: 4.3.4(supports-color@8.1.1) + debug: 4.3.4 dev: true /foreground-child@2.0.0: @@ -7050,7 +7057,7 @@ packages: dependencies: '@tootallnate/once': 1.1.2 data-uri-to-buffer: 3.0.1 - debug: 4.3.4(supports-color@8.1.1) + debug: 4.3.4 file-uri-to-path: 2.0.0 fs-extra: 8.1.0 ftp: 0.3.10 @@ -7378,7 +7385,7 @@ packages: dependencies: '@tootallnate/once': 1.1.2 agent-base: 6.0.2 - debug: 4.3.4(supports-color@8.1.1) + debug: 4.3.4 transitivePeerDependencies: - supports-color dev: true @@ -7389,7 +7396,7 @@ packages: dependencies: '@tootallnate/once': 2.0.0 agent-base: 6.0.2 - debug: 4.3.4(supports-color@8.1.1) + debug: 4.3.4 transitivePeerDependencies: - supports-color dev: true @@ -7455,7 +7462,7 @@ packages: engines: {node: '>= 6'} dependencies: agent-base: 6.0.2 - debug: 4.3.4(supports-color@8.1.1) + debug: 4.3.4 transitivePeerDependencies: - supports-color dev: true @@ -7828,7 +7835,7 @@ packages: resolution: {integrity: sha512-n3s8EwkdFIJCG3BPKBYvskgXGoy88ARzvegkitk60NxRdwltLOTaH7CUiMRXvwYorl0Q712iEjcWB+fK/MrWVw==} engines: {node: '>=10'} dependencies: - debug: 4.3.4(supports-color@8.1.1) + debug: 4.3.4 istanbul-lib-coverage: 3.2.0 source-map: 0.6.1 transitivePeerDependencies: @@ -8551,7 +8558,6 @@ packages: /kleur@4.1.5: resolution: {integrity: sha512-o+NO+8WrRiQEE4/7nwRJhN1HWpVmJm511pBHUxPLtp0BUISzlBplORYSmTclCnJvQq2tKu/sgl3xVpkc7ZWuQQ==} engines: {node: '>=6'} - dev: true /ky@0.30.0: resolution: {integrity: sha512-X/u76z4JtDVq10u1JA5UQfatPxgPaVDMYTrgHyiTpGN2z4TMEJkIHsoSBBSg9SWZEIXTKsi9kHgiQ9o3Y/4yog==} @@ -8633,7 +8639,7 @@ packages: chalk: 5.2.0 cli-truncate: 3.1.0 commander: 10.0.1 - debug: 4.3.4(supports-color@8.1.1) + debug: 4.3.4 execa: 7.1.1 lilconfig: 2.1.0 listr2: 5.0.8 @@ -8941,8 +8947,8 @@ packages: - supports-color dev: true - /mdast-util-from-markdown@1.2.0: - resolution: {integrity: sha512-iZJyyvKD1+K7QX1b5jXdE7Sc5dtoTry1vzV28UZZe8Z1xVnB/czKntJ7ZAkG0tANqRnBF6p3p7GpU1y19DTf2Q==} + /mdast-util-from-markdown@1.3.0: + resolution: {integrity: sha512-HN3W1gRIuN/ZW295c7zi7g9lVBllMgZE40RxCX37wrTPWXCWtpvOZdfnuK+1WNpvZje6XuJeI3Wnb4TJEUem+g==} dependencies: '@types/mdast': 3.0.11 '@types/unist': 2.0.6 @@ -8958,7 +8964,6 @@ packages: uvu: 0.5.6 transitivePeerDependencies: - supports-color - dev: true /mdast-util-frontmatter@1.0.0: resolution: {integrity: sha512-7itKvp0arEVNpCktOET/eLFAYaZ+0cNjVtFtIPxgQ5tV+3i+D4SDDTjTzPWl44LT59PC+xdx+glNTawBdF98Mw==} @@ -8995,7 +9000,7 @@ packages: dependencies: '@types/mdast': 3.0.11 markdown-table: 3.0.3 - mdast-util-from-markdown: 1.2.0 + mdast-util-from-markdown: 1.3.0 mdast-util-to-markdown: 1.3.0 transitivePeerDependencies: - supports-color @@ -9011,7 +9016,7 @@ packages: /mdast-util-gfm@2.0.1: resolution: {integrity: sha512-42yHBbfWIFisaAfV1eixlabbsa6q7vHeSPY+cg+BBjX51M8xhgMacqH9g6TftB/9+YkcI0ooV4ncfrJslzm/RQ==} dependencies: - mdast-util-from-markdown: 1.2.0 + mdast-util-from-markdown: 1.3.0 mdast-util-gfm-autolink-literal: 1.0.2 mdast-util-gfm-footnote: 1.0.1 mdast-util-gfm-strikethrough: 1.0.2 @@ -9040,7 +9045,6 @@ packages: /mdast-util-to-string@3.1.0: resolution: {integrity: sha512-n4Vypz/DZgwo0iMHLQL49dJzlp7YtAJP+N07MZHpjPf/5XJuHUWstviF4Mn2jEiR/GNmtnRRqnwsXExk3igfFA==} - dev: true /mdn-data@2.0.30: resolution: {integrity: sha512-GaqWWShW4kv/G9IEucWScBx9G1/vsFZZJUO+tD26M8J8z3Kw5RDQjaoZe03YAClgeS/SWPOcb4nkFBTEi5DUEA==} @@ -9134,7 +9138,6 @@ packages: micromark-util-symbol: 1.0.1 micromark-util-types: 1.0.2 uvu: 0.5.6 - dev: true /micromark-extension-frontmatter@1.0.0: resolution: {integrity: sha512-EXjmRnupoX6yYuUJSQhrQ9ggK0iQtQlpi6xeJzVD5xscyAI+giqco5fdymayZhJMbIFecjnE2yz85S9NzIgQpg==} @@ -9223,7 +9226,6 @@ packages: micromark-util-character: 1.1.0 micromark-util-symbol: 1.0.1 micromark-util-types: 1.0.2 - dev: true /micromark-factory-label@1.0.2: resolution: {integrity: sha512-CTIwxlOnU7dEshXDQ+dsr2n+yxpP0+fn271pu0bwDIS8uqfFcumXpj5mLn3hSC8iw2MUr6Gx8EcKng1dD7i6hg==} @@ -9232,14 +9234,12 @@ packages: micromark-util-symbol: 1.0.1 micromark-util-types: 1.0.2 uvu: 0.5.6 - dev: true /micromark-factory-space@1.0.0: resolution: {integrity: sha512-qUmqs4kj9a5yBnk3JMLyjtWYN6Mzfcx8uJfi5XAveBniDevmZasdGBba5b4QsvRcAkmvGo5ACmSUmyGiKTLZew==} dependencies: micromark-util-character: 1.1.0 micromark-util-types: 1.0.2 - dev: true /micromark-factory-title@1.0.2: resolution: {integrity: sha512-zily+Nr4yFqgMGRKLpTVsNl5L4PMu485fGFDOQJQBl2NFpjGte1e86zC0da93wf97jrc4+2G2GQudFMHn3IX+A==} @@ -9249,7 +9249,6 @@ packages: micromark-util-symbol: 1.0.1 micromark-util-types: 1.0.2 uvu: 0.5.6 - dev: true /micromark-factory-whitespace@1.0.0: resolution: {integrity: sha512-Qx7uEyahU1lt1RnsECBiuEbfr9INjQTGa6Err+gF3g0Tx4YEviPbqqGKNv/NrBaE7dVHdn1bVZKM/n5I/Bak7A==} @@ -9258,20 +9257,17 @@ packages: micromark-util-character: 1.1.0 micromark-util-symbol: 1.0.1 micromark-util-types: 1.0.2 - dev: true /micromark-util-character@1.1.0: resolution: {integrity: sha512-agJ5B3unGNJ9rJvADMJ5ZiYjBRyDpzKAOk01Kpi1TKhlT1APx3XZk6eN7RtSz1erbWHC2L8T3xLZ81wdtGRZzg==} dependencies: micromark-util-symbol: 1.0.1 micromark-util-types: 1.0.2 - dev: true /micromark-util-chunked@1.0.0: resolution: {integrity: sha512-5e8xTis5tEZKgesfbQMKRCyzvffRRUX+lK/y+DvsMFdabAicPkkZV6gO+FEWi9RfuKKoxxPwNL+dFF0SMImc1g==} dependencies: micromark-util-symbol: 1.0.1 - dev: true /micromark-util-classify-character@1.0.0: resolution: {integrity: sha512-F8oW2KKrQRb3vS5ud5HIqBVkCqQi224Nm55o5wYLzY/9PwHGXC01tr3d7+TqHHz6zrKQ72Okwtvm/xQm6OVNZA==} @@ -9279,20 +9275,17 @@ packages: micromark-util-character: 1.1.0 micromark-util-symbol: 1.0.1 micromark-util-types: 1.0.2 - dev: true /micromark-util-combine-extensions@1.0.0: resolution: {integrity: sha512-J8H058vFBdo/6+AsjHp2NF7AJ02SZtWaVUjsayNFeAiydTxUwViQPxN0Hf8dp4FmCQi0UUFovFsEyRSUmFH3MA==} dependencies: micromark-util-chunked: 1.0.0 micromark-util-types: 1.0.2 - dev: true /micromark-util-decode-numeric-character-reference@1.0.0: resolution: {integrity: sha512-OzO9AI5VUtrTD7KSdagf4MWgHMtET17Ua1fIpXTpuhclCqD8egFWo85GxSGvxgkGS74bEahvtM0WP0HjvV0e4w==} dependencies: micromark-util-symbol: 1.0.1 - dev: true /micromark-util-decode-string@1.0.2: resolution: {integrity: sha512-DLT5Ho02qr6QWVNYbRZ3RYOSSWWFuH3tJexd3dgN1odEuPNxCngTCXJum7+ViRAd9BbdxCvMToPOD/IvVhzG6Q==} @@ -9301,27 +9294,22 @@ packages: micromark-util-character: 1.1.0 micromark-util-decode-numeric-character-reference: 1.0.0 micromark-util-symbol: 1.0.1 - dev: true /micromark-util-encode@1.0.1: resolution: {integrity: sha512-U2s5YdnAYexjKDel31SVMPbfi+eF8y1U4pfiRW/Y8EFVCy/vgxk/2wWTxzcqE71LHtCuCzlBDRU2a5CQ5j+mQA==} - dev: true /micromark-util-html-tag-name@1.1.0: resolution: {integrity: sha512-BKlClMmYROy9UiV03SwNmckkjn8QHVaWkqoAqzivabvdGcwNGMMMH/5szAnywmsTBUzDsU57/mFi0sp4BQO6dA==} - dev: true /micromark-util-normalize-identifier@1.0.0: resolution: {integrity: sha512-yg+zrL14bBTFrQ7n35CmByWUTFsgst5JhA4gJYoty4Dqzj4Z4Fr/DHekSS5aLfH9bdlfnSvKAWsAgJhIbogyBg==} dependencies: micromark-util-symbol: 1.0.1 - dev: true /micromark-util-resolve-all@1.0.0: resolution: {integrity: sha512-CB/AGk98u50k42kvgaMM94wzBqozSzDDaonKU7P7jwQIuH2RU0TeBqGYJz2WY1UdihhjweivStrJ2JdkdEmcfw==} dependencies: micromark-util-types: 1.0.2 - dev: true /micromark-util-sanitize-uri@1.0.0: resolution: {integrity: sha512-cCxvBKlmac4rxCGx6ejlIviRaMKZc0fWm5HdCHEeDWRSkn44l6NdYVRyU+0nT1XC72EQJMZV8IPHF+jTr56lAg==} @@ -9329,7 +9317,6 @@ packages: micromark-util-character: 1.1.0 micromark-util-encode: 1.0.1 micromark-util-symbol: 1.0.1 - dev: true /micromark-util-subtokenize@1.0.2: resolution: {integrity: sha512-d90uqCnXp/cy4G881Ub4psE57Sf8YD0pim9QdjCRNjfas2M1u6Lbt+XZK9gnHL2XFhnozZiEdCa9CNfXSfQ6xA==} @@ -9338,20 +9325,17 @@ packages: micromark-util-symbol: 1.0.1 micromark-util-types: 1.0.2 uvu: 0.5.6 - dev: true /micromark-util-symbol@1.0.1: resolution: {integrity: sha512-oKDEMK2u5qqAptasDAwWDXq0tG9AssVwAx3E9bBF3t/shRIGsWIRG+cGafs2p/SnDSOecnt6hZPCE2o6lHfFmQ==} - dev: true /micromark-util-types@1.0.2: resolution: {integrity: sha512-DCfg/T8fcrhrRKTPjRrw/5LLvdGV7BHySf/1LOZx7TzWZdYRjogNtyNq885z3nNallwr3QUKARjqvHqX1/7t+w==} - dev: true /micromark@2.11.4: resolution: {integrity: sha512-+WoovN/ppKolQOFIAajxi7Lu9kInbPxFuTBVEavFcL8eAfVstoc5MocPmqBeAdBOJV00uaVjegzH4+MA0DN/uA==} dependencies: - debug: 4.3.4(supports-color@8.1.1) + debug: 4.3.4 parse-entities: 2.0.0 transitivePeerDependencies: - supports-color @@ -9361,7 +9345,7 @@ packages: resolution: {integrity: sha512-ryTDy6UUunOXy2HPjelppgJ2sNfcPz1pLlMdA6Rz9jPzhLikWXv/irpWV/I2jd68Uhmny7hHxAlAhk4+vWggpg==} dependencies: '@types/debug': 4.1.7 - debug: 4.3.4(supports-color@8.1.1) + debug: 4.3.4 decode-named-character-reference: 1.0.2 micromark-core-commonmark: 1.0.6 micromark-factory-space: 1.0.0 @@ -9379,7 +9363,6 @@ packages: uvu: 0.5.6 transitivePeerDependencies: - supports-color - dev: true /micromatch@4.0.5: resolution: {integrity: sha512-DMy+ERcEW2q8Z2Po+WNXuw3c5YaUSFjAO5GsJqfEl7UjvtIuFKO6ZrKvcItdy98dwFI2N1tg3zNIdKaQT+aNdA==} @@ -9501,7 +9484,6 @@ packages: /mri@1.2.0: resolution: {integrity: sha512-tzzskb3bG8LvYGFF/mDTpq3jpI6Q9wc3LEmBaghu+DdCssd1FakN7Bc0hVNmEyGq1bq3RgfkCb3cmQLpNPOroA==} engines: {node: '>=4'} - dev: true /mrmime@1.0.1: resolution: {integrity: sha512-hzzEagAgDyoU1Q6yg5uI+AorQgdvMCur3FcKf7NhMKWsaYg+RnbTyHRa/9IlLF9rf455MOCtcqqrQQ83pPP7Uw==} @@ -9514,7 +9496,6 @@ packages: /ms@2.1.2: resolution: {integrity: sha512-sGkPx+VjMtmA6MX27oA4FBFELFCZZ4S4XqeGOXCv68tT+jb3vk/RyaKWP0PTKyWtmLSM0b+adUTEvbs1PEaH2w==} - dev: true /ms@2.1.3: resolution: {integrity: sha512-6FlzubTLZG3J2a/NVCAleEhjzq5oxgHyaCU9yYXvcLsvoVaHJq/s5xXI6/XXP6tz7R9xAOtHnSO/tXtF3WRTlA==} @@ -9580,6 +9561,18 @@ packages: whatwg-url: 5.0.0 dev: true + /node-fetch@2.6.9: + resolution: {integrity: sha512-DJm/CJkZkRjKKj4Zi4BsKVZh3ValV5IR5s7LVZnW+6YMh0W1BfNA8XSs6DLMGYlId5F3KnA70uu2qepcR08Qqg==} + engines: {node: 4.x || >=6.0.0} + peerDependencies: + encoding: ^0.1.0 + peerDependenciesMeta: + encoding: + optional: true + dependencies: + whatwg-url: 5.0.0 + dev: true + /node-fetch@2.6.9(encoding@0.1.13): resolution: {integrity: sha512-DJm/CJkZkRjKKj4Zi4BsKVZh3ValV5IR5s7LVZnW+6YMh0W1BfNA8XSs6DLMGYlId5F3KnA70uu2qepcR08Qqg==} engines: {node: 4.x || >=6.0.0} @@ -9872,7 +9865,7 @@ packages: dependencies: '@tootallnate/once': 1.1.2 agent-base: 6.0.2 - debug: 4.3.4(supports-color@8.1.1) + debug: 4.3.4 get-uri: 3.0.2 http-proxy-agent: 4.0.1 https-proxy-agent: 5.0.1 @@ -10168,7 +10161,7 @@ packages: dependencies: binary-searching: 2.0.5 comment-parser: 1.3.1 - mdast-util-from-markdown: 1.2.0 + mdast-util-from-markdown: 1.3.0 prettier: 2.8.8 transitivePeerDependencies: - supports-color @@ -10239,7 +10232,7 @@ packages: engines: {node: '>= 8'} dependencies: agent-base: 6.0.2 - debug: 4.3.4(supports-color@8.1.1) + debug: 4.3.4 http-proxy-agent: 4.0.1 https-proxy-agent: 5.0.1 lru-cache: 5.1.1 @@ -10519,7 +10512,7 @@ packages: resolution: {integrity: sha512-1fUyHr2jLsVOkhbvPRBJ5zTKZZyD6yZzYaWCS6BPBdQ8vEMBCH+9zNCDA6tET/zHCi/jLqjCWtlJZUPk+DbnFw==} dependencies: '@types/mdast': 3.0.11 - mdast-util-from-markdown: 1.2.0 + mdast-util-from-markdown: 1.3.0 unified: 10.1.2 transitivePeerDependencies: - supports-color @@ -10761,7 +10754,6 @@ packages: engines: {node: '>=6'} dependencies: mri: 1.2.0 - dev: true /safe-buffer@5.1.2: resolution: {integrity: sha512-Gd2UZBJDkXlY7GbJxfsE8/nvKkUEU1G38c1siN6QP6a9PT9MmHB8GnpscSmMJSoF8LOIrt8ud/wPtojys4G6+g==} @@ -11076,7 +11068,7 @@ packages: engines: {node: '>= 6'} dependencies: agent-base: 6.0.2 - debug: 4.3.4(supports-color@8.1.1) + debug: 4.3.4 socks: 2.7.0 transitivePeerDependencies: - supports-color @@ -11252,7 +11244,7 @@ packages: arg: 5.0.2 bluebird: 3.7.2 check-more-types: 2.24.0 - debug: 4.3.4(supports-color@8.1.1) + debug: 4.3.4 execa: 5.1.1 lazy-ass: 1.6.0 ps-tree: 1.2.0 @@ -11899,7 +11891,6 @@ packages: resolution: {integrity: sha512-7A6eiDCs9UtjcwZOcCpM4aPII3bAAGv13E96IkawkOAW0OhH+yRxtY0lzo8KiHpzEMfH7Q+FizUmwp8Iqy5EWg==} dependencies: '@types/unist': 2.0.6 - dev: true /unist-util-visit-parents@5.1.1: resolution: {integrity: sha512-gks4baapT/kNRaWxuGkl5BIhoanZo7sC/cUT/JToSRNL1dYoXRFl75d++NkjYk4TAu2uv2Px+l8guMajogeuiw==} @@ -11999,7 +11990,6 @@ packages: diff: 5.1.0 kleur: 4.1.5 sade: 1.8.1 - dev: true /v8-compile-cache-lib@3.0.1: resolution: {integrity: sha512-wa7YjyUGfNZngI/vtK0UHAN+lgDCxBPCylVXGp0zu59Fz5aiGtNXaq3DhIov063MorB+VfufLh3JlF2KdTK3xg==} @@ -12057,7 +12047,7 @@ packages: hasBin: true dependencies: cac: 6.7.14 - debug: 4.3.4(supports-color@8.1.1) + debug: 4.3.4 mlly: 1.2.0 pathe: 1.1.0 picocolors: 1.0.0 @@ -12072,7 +12062,7 @@ packages: - terser dev: true - /vite@4.2.2(@types/node@18.16.0): + /vite@4.2.2: resolution: {integrity: sha512-PcNtT5HeDxb3QaSqFYkEum8f5sCVe0R3WK20qxgIvNBZPXU/Obxs/+ubBMeE7nLWeCo2LDzv+8hRYSlcaSehig==} engines: {node: ^14.18.0 || >=16.0.0} hasBin: true @@ -12097,7 +12087,6 @@ packages: terser: optional: true dependencies: - '@types/node': 18.16.0 esbuild: 0.17.18 postcss: 8.4.21 resolve: 1.22.1 @@ -12152,11 +12141,11 @@ packages: flexsearch: 0.7.31 glob-to-regexp: 0.4.1 markdown-it: 13.0.1 - vitepress: 1.0.0-alpha.72(@algolia/client-search@4.14.2)(@types/node@18.16.0)(react-dom@16.14.0)(react@16.14.0) + vitepress: 1.0.0-alpha.72(@algolia/client-search@4.14.2)(react-dom@16.14.0)(react@16.14.0) vue: 3.2.47 dev: true - /vitepress@1.0.0-alpha.72(@algolia/client-search@4.14.2)(@types/node@18.16.0)(react-dom@16.14.0)(react@16.14.0): + /vitepress@1.0.0-alpha.72(@algolia/client-search@4.14.2)(react-dom@16.14.0)(react@16.14.0): resolution: {integrity: sha512-Ou7fNE/OVYLrKGQMHSTVG6AcNsdv7tm4ACrdhx93SPMzEDj8UgIb4RFa5CTTowaYf3jeDGi2EAJlzXVC+IE3dg==} hasBin: true dependencies: @@ -12169,7 +12158,7 @@ packages: mark.js: 8.11.1 minisearch: 6.0.1 shiki: 0.14.1 - vite: 4.2.2(@types/node@18.16.0) + vite: 4.2.2 vue: 3.2.47 transitivePeerDependencies: - '@algolia/client-search' @@ -12230,7 +12219,7 @@ packages: cac: 6.7.14 chai: 4.3.7 concordance: 5.0.4 - debug: 4.3.4(supports-color@8.1.1) + debug: 4.3.4 jsdom: 21.1.1 local-pkg: 0.4.3 magic-string: 0.30.0 From 1f2af83a0c13db67770eebe483a32ce97d1fd582 Mon Sep 17 00:00:00 2001 From: Sidharth Vinod Date: Wed, 26 Apr 2023 10:35:24 +0530 Subject: [PATCH 03/22] Fix lockfile --- pnpm-lock.yaml | 72 ++++++++++++++++++++++++++++++++++++-------------- 1 file changed, 52 insertions(+), 20 deletions(-) diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 12ea827e9..94918dac1 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -214,9 +214,6 @@ importers: lodash-es: specifier: ^4.17.21 version: 4.17.21 - mdast-util-from-markdown: - specifier: ^1.3.0 - version: 1.3.0 non-layered-tidy-tree-layout: specifier: ^2.0.2 version: 2.0.2 @@ -387,7 +384,7 @@ importers: devDependencies: webpack: specifier: ^5.74.0 - version: 5.75.0(esbuild@0.17.18)(webpack-cli@4.10.0) + version: 5.75.0(webpack-cli@4.10.0) webpack-cli: specifier: ^4.10.0 version: 4.10.0(webpack-dev-server@4.11.1)(webpack@5.75.0) @@ -2939,6 +2936,7 @@ packages: resolution: {integrity: sha512-9AonUzyTjXXhEOa0DnqpzZi6VHlqKMswga9EXjpXnnqxwLtdvPPtlO8evrI5D9S6asFRCQ6v+wpiUKbw+vKqyg==} dependencies: '@types/ms': 0.7.31 + dev: true /@types/dompurify@3.0.2: resolution: {integrity: sha512-YBL4ziFebbbfQfH5mlC+QTJsvh0oJUrWbmxKMyEdL7emlHJqGR2Qb34TEFKj+VCayBvjKy3xczMFNhugThUsfQ==} @@ -3091,6 +3089,7 @@ packages: resolution: {integrity: sha512-Y/uImid8aAwrEA24/1tcRZwpxX3pIFTSilcNDKSPn+Y2iDywSEachzRuvgAYYLR3wpGXAsMbv5lvKLDZLeYPAw==} dependencies: '@types/unist': 2.0.6 + dev: true /@types/mdurl@1.0.2: resolution: {integrity: sha512-eC4U9MlIcu2q0KQmXszyn5Akca/0jrQmwDRgpAMJai7qBWq4amIQhZyNau4VYGtCeALvW1/NtjzJJ567aZxfKA==} @@ -3112,6 +3111,7 @@ packages: /@types/ms@0.7.31: resolution: {integrity: sha512-iiUgKzV9AuaEkZqkOLDIvlQiL6ltuZd9tGcW3gwpnX8JbuiuhFlEGmmFXEXkN50Cvq7Os88IY2v0dkDqXYWVgA==} + dev: true /@types/node-fetch@2.6.2: resolution: {integrity: sha512-DHqhlq5jeESLy19TYhLakJ07kNumXWjcDdxXsLUMJZ6ue8VZJj4kLPQVE/2mdHh3xZziNF1xppu5lwmS53HR+A==} @@ -3226,6 +3226,7 @@ packages: /@types/unist@2.0.6: resolution: {integrity: sha512-PBjIUxZHOuj0R15/xuwJYjFi+KZdNFrehocChv4g5hu6aFroHue8m0lBP0POdK2nKzbw0cgV1mws8+V/JAcEkQ==} + dev: true /@types/uuid@9.0.1: resolution: {integrity: sha512-rFT3ak0/2trgvp4yYZo5iKFEPsET7vKydKF+VRCxlQ9bpheehyAJH89dAkaLEq/j/RZXJIqcgsmPJKUP1Z28HA==} @@ -3745,7 +3746,7 @@ packages: webpack: 4.x.x || 5.x.x webpack-cli: 4.x.x dependencies: - webpack: 5.75.0(esbuild@0.17.18)(webpack-cli@4.10.0) + webpack: 5.75.0(webpack-cli@4.10.0) webpack-cli: 4.10.0(webpack-dev-server@4.11.1)(webpack@5.75.0) dev: true @@ -4189,7 +4190,7 @@ packages: /axios@0.27.2(debug@4.3.4): resolution: {integrity: sha512-t+yRIyySRTp/wua5xEr+z1q60QmLq8ABsS5O9Me1AsE5dfKqgnCFzwiCZZ/cGNd1lq4/7akDWMxdhVlucjmnOQ==} dependencies: - follow-redirects: 1.15.2(debug@4.3.4) + follow-redirects: 1.15.2 form-data: 4.0.0 transitivePeerDependencies: - debug @@ -4619,6 +4620,7 @@ packages: /character-entities@2.0.2: resolution: {integrity: sha512-shx7oQ0Awen/BRIdkjkvz54PnEEI/EjwXDSIZp86/KKdbafHh1Df/RYGBhn4hbe2+uKC9FnT5UCEdyPz3ai9hQ==} + dev: true /character-reference-invalid@1.1.4: resolution: {integrity: sha512-mKKUkUbhPpQlCOfIuZkvSEgktjPFIsZKRRbC6KWVEMvlzblj3i3asQv5ODsrwt0N3pHAEvjP8KTQPHkp0+6jOg==} @@ -5740,6 +5742,7 @@ packages: optional: true dependencies: ms: 2.1.2 + dev: true /debug@4.3.4(supports-color@8.1.1): resolution: {integrity: sha512-PRWFHuSU3eDtQJPvnNY7Jcket1j0t5OuOsFzPPzsekD52Zl8qUfFIPEiswXqIvHWGVHOgX+7G/vCNNhehwxfkQ==} @@ -5780,6 +5783,7 @@ packages: resolution: {integrity: sha512-O8x12RzrUF8xyVcY0KJowWsmaJxQbmy0/EtnNtHRpsOcT7dFk5W598coHqBVpmWo1oQQfsCqfCmkZN5DJrZVdg==} dependencies: character-entities: 2.0.2 + dev: true /decompress-response@6.0.0: resolution: {integrity: sha512-aW35yZM6Bb/4oJlZncMH2LCoZtJXTRxES17vE3hoRiowU2kWHaJKFkSBDnDR+cm9J+9QhXmREyIfv0pji9ejCQ==} @@ -5859,6 +5863,7 @@ packages: /dequal@2.0.3: resolution: {integrity: sha512-0je+qPKHEMohvfRTCEo3CrPG6cAzAYgmzKyxRiYSSDkS6eGJdyVJm7WaYA5ECaAD9wLB2T4EEeymA5aFVcYXCA==} engines: {node: '>=6'} + dev: true /destroy@1.2.0: resolution: {integrity: sha512-2sJGJTaXIIaR1w4iJSNoN0hnMY7Gpc/n8D4qSCJw8QqFWXf7cuAgnEHxBpweaVcPevC2l3KpjYCx3NypQQgaJg==} @@ -5887,6 +5892,7 @@ packages: /diff@5.1.0: resolution: {integrity: sha512-D+mk+qE8VC/PAUrlAU34N+VfXev0ghe5ywmpqrawphmVZc1bEfn56uo9qpyGp1p4xpzOHkSW4ztBd6L7Xx4ACw==} engines: {node: '>=0.3.1'} + dev: true /dir-glob@3.0.1: resolution: {integrity: sha512-WkrWp9GR4KXfKGYzOLmTuGVi1UWFfws377n9cc55/tb6DuqyF6pcQ5AbiHEshaDpY9v6oaSr2XCDidGmMwdzIA==} @@ -6847,7 +6853,7 @@ packages: resolution: {integrity: sha512-XGozTsMPYkm+6b5QL3Z9wQcJjNYxp0CYn3U1gO7dwD6PAqU1SVWZxI9CCg3z+ml3YfqdPnrBehaBrnH2AGKbNA==} dev: true - /follow-redirects@1.15.2(debug@4.3.4): + /follow-redirects@1.15.2: resolution: {integrity: sha512-VQLG33o04KaQ8uYi2tVNbdrWp1QWxNNea+nmIB4EVM28v0hmP17z7aG1+wAkNzVq4KeXTq3221ye5qTJP91JwA==} engines: {node: '>=4.0'} peerDependencies: @@ -6855,8 +6861,6 @@ packages: peerDependenciesMeta: debug: optional: true - dependencies: - debug: 4.3.4 dev: true /foreground-child@2.0.0: @@ -7425,7 +7429,7 @@ packages: engines: {node: '>=8.0.0'} dependencies: eventemitter3: 4.0.7 - follow-redirects: 1.15.2(debug@4.3.4) + follow-redirects: 1.15.2 requires-port: 1.0.0 transitivePeerDependencies: - debug @@ -8558,6 +8562,7 @@ packages: /kleur@4.1.5: resolution: {integrity: sha512-o+NO+8WrRiQEE4/7nwRJhN1HWpVmJm511pBHUxPLtp0BUISzlBplORYSmTclCnJvQq2tKu/sgl3xVpkc7ZWuQQ==} engines: {node: '>=6'} + dev: true /ky@0.30.0: resolution: {integrity: sha512-X/u76z4JtDVq10u1JA5UQfatPxgPaVDMYTrgHyiTpGN2z4TMEJkIHsoSBBSg9SWZEIXTKsi9kHgiQ9o3Y/4yog==} @@ -8964,6 +8969,7 @@ packages: uvu: 0.5.6 transitivePeerDependencies: - supports-color + dev: true /mdast-util-frontmatter@1.0.0: resolution: {integrity: sha512-7itKvp0arEVNpCktOET/eLFAYaZ+0cNjVtFtIPxgQ5tV+3i+D4SDDTjTzPWl44LT59PC+xdx+glNTawBdF98Mw==} @@ -9045,6 +9051,7 @@ packages: /mdast-util-to-string@3.1.0: resolution: {integrity: sha512-n4Vypz/DZgwo0iMHLQL49dJzlp7YtAJP+N07MZHpjPf/5XJuHUWstviF4Mn2jEiR/GNmtnRRqnwsXExk3igfFA==} + dev: true /mdn-data@2.0.30: resolution: {integrity: sha512-GaqWWShW4kv/G9IEucWScBx9G1/vsFZZJUO+tD26M8J8z3Kw5RDQjaoZe03YAClgeS/SWPOcb4nkFBTEi5DUEA==} @@ -9138,6 +9145,7 @@ packages: micromark-util-symbol: 1.0.1 micromark-util-types: 1.0.2 uvu: 0.5.6 + dev: true /micromark-extension-frontmatter@1.0.0: resolution: {integrity: sha512-EXjmRnupoX6yYuUJSQhrQ9ggK0iQtQlpi6xeJzVD5xscyAI+giqco5fdymayZhJMbIFecjnE2yz85S9NzIgQpg==} @@ -9226,6 +9234,7 @@ packages: micromark-util-character: 1.1.0 micromark-util-symbol: 1.0.1 micromark-util-types: 1.0.2 + dev: true /micromark-factory-label@1.0.2: resolution: {integrity: sha512-CTIwxlOnU7dEshXDQ+dsr2n+yxpP0+fn271pu0bwDIS8uqfFcumXpj5mLn3hSC8iw2MUr6Gx8EcKng1dD7i6hg==} @@ -9234,12 +9243,14 @@ packages: micromark-util-symbol: 1.0.1 micromark-util-types: 1.0.2 uvu: 0.5.6 + dev: true /micromark-factory-space@1.0.0: resolution: {integrity: sha512-qUmqs4kj9a5yBnk3JMLyjtWYN6Mzfcx8uJfi5XAveBniDevmZasdGBba5b4QsvRcAkmvGo5ACmSUmyGiKTLZew==} dependencies: micromark-util-character: 1.1.0 micromark-util-types: 1.0.2 + dev: true /micromark-factory-title@1.0.2: resolution: {integrity: sha512-zily+Nr4yFqgMGRKLpTVsNl5L4PMu485fGFDOQJQBl2NFpjGte1e86zC0da93wf97jrc4+2G2GQudFMHn3IX+A==} @@ -9249,6 +9260,7 @@ packages: micromark-util-symbol: 1.0.1 micromark-util-types: 1.0.2 uvu: 0.5.6 + dev: true /micromark-factory-whitespace@1.0.0: resolution: {integrity: sha512-Qx7uEyahU1lt1RnsECBiuEbfr9INjQTGa6Err+gF3g0Tx4YEviPbqqGKNv/NrBaE7dVHdn1bVZKM/n5I/Bak7A==} @@ -9257,17 +9269,20 @@ packages: micromark-util-character: 1.1.0 micromark-util-symbol: 1.0.1 micromark-util-types: 1.0.2 + dev: true /micromark-util-character@1.1.0: resolution: {integrity: sha512-agJ5B3unGNJ9rJvADMJ5ZiYjBRyDpzKAOk01Kpi1TKhlT1APx3XZk6eN7RtSz1erbWHC2L8T3xLZ81wdtGRZzg==} dependencies: micromark-util-symbol: 1.0.1 micromark-util-types: 1.0.2 + dev: true /micromark-util-chunked@1.0.0: resolution: {integrity: sha512-5e8xTis5tEZKgesfbQMKRCyzvffRRUX+lK/y+DvsMFdabAicPkkZV6gO+FEWi9RfuKKoxxPwNL+dFF0SMImc1g==} dependencies: micromark-util-symbol: 1.0.1 + dev: true /micromark-util-classify-character@1.0.0: resolution: {integrity: sha512-F8oW2KKrQRb3vS5ud5HIqBVkCqQi224Nm55o5wYLzY/9PwHGXC01tr3d7+TqHHz6zrKQ72Okwtvm/xQm6OVNZA==} @@ -9275,17 +9290,20 @@ packages: micromark-util-character: 1.1.0 micromark-util-symbol: 1.0.1 micromark-util-types: 1.0.2 + dev: true /micromark-util-combine-extensions@1.0.0: resolution: {integrity: sha512-J8H058vFBdo/6+AsjHp2NF7AJ02SZtWaVUjsayNFeAiydTxUwViQPxN0Hf8dp4FmCQi0UUFovFsEyRSUmFH3MA==} dependencies: micromark-util-chunked: 1.0.0 micromark-util-types: 1.0.2 + dev: true /micromark-util-decode-numeric-character-reference@1.0.0: resolution: {integrity: sha512-OzO9AI5VUtrTD7KSdagf4MWgHMtET17Ua1fIpXTpuhclCqD8egFWo85GxSGvxgkGS74bEahvtM0WP0HjvV0e4w==} dependencies: micromark-util-symbol: 1.0.1 + dev: true /micromark-util-decode-string@1.0.2: resolution: {integrity: sha512-DLT5Ho02qr6QWVNYbRZ3RYOSSWWFuH3tJexd3dgN1odEuPNxCngTCXJum7+ViRAd9BbdxCvMToPOD/IvVhzG6Q==} @@ -9294,22 +9312,27 @@ packages: micromark-util-character: 1.1.0 micromark-util-decode-numeric-character-reference: 1.0.0 micromark-util-symbol: 1.0.1 + dev: true /micromark-util-encode@1.0.1: resolution: {integrity: sha512-U2s5YdnAYexjKDel31SVMPbfi+eF8y1U4pfiRW/Y8EFVCy/vgxk/2wWTxzcqE71LHtCuCzlBDRU2a5CQ5j+mQA==} + dev: true /micromark-util-html-tag-name@1.1.0: resolution: {integrity: sha512-BKlClMmYROy9UiV03SwNmckkjn8QHVaWkqoAqzivabvdGcwNGMMMH/5szAnywmsTBUzDsU57/mFi0sp4BQO6dA==} + dev: true /micromark-util-normalize-identifier@1.0.0: resolution: {integrity: sha512-yg+zrL14bBTFrQ7n35CmByWUTFsgst5JhA4gJYoty4Dqzj4Z4Fr/DHekSS5aLfH9bdlfnSvKAWsAgJhIbogyBg==} dependencies: micromark-util-symbol: 1.0.1 + dev: true /micromark-util-resolve-all@1.0.0: resolution: {integrity: sha512-CB/AGk98u50k42kvgaMM94wzBqozSzDDaonKU7P7jwQIuH2RU0TeBqGYJz2WY1UdihhjweivStrJ2JdkdEmcfw==} dependencies: micromark-util-types: 1.0.2 + dev: true /micromark-util-sanitize-uri@1.0.0: resolution: {integrity: sha512-cCxvBKlmac4rxCGx6ejlIviRaMKZc0fWm5HdCHEeDWRSkn44l6NdYVRyU+0nT1XC72EQJMZV8IPHF+jTr56lAg==} @@ -9317,6 +9340,7 @@ packages: micromark-util-character: 1.1.0 micromark-util-encode: 1.0.1 micromark-util-symbol: 1.0.1 + dev: true /micromark-util-subtokenize@1.0.2: resolution: {integrity: sha512-d90uqCnXp/cy4G881Ub4psE57Sf8YD0pim9QdjCRNjfas2M1u6Lbt+XZK9gnHL2XFhnozZiEdCa9CNfXSfQ6xA==} @@ -9325,12 +9349,15 @@ packages: micromark-util-symbol: 1.0.1 micromark-util-types: 1.0.2 uvu: 0.5.6 + dev: true /micromark-util-symbol@1.0.1: resolution: {integrity: sha512-oKDEMK2u5qqAptasDAwWDXq0tG9AssVwAx3E9bBF3t/shRIGsWIRG+cGafs2p/SnDSOecnt6hZPCE2o6lHfFmQ==} + dev: true /micromark-util-types@1.0.2: resolution: {integrity: sha512-DCfg/T8fcrhrRKTPjRrw/5LLvdGV7BHySf/1LOZx7TzWZdYRjogNtyNq885z3nNallwr3QUKARjqvHqX1/7t+w==} + dev: true /micromark@2.11.4: resolution: {integrity: sha512-+WoovN/ppKolQOFIAajxi7Lu9kInbPxFuTBVEavFcL8eAfVstoc5MocPmqBeAdBOJV00uaVjegzH4+MA0DN/uA==} @@ -9363,6 +9390,7 @@ packages: uvu: 0.5.6 transitivePeerDependencies: - supports-color + dev: true /micromatch@4.0.5: resolution: {integrity: sha512-DMy+ERcEW2q8Z2Po+WNXuw3c5YaUSFjAO5GsJqfEl7UjvtIuFKO6ZrKvcItdy98dwFI2N1tg3zNIdKaQT+aNdA==} @@ -9484,6 +9512,7 @@ packages: /mri@1.2.0: resolution: {integrity: sha512-tzzskb3bG8LvYGFF/mDTpq3jpI6Q9wc3LEmBaghu+DdCssd1FakN7Bc0hVNmEyGq1bq3RgfkCb3cmQLpNPOroA==} engines: {node: '>=4'} + dev: true /mrmime@1.0.1: resolution: {integrity: sha512-hzzEagAgDyoU1Q6yg5uI+AorQgdvMCur3FcKf7NhMKWsaYg+RnbTyHRa/9IlLF9rf455MOCtcqqrQQ83pPP7Uw==} @@ -9496,6 +9525,7 @@ packages: /ms@2.1.2: resolution: {integrity: sha512-sGkPx+VjMtmA6MX27oA4FBFELFCZZ4S4XqeGOXCv68tT+jb3vk/RyaKWP0PTKyWtmLSM0b+adUTEvbs1PEaH2w==} + dev: true /ms@2.1.3: resolution: {integrity: sha512-6FlzubTLZG3J2a/NVCAleEhjzq5oxgHyaCU9yYXvcLsvoVaHJq/s5xXI6/XXP6tz7R9xAOtHnSO/tXtF3WRTlA==} @@ -10754,6 +10784,7 @@ packages: engines: {node: '>=6'} dependencies: mri: 1.2.0 + dev: true /safe-buffer@5.1.2: resolution: {integrity: sha512-Gd2UZBJDkXlY7GbJxfsE8/nvKkUEU1G38c1siN6QP6a9PT9MmHB8GnpscSmMJSoF8LOIrt8ud/wPtojys4G6+g==} @@ -11166,7 +11197,7 @@ packages: /spdy-transport@3.0.0: resolution: {integrity: sha512-hsLVFE5SjA6TCisWeJXFKniGGOpBgMLmerfO2aCyCU5s7nJ/rpAepqmFifv/GCbSbueEeAJJnmSQ2rKC/g8Fcw==} dependencies: - debug: 4.3.4(supports-color@8.1.1) + debug: 4.3.4 detect-node: 2.1.0 hpack.js: 2.1.6 obuf: 1.1.2 @@ -11180,7 +11211,7 @@ packages: resolution: {integrity: sha512-r46gZQZQV+Kl9oItvl1JZZqJKGr+oEkB08A6BzkiR7593/7IbtuncXHd2YoYeTsG4157ZssMu9KYvUHLcjcDoA==} engines: {node: '>=6.0.0'} dependencies: - debug: 4.3.4(supports-color@8.1.1) + debug: 4.3.4 handle-thing: 2.0.1 http-deceiver: 1.2.7 select-hose: 2.0.0 @@ -11462,7 +11493,7 @@ packages: iterm2-version: 4.2.0 dev: true - /terser-webpack-plugin@5.3.6(esbuild@0.17.18)(webpack@5.75.0): + /terser-webpack-plugin@5.3.6(webpack@5.75.0): resolution: {integrity: sha512-kfLFk+PoLUQIbLmB1+PZDMRSZS99Mp+/MHqDNmMA6tOItzRt+Npe3E+fsMs5mfcM0wCtrrdU387UnV+vnSffXQ==} engines: {node: '>= 10.13.0'} peerDependencies: @@ -11479,12 +11510,11 @@ packages: optional: true dependencies: '@jridgewell/trace-mapping': 0.3.15 - esbuild: 0.17.18 jest-worker: 27.5.1 schema-utils: 3.1.1 serialize-javascript: 6.0.0 terser: 5.15.1 - webpack: 5.75.0(esbuild@0.17.18)(webpack-cli@4.10.0) + webpack: 5.75.0(webpack-cli@4.10.0) dev: true /terser@5.15.1: @@ -11891,6 +11921,7 @@ packages: resolution: {integrity: sha512-7A6eiDCs9UtjcwZOcCpM4aPII3bAAGv13E96IkawkOAW0OhH+yRxtY0lzo8KiHpzEMfH7Q+FizUmwp8Iqy5EWg==} dependencies: '@types/unist': 2.0.6 + dev: true /unist-util-visit-parents@5.1.1: resolution: {integrity: sha512-gks4baapT/kNRaWxuGkl5BIhoanZo7sC/cUT/JToSRNL1dYoXRFl75d++NkjYk4TAu2uv2Px+l8guMajogeuiw==} @@ -11990,6 +12021,7 @@ packages: diff: 5.1.0 kleur: 4.1.5 sade: 1.8.1 + dev: true /v8-compile-cache-lib@3.0.1: resolution: {integrity: sha512-wa7YjyUGfNZngI/vtK0UHAN+lgDCxBPCylVXGp0zu59Fz5aiGtNXaq3DhIov063MorB+VfufLh3JlF2KdTK3xg==} @@ -12434,7 +12466,7 @@ packages: import-local: 3.1.0 interpret: 2.2.0 rechoir: 0.7.1 - webpack: 5.75.0(esbuild@0.17.18)(webpack-cli@4.10.0) + webpack: 5.75.0(webpack-cli@4.10.0) webpack-dev-server: 4.11.1(webpack-cli@4.10.0)(webpack@5.75.0) webpack-merge: 5.8.0 dev: true @@ -12450,7 +12482,7 @@ packages: mime-types: 2.1.35 range-parser: 1.2.1 schema-utils: 4.0.0 - webpack: 5.75.0(esbuild@0.17.18)(webpack-cli@4.10.0) + webpack: 5.75.0(webpack-cli@4.10.0) dev: true /webpack-dev-server@4.11.1(webpack-cli@4.10.0)(webpack@5.75.0): @@ -12491,7 +12523,7 @@ packages: serve-index: 1.9.1 sockjs: 0.3.24 spdy: 4.0.2 - webpack: 5.75.0(esbuild@0.17.18)(webpack-cli@4.10.0) + webpack: 5.75.0(webpack-cli@4.10.0) webpack-cli: 4.10.0(webpack-dev-server@4.11.1)(webpack@5.75.0) webpack-dev-middleware: 5.3.3(webpack@5.75.0) ws: 8.9.0 @@ -12515,7 +12547,7 @@ packages: engines: {node: '>=10.13.0'} dev: true - /webpack@5.75.0(esbuild@0.17.18)(webpack-cli@4.10.0): + /webpack@5.75.0(webpack-cli@4.10.0): resolution: {integrity: sha512-piaIaoVJlqMsPtX/+3KTTO6jfvrSYgauFVdt8cr9LTHKmcq/AMd4mhzsiP7ZF/PGRNPGA8336jldh9l2Kt2ogQ==} engines: {node: '>=10.13.0'} hasBin: true @@ -12546,7 +12578,7 @@ packages: neo-async: 2.6.2 schema-utils: 3.1.1 tapable: 2.2.1 - terser-webpack-plugin: 5.3.6(esbuild@0.17.18)(webpack@5.75.0) + terser-webpack-plugin: 5.3.6(webpack@5.75.0) watchpack: 2.4.0 webpack-cli: 4.10.0(webpack-dev-server@4.11.1)(webpack@5.75.0) webpack-sources: 3.2.3 From 395a79475838410edea4a5962a1294a9138c6ce6 Mon Sep 17 00:00:00 2001 From: Sidharth Vinod Date: Wed, 26 Apr 2023 10:37:03 +0530 Subject: [PATCH 04/22] Fix deps --- packages/mermaid/package.json | 2 +- pnpm-lock.yaml | 134 +++------------------------------- 2 files changed, 13 insertions(+), 123 deletions(-) diff --git a/packages/mermaid/package.json b/packages/mermaid/package.json index 244ebe453..f65ae6521 100644 --- a/packages/mermaid/package.json +++ b/packages/mermaid/package.json @@ -53,7 +53,6 @@ }, "dependencies": { "@braintree/sanitize-url": "^6.0.2", - "@khanacademy/simple-markdown": "^0.9.0", "cytoscape": "^3.23.0", "cytoscape-cose-bilkent": "^4.1.0", "cytoscape-fcose": "^2.1.0", @@ -64,6 +63,7 @@ "elkjs": "^0.8.2", "khroma": "^2.0.0", "lodash-es": "^4.17.21", + "mdast-util-from-markdown": "^1.3.0", "non-layered-tidy-tree-layout": "^2.0.2", "stylis": "^4.1.3", "ts-dedent": "^2.2.0", diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 94918dac1..699aa621d 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -181,9 +181,6 @@ importers: '@braintree/sanitize-url': specifier: ^6.0.2 version: 6.0.2 - '@khanacademy/simple-markdown': - specifier: ^0.9.0 - version: 0.9.2(react-dom@16.14.0)(react@16.14.0) cytoscape: specifier: ^3.23.0 version: 3.23.0 @@ -214,6 +211,9 @@ importers: lodash-es: specifier: ^4.17.21 version: 4.17.21 + mdast-util-from-markdown: + specifier: ^1.3.0 + version: 1.3.0 non-layered-tidy-tree-layout: specifier: ^2.0.2 version: 2.0.2 @@ -331,7 +331,7 @@ importers: version: 1.0.0 vitepress: specifier: ^1.0.0-alpha.72 - version: 1.0.0-alpha.72(@algolia/client-search@4.14.2)(react-dom@16.14.0)(react@16.14.0) + version: 1.0.0-alpha.72(@algolia/client-search@4.14.2) vitepress-plugin-search: specifier: ^1.0.4-alpha.20 version: 1.0.4-alpha.20(flexsearch@0.7.31)(vitepress@1.0.0-alpha.72)(vue@3.2.47) @@ -1900,10 +1900,10 @@ packages: resolution: {integrity: sha512-6SCwI7P8ao+se1TUsdZ7B4XzL+gqeQZnBc+2EONZlcVa0dVrk0NjETxozFKgMv0eEGH8QzP1fkN+A1rH61l4eg==} dev: true - /@docsearch/js@3.3.3(@algolia/client-search@4.14.2)(react-dom@16.14.0)(react@16.14.0): + /@docsearch/js@3.3.3(@algolia/client-search@4.14.2): resolution: {integrity: sha512-2xAv2GFuHzzmG0SSZgf8wHX0qZX8n9Y1ZirKUk5Wrdc+vH9CL837x2hZIUdwcPZI9caBA+/CzxsS68O4waYjUQ==} dependencies: - '@docsearch/react': 3.3.3(@algolia/client-search@4.14.2)(react-dom@16.14.0)(react@16.14.0) + '@docsearch/react': 3.3.3(@algolia/client-search@4.14.2) preact: 10.11.0 transitivePeerDependencies: - '@algolia/client-search' @@ -1912,7 +1912,7 @@ packages: - react-dom dev: true - /@docsearch/react@3.3.3(@algolia/client-search@4.14.2)(react-dom@16.14.0)(react@16.14.0): + /@docsearch/react@3.3.3(@algolia/client-search@4.14.2): resolution: {integrity: sha512-pLa0cxnl+G0FuIDuYlW+EBK6Rw2jwLw9B1RHIeS4N4s2VhsfJ/wzeCi3CWcs5yVfxLd5ZK50t//TMA5e79YT7Q==} peerDependencies: '@types/react': '>= 16.8.0 < 19.0.0' @@ -1930,8 +1930,6 @@ packages: '@algolia/autocomplete-preset-algolia': 1.7.4(@algolia/client-search@4.14.2)(algoliasearch@4.14.2) '@docsearch/css': 3.3.3 algoliasearch: 4.14.2 - react: 16.14.0 - react-dom: 16.14.0(react@16.14.0) transitivePeerDependencies: - '@algolia/client-search' dev: true @@ -2493,17 +2491,6 @@ packages: '@jridgewell/sourcemap-codec': 1.4.14 dev: true - /@khanacademy/simple-markdown@0.9.2(react-dom@16.14.0)(react@16.14.0): - resolution: {integrity: sha512-iRkSaVuUT+ho8B0aY0uLGgfS1YU84l/mSwjJTh0N0k0WzjdJUJY4+Eh56kn8whwD8QX6uNblAT0lT5ICATLtZg==} - peerDependencies: - react: 16.14.0 - react-dom: 16.14.0 - dependencies: - '@types/react': 18.0.33 - react: 16.14.0 - react-dom: 16.14.0(react@16.14.0) - dev: false - /@leichtgewicht/ip-codec@2.0.4: resolution: {integrity: sha512-Hcv+nVC0kZnQ3tD9GVu5xSMR4VVYOteQIr/hwFPVEvPdlXqgGEuRjiheChHgdM+JyqdgNcmzZOX/tnl0JOiI7A==} dev: true @@ -2936,7 +2923,6 @@ packages: resolution: {integrity: sha512-9AonUzyTjXXhEOa0DnqpzZi6VHlqKMswga9EXjpXnnqxwLtdvPPtlO8evrI5D9S6asFRCQ6v+wpiUKbw+vKqyg==} dependencies: '@types/ms': 0.7.31 - dev: true /@types/dompurify@3.0.2: resolution: {integrity: sha512-YBL4ziFebbbfQfH5mlC+QTJsvh0oJUrWbmxKMyEdL7emlHJqGR2Qb34TEFKj+VCayBvjKy3xczMFNhugThUsfQ==} @@ -3089,7 +3075,6 @@ packages: resolution: {integrity: sha512-Y/uImid8aAwrEA24/1tcRZwpxX3pIFTSilcNDKSPn+Y2iDywSEachzRuvgAYYLR3wpGXAsMbv5lvKLDZLeYPAw==} dependencies: '@types/unist': 2.0.6 - dev: true /@types/mdurl@1.0.2: resolution: {integrity: sha512-eC4U9MlIcu2q0KQmXszyn5Akca/0jrQmwDRgpAMJai7qBWq4amIQhZyNau4VYGtCeALvW1/NtjzJJ567aZxfKA==} @@ -3111,7 +3096,6 @@ packages: /@types/ms@0.7.31: resolution: {integrity: sha512-iiUgKzV9AuaEkZqkOLDIvlQiL6ltuZd9tGcW3gwpnX8JbuiuhFlEGmmFXEXkN50Cvq7Os88IY2v0dkDqXYWVgA==} - dev: true /@types/node-fetch@2.6.2: resolution: {integrity: sha512-DHqhlq5jeESLy19TYhLakJ07kNumXWjcDdxXsLUMJZ6ue8VZJj4kLPQVE/2mdHh3xZziNF1xppu5lwmS53HR+A==} @@ -3136,10 +3120,6 @@ packages: resolution: {integrity: sha512-KufADq8uQqo1pYKVIYzfKbJfBAc0sOeXqGbFaSpv8MRmC/zXgowNZmFcbngndGk922QDmOASEXUZCaY48gs4cg==} dev: true - /@types/prop-types@15.7.5: - resolution: {integrity: sha512-JCB8C6SnDoQf0cNycqd/35A7MjcnK+ZTqE7judS6o7utxUCg6imJg3QK2qzHKszlTjcj2cn+NwMB2i96ubpj7w==} - dev: false - /@types/qs@6.9.7: resolution: {integrity: sha512-FGa1F62FT09qcrueBA6qYTrJPVDzah9a+493+o2PCXsesWHIn27G98TsSMs3WPNbZIEj4+VJf6saSFpvD+3Zsw==} dev: true @@ -3148,14 +3128,6 @@ packages: resolution: {integrity: sha512-EEhsLsD6UsDM1yFhAvy0Cjr6VwmpMWqFBCb9w07wVugF7w9nfajxLuVmngTIpgS6svCnm6Vaw+MZhoDCKnOfsw==} dev: true - /@types/react@18.0.33: - resolution: {integrity: sha512-sHxzVxeanvQyQ1lr8NSHaj0kDzcNiGpILEVt69g9S31/7PfMvNCKLKcsHw4lYKjs3cGNJjXSP4mYzX43QlnjNA==} - dependencies: - '@types/prop-types': 15.7.5 - '@types/scheduler': 0.16.3 - csstype: 3.1.2 - dev: false - /@types/responselike@1.0.0: resolution: {integrity: sha512-85Y2BjiufFzaMIlvJDvTTB8Fxl2xfLo4HgmHzVBz08w4wDePCTjYw66PdrolO0kzli3yam/YCgRufyo1DdQVTA==} dependencies: @@ -3173,10 +3145,6 @@ packages: rollup: 2.79.1 dev: true - /@types/scheduler@0.16.3: - resolution: {integrity: sha512-5cJ8CB4yAx7BH1oMvdU0Jh9lrEXyPkar6F9G/ERswkCuvP4KQZfZkSjcMbAICCpQTN4OuZn8tz0HiKv9TGZgrQ==} - dev: false - /@types/semver@7.3.12: resolution: {integrity: sha512-WwA1MW0++RfXmCr12xeYOOC5baSC9mSb0ZqCquFzKhcoF4TvHu5MKOuXsncgZcpVFhB1pXd5hZmM0ryAoCp12A==} dev: true @@ -3226,7 +3194,6 @@ packages: /@types/unist@2.0.6: resolution: {integrity: sha512-PBjIUxZHOuj0R15/xuwJYjFi+KZdNFrehocChv4g5hu6aFroHue8m0lBP0POdK2nKzbw0cgV1mws8+V/JAcEkQ==} - dev: true /@types/uuid@9.0.1: resolution: {integrity: sha512-rFT3ak0/2trgvp4yYZo5iKFEPsET7vKydKF+VRCxlQ9bpheehyAJH89dAkaLEq/j/RZXJIqcgsmPJKUP1Z28HA==} @@ -4620,7 +4587,6 @@ packages: /character-entities@2.0.2: resolution: {integrity: sha512-shx7oQ0Awen/BRIdkjkvz54PnEEI/EjwXDSIZp86/KKdbafHh1Df/RYGBhn4hbe2+uKC9FnT5UCEdyPz3ai9hQ==} - dev: true /character-reference-invalid@1.1.4: resolution: {integrity: sha512-mKKUkUbhPpQlCOfIuZkvSEgktjPFIsZKRRbC6KWVEMvlzblj3i3asQv5ODsrwt0N3pHAEvjP8KTQPHkp0+6jOg==} @@ -5295,10 +5261,6 @@ packages: resolution: {integrity: sha512-Z1PhmomIfypOpoMjRQB70jfvy/wxT50qW08YXO5lMIJkrdq4yOTR+AW7FqutScmB9NkLwxo+jU+kZLbofZZq/w==} dev: true - /csstype@3.1.2: - resolution: {integrity: sha512-I7K1Uu0MBPzaFKg4nI5Q7Vs2t+3gWWW648spaF+Rg7pI9ds18Ugn+lvg4SHczUdKlHI5LWBXyqfS8+DufyBsgQ==} - dev: false - /cypress-image-snapshot@4.0.1(cypress@12.10.0)(jest@29.5.0): resolution: {integrity: sha512-PBpnhX/XItlx3/DAk5ozsXQHUi72exybBNH5Mpqj1DVmjq+S5Jd9WE5CRa4q5q0zuMZb2V2VpXHth6MjFpgj9Q==} engines: {node: '>=8'} @@ -5742,7 +5704,6 @@ packages: optional: true dependencies: ms: 2.1.2 - dev: true /debug@4.3.4(supports-color@8.1.1): resolution: {integrity: sha512-PRWFHuSU3eDtQJPvnNY7Jcket1j0t5OuOsFzPPzsekD52Zl8qUfFIPEiswXqIvHWGVHOgX+7G/vCNNhehwxfkQ==} @@ -5783,7 +5744,6 @@ packages: resolution: {integrity: sha512-O8x12RzrUF8xyVcY0KJowWsmaJxQbmy0/EtnNtHRpsOcT7dFk5W598coHqBVpmWo1oQQfsCqfCmkZN5DJrZVdg==} dependencies: character-entities: 2.0.2 - dev: true /decompress-response@6.0.0: resolution: {integrity: sha512-aW35yZM6Bb/4oJlZncMH2LCoZtJXTRxES17vE3hoRiowU2kWHaJKFkSBDnDR+cm9J+9QhXmREyIfv0pji9ejCQ==} @@ -5863,7 +5823,6 @@ packages: /dequal@2.0.3: resolution: {integrity: sha512-0je+qPKHEMohvfRTCEo3CrPG6cAzAYgmzKyxRiYSSDkS6eGJdyVJm7WaYA5ECaAD9wLB2T4EEeymA5aFVcYXCA==} engines: {node: '>=6'} - dev: true /destroy@1.2.0: resolution: {integrity: sha512-2sJGJTaXIIaR1w4iJSNoN0hnMY7Gpc/n8D4qSCJw8QqFWXf7cuAgnEHxBpweaVcPevC2l3KpjYCx3NypQQgaJg==} @@ -5892,7 +5851,6 @@ packages: /diff@5.1.0: resolution: {integrity: sha512-D+mk+qE8VC/PAUrlAU34N+VfXev0ghe5ywmpqrawphmVZc1bEfn56uo9qpyGp1p4xpzOHkSW4ztBd6L7Xx4ACw==} engines: {node: '>=0.3.1'} - dev: true /dir-glob@3.0.1: resolution: {integrity: sha512-WkrWp9GR4KXfKGYzOLmTuGVi1UWFfws377n9cc55/tb6DuqyF6pcQ5AbiHEshaDpY9v6oaSr2XCDidGmMwdzIA==} @@ -8365,6 +8323,7 @@ packages: /js-tokens@4.0.0: resolution: {integrity: sha512-RdJUflcE3cUzKiMqQgsCu06FPu9UdIJO0beYbPhHN4k6apgJtifcoCtT9bcxOpYBtpD2kCM6Sbzg4CausW/PKQ==} + dev: true /js-yaml@3.14.1: resolution: {integrity: sha512-okMH7OXXJ7YrN9Ok3/SXrnu4iX9yOk+25nqX4imS2npuvTYDmo/QEZoqwZkYaIDk3jVvBOTOIEgEhaLOynBS9g==} @@ -8562,7 +8521,6 @@ packages: /kleur@4.1.5: resolution: {integrity: sha512-o+NO+8WrRiQEE4/7nwRJhN1HWpVmJm511pBHUxPLtp0BUISzlBplORYSmTclCnJvQq2tKu/sgl3xVpkc7ZWuQQ==} engines: {node: '>=6'} - dev: true /ky@0.30.0: resolution: {integrity: sha512-X/u76z4JtDVq10u1JA5UQfatPxgPaVDMYTrgHyiTpGN2z4TMEJkIHsoSBBSg9SWZEIXTKsi9kHgiQ9o3Y/4yog==} @@ -8817,12 +8775,6 @@ packages: resolution: {integrity: sha512-cHlYSUpL2s7Fb3394mYxwTYj8niTaNHUCLr0qdiCXQfSjfuA7CKofpX2uSwEfFDQ0EB7JcnMnm+GjbqqoinYYg==} dev: true - /loose-envify@1.4.0: - resolution: {integrity: sha512-lyuxPGr/Wfhrlem2CL/UcnUc1zcqKAImBDzukY7Y5F/yQiNdko6+fRLevlw1HgMySw7f611UIY408EtxRSoK3Q==} - hasBin: true - dependencies: - js-tokens: 4.0.0 - /loupe@2.3.6: resolution: {integrity: sha512-RaPMZKiMy8/JruncMU5Bt6na1eftNoo++R4Y+N2FrxkDVTrGvcyzFTsaGif4QTeKESheMGegbhw6iUAq+5A8zA==} dependencies: @@ -8969,7 +8921,6 @@ packages: uvu: 0.5.6 transitivePeerDependencies: - supports-color - dev: true /mdast-util-frontmatter@1.0.0: resolution: {integrity: sha512-7itKvp0arEVNpCktOET/eLFAYaZ+0cNjVtFtIPxgQ5tV+3i+D4SDDTjTzPWl44LT59PC+xdx+glNTawBdF98Mw==} @@ -9051,7 +9002,6 @@ packages: /mdast-util-to-string@3.1.0: resolution: {integrity: sha512-n4Vypz/DZgwo0iMHLQL49dJzlp7YtAJP+N07MZHpjPf/5XJuHUWstviF4Mn2jEiR/GNmtnRRqnwsXExk3igfFA==} - dev: true /mdn-data@2.0.30: resolution: {integrity: sha512-GaqWWShW4kv/G9IEucWScBx9G1/vsFZZJUO+tD26M8J8z3Kw5RDQjaoZe03YAClgeS/SWPOcb4nkFBTEi5DUEA==} @@ -9145,7 +9095,6 @@ packages: micromark-util-symbol: 1.0.1 micromark-util-types: 1.0.2 uvu: 0.5.6 - dev: true /micromark-extension-frontmatter@1.0.0: resolution: {integrity: sha512-EXjmRnupoX6yYuUJSQhrQ9ggK0iQtQlpi6xeJzVD5xscyAI+giqco5fdymayZhJMbIFecjnE2yz85S9NzIgQpg==} @@ -9234,7 +9183,6 @@ packages: micromark-util-character: 1.1.0 micromark-util-symbol: 1.0.1 micromark-util-types: 1.0.2 - dev: true /micromark-factory-label@1.0.2: resolution: {integrity: sha512-CTIwxlOnU7dEshXDQ+dsr2n+yxpP0+fn271pu0bwDIS8uqfFcumXpj5mLn3hSC8iw2MUr6Gx8EcKng1dD7i6hg==} @@ -9243,14 +9191,12 @@ packages: micromark-util-symbol: 1.0.1 micromark-util-types: 1.0.2 uvu: 0.5.6 - dev: true /micromark-factory-space@1.0.0: resolution: {integrity: sha512-qUmqs4kj9a5yBnk3JMLyjtWYN6Mzfcx8uJfi5XAveBniDevmZasdGBba5b4QsvRcAkmvGo5ACmSUmyGiKTLZew==} dependencies: micromark-util-character: 1.1.0 micromark-util-types: 1.0.2 - dev: true /micromark-factory-title@1.0.2: resolution: {integrity: sha512-zily+Nr4yFqgMGRKLpTVsNl5L4PMu485fGFDOQJQBl2NFpjGte1e86zC0da93wf97jrc4+2G2GQudFMHn3IX+A==} @@ -9260,7 +9206,6 @@ packages: micromark-util-symbol: 1.0.1 micromark-util-types: 1.0.2 uvu: 0.5.6 - dev: true /micromark-factory-whitespace@1.0.0: resolution: {integrity: sha512-Qx7uEyahU1lt1RnsECBiuEbfr9INjQTGa6Err+gF3g0Tx4YEviPbqqGKNv/NrBaE7dVHdn1bVZKM/n5I/Bak7A==} @@ -9269,20 +9214,17 @@ packages: micromark-util-character: 1.1.0 micromark-util-symbol: 1.0.1 micromark-util-types: 1.0.2 - dev: true /micromark-util-character@1.1.0: resolution: {integrity: sha512-agJ5B3unGNJ9rJvADMJ5ZiYjBRyDpzKAOk01Kpi1TKhlT1APx3XZk6eN7RtSz1erbWHC2L8T3xLZ81wdtGRZzg==} dependencies: micromark-util-symbol: 1.0.1 micromark-util-types: 1.0.2 - dev: true /micromark-util-chunked@1.0.0: resolution: {integrity: sha512-5e8xTis5tEZKgesfbQMKRCyzvffRRUX+lK/y+DvsMFdabAicPkkZV6gO+FEWi9RfuKKoxxPwNL+dFF0SMImc1g==} dependencies: micromark-util-symbol: 1.0.1 - dev: true /micromark-util-classify-character@1.0.0: resolution: {integrity: sha512-F8oW2KKrQRb3vS5ud5HIqBVkCqQi224Nm55o5wYLzY/9PwHGXC01tr3d7+TqHHz6zrKQ72Okwtvm/xQm6OVNZA==} @@ -9290,20 +9232,17 @@ packages: micromark-util-character: 1.1.0 micromark-util-symbol: 1.0.1 micromark-util-types: 1.0.2 - dev: true /micromark-util-combine-extensions@1.0.0: resolution: {integrity: sha512-J8H058vFBdo/6+AsjHp2NF7AJ02SZtWaVUjsayNFeAiydTxUwViQPxN0Hf8dp4FmCQi0UUFovFsEyRSUmFH3MA==} dependencies: micromark-util-chunked: 1.0.0 micromark-util-types: 1.0.2 - dev: true /micromark-util-decode-numeric-character-reference@1.0.0: resolution: {integrity: sha512-OzO9AI5VUtrTD7KSdagf4MWgHMtET17Ua1fIpXTpuhclCqD8egFWo85GxSGvxgkGS74bEahvtM0WP0HjvV0e4w==} dependencies: micromark-util-symbol: 1.0.1 - dev: true /micromark-util-decode-string@1.0.2: resolution: {integrity: sha512-DLT5Ho02qr6QWVNYbRZ3RYOSSWWFuH3tJexd3dgN1odEuPNxCngTCXJum7+ViRAd9BbdxCvMToPOD/IvVhzG6Q==} @@ -9312,27 +9251,22 @@ packages: micromark-util-character: 1.1.0 micromark-util-decode-numeric-character-reference: 1.0.0 micromark-util-symbol: 1.0.1 - dev: true /micromark-util-encode@1.0.1: resolution: {integrity: sha512-U2s5YdnAYexjKDel31SVMPbfi+eF8y1U4pfiRW/Y8EFVCy/vgxk/2wWTxzcqE71LHtCuCzlBDRU2a5CQ5j+mQA==} - dev: true /micromark-util-html-tag-name@1.1.0: resolution: {integrity: sha512-BKlClMmYROy9UiV03SwNmckkjn8QHVaWkqoAqzivabvdGcwNGMMMH/5szAnywmsTBUzDsU57/mFi0sp4BQO6dA==} - dev: true /micromark-util-normalize-identifier@1.0.0: resolution: {integrity: sha512-yg+zrL14bBTFrQ7n35CmByWUTFsgst5JhA4gJYoty4Dqzj4Z4Fr/DHekSS5aLfH9bdlfnSvKAWsAgJhIbogyBg==} dependencies: micromark-util-symbol: 1.0.1 - dev: true /micromark-util-resolve-all@1.0.0: resolution: {integrity: sha512-CB/AGk98u50k42kvgaMM94wzBqozSzDDaonKU7P7jwQIuH2RU0TeBqGYJz2WY1UdihhjweivStrJ2JdkdEmcfw==} dependencies: micromark-util-types: 1.0.2 - dev: true /micromark-util-sanitize-uri@1.0.0: resolution: {integrity: sha512-cCxvBKlmac4rxCGx6ejlIviRaMKZc0fWm5HdCHEeDWRSkn44l6NdYVRyU+0nT1XC72EQJMZV8IPHF+jTr56lAg==} @@ -9340,7 +9274,6 @@ packages: micromark-util-character: 1.1.0 micromark-util-encode: 1.0.1 micromark-util-symbol: 1.0.1 - dev: true /micromark-util-subtokenize@1.0.2: resolution: {integrity: sha512-d90uqCnXp/cy4G881Ub4psE57Sf8YD0pim9QdjCRNjfas2M1u6Lbt+XZK9gnHL2XFhnozZiEdCa9CNfXSfQ6xA==} @@ -9349,15 +9282,12 @@ packages: micromark-util-symbol: 1.0.1 micromark-util-types: 1.0.2 uvu: 0.5.6 - dev: true /micromark-util-symbol@1.0.1: resolution: {integrity: sha512-oKDEMK2u5qqAptasDAwWDXq0tG9AssVwAx3E9bBF3t/shRIGsWIRG+cGafs2p/SnDSOecnt6hZPCE2o6lHfFmQ==} - dev: true /micromark-util-types@1.0.2: resolution: {integrity: sha512-DCfg/T8fcrhrRKTPjRrw/5LLvdGV7BHySf/1LOZx7TzWZdYRjogNtyNq885z3nNallwr3QUKARjqvHqX1/7t+w==} - dev: true /micromark@2.11.4: resolution: {integrity: sha512-+WoovN/ppKolQOFIAajxi7Lu9kInbPxFuTBVEavFcL8eAfVstoc5MocPmqBeAdBOJV00uaVjegzH4+MA0DN/uA==} @@ -9390,7 +9320,6 @@ packages: uvu: 0.5.6 transitivePeerDependencies: - supports-color - dev: true /micromatch@4.0.5: resolution: {integrity: sha512-DMy+ERcEW2q8Z2Po+WNXuw3c5YaUSFjAO5GsJqfEl7UjvtIuFKO6ZrKvcItdy98dwFI2N1tg3zNIdKaQT+aNdA==} @@ -9512,7 +9441,6 @@ packages: /mri@1.2.0: resolution: {integrity: sha512-tzzskb3bG8LvYGFF/mDTpq3jpI6Q9wc3LEmBaghu+DdCssd1FakN7Bc0hVNmEyGq1bq3RgfkCb3cmQLpNPOroA==} engines: {node: '>=4'} - dev: true /mrmime@1.0.1: resolution: {integrity: sha512-hzzEagAgDyoU1Q6yg5uI+AorQgdvMCur3FcKf7NhMKWsaYg+RnbTyHRa/9IlLF9rf455MOCtcqqrQQ83pPP7Uw==} @@ -9525,7 +9453,6 @@ packages: /ms@2.1.2: resolution: {integrity: sha512-sGkPx+VjMtmA6MX27oA4FBFELFCZZ4S4XqeGOXCv68tT+jb3vk/RyaKWP0PTKyWtmLSM0b+adUTEvbs1PEaH2w==} - dev: true /ms@2.1.3: resolution: {integrity: sha512-6FlzubTLZG3J2a/NVCAleEhjzq5oxgHyaCU9yYXvcLsvoVaHJq/s5xXI6/XXP6tz7R9xAOtHnSO/tXtF3WRTlA==} @@ -9702,6 +9629,7 @@ packages: /object-assign@4.1.1: resolution: {integrity: sha512-rJgTQnkUnH1sFw8yT6VSU3zD3sWmu6sZhIseY8VX+GRu3P6F7Fu+JNDoXfklElbLJSnc3FUQHVe4cU5hj+BcUg==} engines: {node: '>=0.10.0'} + dev: true /object-inspect@1.12.2: resolution: {integrity: sha512-z+cPxW0QGUp0mcqcsgQyLVRDoXFQbXOwBaqyF7VIgI4TWNQsDHrBpUQslRmIfAoYWdYzs6UlKJtB2XJpTaNSpQ==} @@ -10242,13 +10170,6 @@ packages: sisteransi: 1.0.5 dev: true - /prop-types@15.8.1: - resolution: {integrity: sha512-oj87CgZICdulUohogVAR7AjlC0327U4el4L6eAvOqCeudMDVU0NThNaV+b9Df4dXgSP1gXMTnPdhfe/2qDH5cg==} - dependencies: - loose-envify: 1.4.0 - object-assign: 4.1.1 - react-is: 16.13.1 - /proxy-addr@2.0.7: resolution: {integrity: sha512-llQsMLSUDUPT44jdrU/O37qlnifitDP+ZwrmmZcoSKyLKvtZxpyV0n2/bD/N4tBAAZ/gJEdZU7KMraoK1+XYAg==} engines: {node: '>= 0.10'} @@ -10374,20 +10295,6 @@ packages: unpipe: 1.0.0 dev: true - /react-dom@16.14.0(react@16.14.0): - resolution: {integrity: sha512-1gCeQXDLoIqMgqD3IO2Ah9bnf0w9kzhwN5q4FGnHZ67hBm9yePzB5JJAIQCc8x3pFnNlwFq4RidZggNAAkzWWw==} - peerDependencies: - react: ^16.14.0 - dependencies: - loose-envify: 1.4.0 - object-assign: 4.1.1 - prop-types: 15.8.1 - react: 16.14.0 - scheduler: 0.19.1 - - /react-is@16.13.1: - resolution: {integrity: sha512-24e6ynE2H+OKt4kqsOvNd8kBpV65zoxbA4BVsEOB3ARVWQki/DHzaUoC5KuON/BiccDaCCTZBuOcfZs70kR8bQ==} - /react-is@17.0.2: resolution: {integrity: sha512-w2GsyukL62IJnlaff/nRegPQR94C/XXamvMWmSHRJ4y7Ts/4ocGRmTHvOs8PSE6pB3dWOrD/nueuU5sduBsQ4w==} dev: true @@ -10396,14 +10303,6 @@ packages: resolution: {integrity: sha512-xWGDIW6x921xtzPkhiULtthJHoJvBbF3q26fzloPCK0hsvxtPVelvftw3zjbHWSkR2km9Z+4uxbDDK/6Zw9B8w==} dev: true - /react@16.14.0: - resolution: {integrity: sha512-0X2CImDkJGApiAlcf0ODKIneSwBPhqJawOa5wCtKbu7ZECrmS26NvtSILynQ66cgkT/RJ4LidJOc3bUESwmU8g==} - engines: {node: '>=0.10.0'} - dependencies: - loose-envify: 1.4.0 - object-assign: 4.1.1 - prop-types: 15.8.1 - /read-pkg-up@7.0.1: resolution: {integrity: sha512-zK0TB7Xd6JpCLmlLmufqykGE+/TlOePD6qKClNW7hHDKFh/J7/7gCWGR7joEQEW1bKq3a3yUZSObOoWLFQ4ohg==} engines: {node: '>=8'} @@ -10784,7 +10683,6 @@ packages: engines: {node: '>=6'} dependencies: mri: 1.2.0 - dev: true /safe-buffer@5.1.2: resolution: {integrity: sha512-Gd2UZBJDkXlY7GbJxfsE8/nvKkUEU1G38c1siN6QP6a9PT9MmHB8GnpscSmMJSoF8LOIrt8ud/wPtojys4G6+g==} @@ -10823,12 +10721,6 @@ packages: xmlchars: 2.2.0 dev: true - /scheduler@0.19.1: - resolution: {integrity: sha512-n/zwRWRYSUj0/3g/otKDRPMh6qv2SYMWNq85IEa8iZyAv8od9zDYpGSnpBEjNgcMNq6Scbu5KfIPxNF72R/2EA==} - dependencies: - loose-envify: 1.4.0 - object-assign: 4.1.1 - /schema-utils@3.1.1: resolution: {integrity: sha512-Y5PQxS4ITlC+EahLuXaY86TXfR7Dc5lw294alXOq86JAHCihAIZfqv8nNCWvaEJvaC51uN9hbLGeV0cFBdH+Fw==} engines: {node: '>= 10.13.0'} @@ -11921,7 +11813,6 @@ packages: resolution: {integrity: sha512-7A6eiDCs9UtjcwZOcCpM4aPII3bAAGv13E96IkawkOAW0OhH+yRxtY0lzo8KiHpzEMfH7Q+FizUmwp8Iqy5EWg==} dependencies: '@types/unist': 2.0.6 - dev: true /unist-util-visit-parents@5.1.1: resolution: {integrity: sha512-gks4baapT/kNRaWxuGkl5BIhoanZo7sC/cUT/JToSRNL1dYoXRFl75d++NkjYk4TAu2uv2Px+l8guMajogeuiw==} @@ -12021,7 +11912,6 @@ packages: diff: 5.1.0 kleur: 4.1.5 sade: 1.8.1 - dev: true /v8-compile-cache-lib@3.0.1: resolution: {integrity: sha512-wa7YjyUGfNZngI/vtK0UHAN+lgDCxBPCylVXGp0zu59Fz5aiGtNXaq3DhIov063MorB+VfufLh3JlF2KdTK3xg==} @@ -12173,16 +12063,16 @@ packages: flexsearch: 0.7.31 glob-to-regexp: 0.4.1 markdown-it: 13.0.1 - vitepress: 1.0.0-alpha.72(@algolia/client-search@4.14.2)(react-dom@16.14.0)(react@16.14.0) + vitepress: 1.0.0-alpha.72(@algolia/client-search@4.14.2) vue: 3.2.47 dev: true - /vitepress@1.0.0-alpha.72(@algolia/client-search@4.14.2)(react-dom@16.14.0)(react@16.14.0): + /vitepress@1.0.0-alpha.72(@algolia/client-search@4.14.2): resolution: {integrity: sha512-Ou7fNE/OVYLrKGQMHSTVG6AcNsdv7tm4ACrdhx93SPMzEDj8UgIb4RFa5CTTowaYf3jeDGi2EAJlzXVC+IE3dg==} hasBin: true dependencies: '@docsearch/css': 3.3.3 - '@docsearch/js': 3.3.3(@algolia/client-search@4.14.2)(react-dom@16.14.0)(react@16.14.0) + '@docsearch/js': 3.3.3(@algolia/client-search@4.14.2) '@vitejs/plugin-vue': 4.1.0(vite@4.2.2)(vue@3.2.47) '@vue/devtools-api': 6.5.0 '@vueuse/core': 10.0.2(vue@3.2.47) From 5bbce45c56d31012f3b140c10afbafad3187b9b2 Mon Sep 17 00:00:00 2001 From: Sidharth Vinod Date: Wed, 26 Apr 2023 10:51:54 +0530 Subject: [PATCH 05/22] Reduce changes in test --- .../handle-markdown-text.spec.ts | 555 +++++++----------- 1 file changed, 204 insertions(+), 351 deletions(-) diff --git a/packages/mermaid/src/rendering-util/handle-markdown-text.spec.ts b/packages/mermaid/src/rendering-util/handle-markdown-text.spec.ts index 877ea9b25..c8e08eed2 100644 --- a/packages/mermaid/src/rendering-util/handle-markdown-text.spec.ts +++ b/packages/mermaid/src/rendering-util/handle-markdown-text.spec.ts @@ -1,391 +1,244 @@ import { markdownToLines, markdownToHTML } from './handle-markdown-text.js'; import { test, expect } from 'vitest'; -describe('markdownToLines', () => { - test('Basic test', () => { - const input = `This is regular text +test('markdownToLines - Basic test', () => { + const input = `This is regular text Here is a new line There is some words **with a bold** section Here is a line *with an italic* section`; - const output = markdownToLines(input); - expect(output).toMatchInlineSnapshot(` + const expectedOutput = [ [ - [ - { - "content": "This", - "type": "normal", - }, - { - "content": "is", - "type": "normal", - }, - { - "content": "regular", - "type": "normal", - }, - { - "content": "text", - "type": "normal", - }, - ], - [ - { - "content": "Here", - "type": "normal", - }, - { - "content": "is", - "type": "normal", - }, - { - "content": "a", - "type": "normal", - }, - { - "content": "new", - "type": "normal", - }, - { - "content": "line", - "type": "normal", - }, - ], - [ - { - "content": "There", - "type": "normal", - }, - { - "content": "is", - "type": "normal", - }, - { - "content": "some", - "type": "normal", - }, - { - "content": "words", - "type": "normal", - }, - { - "content": "with", - "type": "strong", - }, - { - "content": "a", - "type": "strong", - }, - { - "content": "bold", - "type": "strong", - }, - { - "content": "section", - "type": "normal", - }, - ], - [ - { - "content": "Here", - "type": "normal", - }, - { - "content": "is", - "type": "normal", - }, - { - "content": "a", - "type": "normal", - }, - { - "content": "line", - "type": "normal", - }, - { - "content": "with", - "type": "emphasis", - }, - { - "content": "an", - "type": "emphasis", - }, - { - "content": "italic", - "type": "emphasis", - }, - { - "content": "section", - "type": "normal", - }, - ], - ] - `); - }); + { content: 'This', type: 'normal' }, + { content: 'is', type: 'normal' }, + { content: 'regular', type: 'normal' }, + { content: 'text', type: 'normal' }, + ], + [ + { content: 'Here', type: 'normal' }, + { content: 'is', type: 'normal' }, + { content: 'a', type: 'normal' }, + { content: 'new', type: 'normal' }, + { content: 'line', type: 'normal' }, + ], + [ + { content: 'There', type: 'normal' }, + { content: 'is', type: 'normal' }, + { content: 'some', type: 'normal' }, + { content: 'words', type: 'normal' }, + { content: 'with', type: 'strong' }, + { content: 'a', type: 'strong' }, + { content: 'bold', type: 'strong' }, + { content: 'section', type: 'normal' }, + ], + [ + { content: 'Here', type: 'normal' }, + { content: 'is', type: 'normal' }, + { content: 'a', type: 'normal' }, + { content: 'line', type: 'normal' }, + { content: 'with', type: 'emphasis' }, + { content: 'an', type: 'emphasis' }, + { content: 'italic', type: 'emphasis' }, + { content: 'section', type: 'normal' }, + ], + ]; - test('Empty input', () => { - const input = ''; - const expectedOutput = [[]]; - const output = markdownToLines(input); - expect(output).toEqual(expectedOutput); - }); + const output = markdownToLines(input); + expect(output).toEqual(expectedOutput); +}); - test('No formatting', () => { - const input = `This is a simple test +test('markdownToLines - Empty input', () => { + const input = ''; + const expectedOutput = [[]]; + const output = markdownToLines(input); + expect(output).toEqual(expectedOutput); +}); + +test('markdownToLines - No formatting', () => { + const input = `This is a simple test with no formatting`; - const expectedOutput = [ - [ - { content: 'This', type: 'normal' }, - { content: 'is', type: 'normal' }, - { content: 'a', type: 'normal' }, - { content: 'simple', type: 'normal' }, - { content: 'test', type: 'normal' }, - ], - [ - { content: 'with', type: 'normal' }, - { content: 'no', type: 'normal' }, - { content: 'formatting', type: 'normal' }, - ], - ]; + const expectedOutput = [ + [ + { content: 'This', type: 'normal' }, + { content: 'is', type: 'normal' }, + { content: 'a', type: 'normal' }, + { content: 'simple', type: 'normal' }, + { content: 'test', type: 'normal' }, + ], + [ + { content: 'with', type: 'normal' }, + { content: 'no', type: 'normal' }, + { content: 'formatting', type: 'normal' }, + ], + ]; - const output = markdownToLines(input); - expect(output).toEqual(expectedOutput); - }); + const output = markdownToLines(input); + expect(output).toEqual(expectedOutput); +}); - test('Only bold formatting', () => { - const input = `This is a **bold** test`; +test('markdownToLines - Only bold formatting', () => { + const input = `This is a **bold** test`; - const expectedOutput = [ - [ - { content: 'This', type: 'normal' }, - { content: 'is', type: 'normal' }, - { content: 'a', type: 'normal' }, - { content: 'bold', type: 'strong' }, - { content: 'test', type: 'normal' }, - ], - ]; + const expectedOutput = [ + [ + { content: 'This', type: 'normal' }, + { content: 'is', type: 'normal' }, + { content: 'a', type: 'normal' }, + { content: 'bold', type: 'strong' }, + { content: 'test', type: 'normal' }, + ], + ]; - const output = markdownToLines(input); - expect(output).toEqual(expectedOutput); - }); + const output = markdownToLines(input); + expect(output).toEqual(expectedOutput); +}); - test('paragraph 1', () => { - const input = `**Start** with +test('markdownToLines - paragraph 1', () => { + const input = `**Start** with a second line`; - const expectedOutput = [ - [ - { content: 'Start', type: 'strong' }, - { content: 'with', type: 'normal' }, - ], - [ - { content: 'a', type: 'normal' }, - { content: 'second', type: 'normal' }, - { content: 'line', type: 'normal' }, - ], - ]; + const expectedOutput = [ + [ + { content: 'Start', type: 'strong' }, + { content: 'with', type: 'normal' }, + ], + [ + { content: 'a', type: 'normal' }, + { content: 'second', type: 'normal' }, + { content: 'line', type: 'normal' }, + ], + ]; - const output = markdownToLines(input); - expect(output).toEqual(expectedOutput); - }); - - test('paragraph', () => { - const input = `**Start** with + const output = markdownToLines(input); + expect(output).toEqual(expectedOutput); +}); +test('markdownToLines - paragraph', () => { + const input = `**Start** with a second line`; - const expectedOutput = [ - [ - { content: 'Start', type: 'strong' }, - { content: 'with', type: 'normal' }, - ], - [ - { content: 'a', type: 'normal' }, - { content: 'second', type: 'normal' }, - { content: 'line', type: 'normal' }, - ], - ]; - - const output = markdownToLines(input); - expect(output).toEqual(expectedOutput); - }); - - test('Only italic formatting', () => { - const input = `This is an *italic* test`; - const output = markdownToLines(input); - expect(output).toMatchInlineSnapshot(` + const expectedOutput = [ [ - [ - { - "content": "This", - "type": "normal", - }, - { - "content": "is", - "type": "normal", - }, - { - "content": "an", - "type": "normal", - }, - { - "content": "italic", - "type": "emphasis", - }, - { - "content": "test", - "type": "normal", - }, - ], - ] - `); - }); - - test('Mixed formatting', () => { - const input = `*Italic* and **bold** formatting`; - const output = markdownToLines(input); - expect(output).toMatchInlineSnapshot(` + { content: 'Start', type: 'strong' }, + { content: 'with', type: 'normal' }, + ], [ - [ - { - "content": "Italic", - "type": "emphasis", - }, - { - "content": "and", - "type": "normal", - }, - { - "content": "bold", - "type": "strong", - }, - { - "content": "formatting", - "type": "normal", - }, - ], - ] - `); - }); + { content: 'a', type: 'normal' }, + { content: 'second', type: 'normal' }, + { content: 'line', type: 'normal' }, + ], + ]; - test('Mixed formatting with newline', () => { - const input = `The dog in **the** hog... a *very long text* about it + const output = markdownToLines(input); + expect(output).toEqual(expectedOutput); +}); + +test('markdownToLines - Only italic formatting', () => { + const input = `This is an *italic* test`; + + const expectedOutput = [ + [ + { content: 'This', type: 'normal' }, + { content: 'is', type: 'normal' }, + { content: 'an', type: 'normal' }, + { content: 'italic', type: 'emphasis' }, + { content: 'test', type: 'normal' }, + ], + ]; + + const output = markdownToLines(input); + expect(output).toEqual(expectedOutput); +}); + +it('markdownToLines - Mixed formatting', () => { + const input = `*Italic* and **bold** formatting`; + + const expectedOutput = [ + [ + { content: 'Italic', type: 'emphasis' }, + { content: 'and', type: 'normal' }, + { content: 'bold', type: 'strong' }, + { content: 'formatting', type: 'normal' }, + ], + ]; + + const output = markdownToLines(input); + expect(output).toEqual(expectedOutput); +}); + +it('markdownToLines - Mixed formatting', () => { + const input = `The dog in **the** hog... a *very long text* about it Word!`; - const output = markdownToLines(input); - expect(output).toMatchInlineSnapshot(` + const expectedOutput = [ [ - [ - { - "content": "The", - "type": "normal", - }, - { - "content": "dog", - "type": "normal", - }, - { - "content": "in", - "type": "normal", - }, - { - "content": "the", - "type": "strong", - }, - { - "content": "hog...", - "type": "normal", - }, - { - "content": "a", - "type": "normal", - }, - { - "content": "very", - "type": "emphasis", - }, - { - "content": "long", - "type": "emphasis", - }, - { - "content": "text", - "type": "emphasis", - }, - { - "content": "about", - "type": "normal", - }, - { - "content": "it", - "type": "normal", - }, - ], - [ - { - "content": "Word!", - "type": "normal", - }, - ], - ] - `); - }); + { content: 'The', type: 'normal' }, + { content: 'dog', type: 'normal' }, + { content: 'in', type: 'normal' }, + { content: 'the', type: 'strong' }, + { content: 'hog...', type: 'normal' }, + { content: 'a', type: 'normal' }, + { content: 'very', type: 'emphasis' }, + { content: 'long', type: 'emphasis' }, + { content: 'text', type: 'emphasis' }, + { content: 'about', type: 'normal' }, + { content: 'it', type: 'normal' }, + ], + [{ content: 'Word!', type: 'normal' }], + ]; + + const output = markdownToLines(input); + expect(output).toEqual(expectedOutput); }); -describe('markdownToHTML', () => { - test('Basic test', () => { - const input = `This is regular text +test('markdownToHTML - Basic test', () => { + const input = `This is regular text Here is a new line There is some words **with a bold** section Here is a line *with an italic* section`; - const output = markdownToHTML(input); - expect(output).toMatchInlineSnapshot( - '"

This is regular text
Here is a new line
There is some words with a bold section
Here is a line with an italic section

"' - ); - }); + const expectedOutput = `

This is regular text
Here is a new line
There is some words with a bold section
Here is a line with an italic section

`; - test('Empty input', () => { - const input = ''; - const expectedOutput = ''; - const output = markdownToHTML(input); - expect(output).toEqual(expectedOutput); - }); + const output = markdownToHTML(input); + expect(output).toEqual(expectedOutput); +}); - test('No formatting', () => { - const input = `This is a simple test +test('markdownToHTML - Empty input', () => { + const input = ''; + const expectedOutput = ''; + const output = markdownToHTML(input); + expect(output).toEqual(expectedOutput); +}); + +test('markdownToHTML - No formatting', () => { + const input = `This is a simple test with no formatting`; - const expectedOutput = `

This is a simple test
with no formatting

`; - const output = markdownToHTML(input); - expect(output).toEqual(expectedOutput); - }); - - test('Only bold formatting', () => { - const input = `This is a **bold** test`; - - const expectedOutput = `

This is a bold test

`; - const output = markdownToHTML(input); - expect(output).toEqual(expectedOutput); - }); - - test('Only italic formatting', () => { - const input = `This is an *italic* test`; - - const expectedOutput = `

This is an italic test

`; - const output = markdownToHTML(input); - expect(output).toEqual(expectedOutput); - }); - - test('Mixed formatting', () => { - const input = `*Italic* and **bold** formatting`; - const expectedOutput = `

Italic and bold formatting

`; - const output = markdownToHTML(input); - expect(output).toEqual(expectedOutput); - // const expectedOutput = 'this text has some special characters: `<p>hi</p>`'; - expect( - markdownToHTML('this text has some special characters: `

hi

`') - ).toMatchInlineSnapshot('"

this text has some special characters:

"'); - }); + const expectedOutput = `

This is a simple test
with no formatting

`; + const output = markdownToHTML(input); + expect(output).toEqual(expectedOutput); +}); + +test('markdownToHTML - Only bold formatting', () => { + const input = `This is a **bold** test`; + + const expectedOutput = `

This is a bold test

`; + const output = markdownToHTML(input); + expect(output).toEqual(expectedOutput); +}); + +test('markdownToHTML - Only italic formatting', () => { + const input = `This is an *italic* test`; + + const expectedOutput = `

This is an italic test

`; + const output = markdownToHTML(input); + expect(output).toEqual(expectedOutput); +}); + +test('markdownToHTML - Mixed formatting', () => { + const input = `*Italic* and **bold** formatting`; + const expectedOutput = `

Italic and bold formatting

`; + const output = markdownToHTML(input); + expect(output).toEqual(expectedOutput); }); From eba3a7bdcc83bba73a116b92fbc5f92aad5250ec Mon Sep 17 00:00:00 2001 From: Sidharth Vinod Date: Wed, 26 Apr 2023 10:55:37 +0530 Subject: [PATCH 06/22] Add unsupported text --- .../src/rendering-util/handle-markdown-text.spec.ts | 9 +++++++++ .../mermaid/src/rendering-util/handle-markdown-text.ts | 2 +- 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/packages/mermaid/src/rendering-util/handle-markdown-text.spec.ts b/packages/mermaid/src/rendering-util/handle-markdown-text.spec.ts index c8e08eed2..8ae519cfa 100644 --- a/packages/mermaid/src/rendering-util/handle-markdown-text.spec.ts +++ b/packages/mermaid/src/rendering-util/handle-markdown-text.spec.ts @@ -242,3 +242,12 @@ test('markdownToHTML - Mixed formatting', () => { const output = markdownToHTML(input); expect(output).toEqual(expectedOutput); }); + +test('markdownToHTML - Unsupported formatting', () => { + expect( + markdownToHTML(`Hello + - l1 + - l2 + - l3`) + ).toMatchInlineSnapshot('"

Hello

Unsupported markdown: list"'); +}); diff --git a/packages/mermaid/src/rendering-util/handle-markdown-text.ts b/packages/mermaid/src/rendering-util/handle-markdown-text.ts index 3a7319922..a8b73aec7 100644 --- a/packages/mermaid/src/rendering-util/handle-markdown-text.ts +++ b/packages/mermaid/src/rendering-util/handle-markdown-text.ts @@ -68,7 +68,7 @@ export function markdownToHTML(markdown: string): string { } else if (node.type === 'paragraph') { return `

${node.children.map(output).join('')}

`; } - return ''; + return `Unsupported markdown: ${node.type}`; } return children.map(output).join(''); From 91f1ef9c42b6c70355d6172df2f4af7037b80880 Mon Sep 17 00:00:00 2001 From: Sidharth Vinod Date: Wed, 26 Apr 2023 11:00:35 +0530 Subject: [PATCH 07/22] Back to JS with jsdoc types --- ...rkdown-text.ts => handle-markdown-text.js} | 40 ++++++++++++------- 1 file changed, 25 insertions(+), 15 deletions(-) rename packages/mermaid/src/rendering-util/{handle-markdown-text.ts => handle-markdown-text.js} (74%) diff --git a/packages/mermaid/src/rendering-util/handle-markdown-text.ts b/packages/mermaid/src/rendering-util/handle-markdown-text.js similarity index 74% rename from packages/mermaid/src/rendering-util/handle-markdown-text.ts rename to packages/mermaid/src/rendering-util/handle-markdown-text.js index a8b73aec7..5102429d3 100644 --- a/packages/mermaid/src/rendering-util/handle-markdown-text.ts +++ b/packages/mermaid/src/rendering-util/handle-markdown-text.js @@ -1,8 +1,11 @@ import { fromMarkdown } from 'mdast-util-from-markdown'; -import type { Content } from 'mdast'; import { dedent } from 'ts-dedent'; -function preprocessMarkdown(markdown: string): string { +/** + * @param {string} markdown markdown to process + * @returns {string} processed markdown + */ +function preprocessMarkdown(markdown) { // Replace multiple newlines with a single newline const withoutMultipleNewlines = markdown.replace(/\n{2,}/g, '\n'); // Remove extra spaces at the beginning of each line @@ -10,20 +13,20 @@ function preprocessMarkdown(markdown: string): string { return withoutExtraSpaces; } -interface Word { - content: string; - type: string; -} - -type Line = Word[]; - -export function markdownToLines(markdown: string): Line[] { +/** + * @param {string} markdown markdown to split into lines + */ +export function markdownToLines(markdown) { const preprocessedMarkdown = preprocessMarkdown(markdown); const { children } = fromMarkdown(preprocessedMarkdown); - const lines: Line[] = [[]]; + const lines = [[]]; let currentLine = 0; - function processNode(node: Content, parentType?: string) { + /** + * @param {import('mdast').Content} node + * @param {string} [parentType] + */ + function processNode(node, parentType = 'normal') { if (node.type === 'text') { const textLines = node.value.split('\n'); textLines.forEach((textLine, index) => { @@ -33,7 +36,7 @@ export function markdownToLines(markdown: string): Line[] { } textLine.split(' ').forEach((word) => { if (word) { - lines[currentLine].push({ content: word, type: parentType || 'normal' }); + lines[currentLine].push({ content: word, type: parentType }); } }); }); @@ -55,10 +58,17 @@ export function markdownToLines(markdown: string): Line[] { return lines; } -export function markdownToHTML(markdown: string): string { +/** + * @param {string} markdown markdown to convert to HTML + * @returns {string} HTML + */ +export function markdownToHTML(markdown) { const { children } = fromMarkdown(markdown); - function output(node: Content): string { + /** + * @param {import('mdast').Content} node + */ + function output(node) { if (node.type === 'text') { return node.value.replace(/\n/g, '
'); } else if (node.type === 'strong') { From 75e73a4f032f09fdabf039a36b24afdcbb3147db Mon Sep 17 00:00:00 2001 From: Sidharth Vinod Date: Tue, 9 May 2023 10:20:33 +0530 Subject: [PATCH 08/22] Bump version --- packages/mermaid/package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/mermaid/package.json b/packages/mermaid/package.json index e3458f9ce..61a9e44e6 100644 --- a/packages/mermaid/package.json +++ b/packages/mermaid/package.json @@ -1,6 +1,6 @@ { "name": "mermaid", - "version": "10.2.0-rc.2", + "version": "10.2.0-rc.3", "description": "Markdown-ish syntax for generating flowcharts, sequence diagrams, class diagrams, gantt charts and git graphs.", "type": "module", "module": "./dist/mermaid.core.mjs", From fbd35ae95a7d311542ae73a34f45c6c7e799975e Mon Sep 17 00:00:00 2001 From: Sidharth Vinod Date: Tue, 9 May 2023 10:24:05 +0530 Subject: [PATCH 09/22] fix lint command --- .github/workflows/lint.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/lint.yml b/.github/workflows/lint.yml index a21fbc005..d4bf4afe8 100644 --- a/.github/workflows/lint.yml +++ b/.github/workflows/lint.yml @@ -42,7 +42,7 @@ jobs: if ! pnpm run lint; then # print a nice error message on lint failure ERROR_MESSAGE='Running `pnpm run lint` failed.' - ERROR_MESSAGE+=' Running `pnpm run lint:fix` may fix this issue. ' + ERROR_MESSAGE+=' Running `pnpm -w run lint:fix` may fix this issue. ' ERROR_MESSAGE+=" If this error doesn't occur on your local machine," ERROR_MESSAGE+=' make sure your packages are up-to-date by running `pnpm install`.' ERROR_MESSAGE+=' You may also need to delete your prettier cache by running' From d86d1e7887d62dffb4c96559cc960ac5b7c68064 Mon Sep 17 00:00:00 2001 From: Sidharth Vinod Date: Mon, 15 May 2023 13:32:59 +0530 Subject: [PATCH 10/22] fix: Use unicode arrows in quadrant chart axis --- .../mermaid/src/diagrams/quadrant-chart/parser/quadrant.jison | 4 ++-- .../src/diagrams/quadrant-chart/parser/quadrant.jison.spec.ts | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/packages/mermaid/src/diagrams/quadrant-chart/parser/quadrant.jison b/packages/mermaid/src/diagrams/quadrant-chart/parser/quadrant.jison index 555eea152..5a4bb9d20 100644 --- a/packages/mermaid/src/diagrams/quadrant-chart/parser/quadrant.jison +++ b/packages/mermaid/src/diagrams/quadrant-chart/parser/quadrant.jison @@ -119,10 +119,10 @@ points axisDetails : X-AXIS text AXIS-TEXT-DELIMITER text {yy.setXAxisLeftText($2); yy.setXAxisRightText($4);} - | X-AXIS text AXIS-TEXT-DELIMITER {$2.text += $3; yy.setXAxisLeftText($2);} + | X-AXIS text AXIS-TEXT-DELIMITER {$2.text += " ⭢ "; yy.setXAxisLeftText($2);} | X-AXIS text {yy.setXAxisLeftText($2);} | Y-AXIS text AXIS-TEXT-DELIMITER text {yy.setYAxisBottomText($2); yy.setYAxisTopText($4);} - | Y-AXIS text AXIS-TEXT-DELIMITER {$2.text += $3; yy.setYAxisBottomText($2);} + | Y-AXIS text AXIS-TEXT-DELIMITER {$2.text += " ⭢ "; yy.setYAxisBottomText($2);} | Y-AXIS text {yy.setYAxisBottomText($2);} ; diff --git a/packages/mermaid/src/diagrams/quadrant-chart/parser/quadrant.jison.spec.ts b/packages/mermaid/src/diagrams/quadrant-chart/parser/quadrant.jison.spec.ts index f91858c72..5b25f22f7 100644 --- a/packages/mermaid/src/diagrams/quadrant-chart/parser/quadrant.jison.spec.ts +++ b/packages/mermaid/src/diagrams/quadrant-chart/parser/quadrant.jison.spec.ts @@ -93,7 +93,7 @@ describe('Testing quadrantChart jison file', () => { str = 'quadrantChart\n x-AxIs "Urgent(* +=[❤" --> '; expect(parserFnConstructor(str)).not.toThrow(); expect(mockDB.setXAxisLeftText).toHaveBeenCalledWith({ - text: 'Urgent(* +=[❤ --> ', + text: 'Urgent(* +=[❤ ⭢ ', type: 'text', }); expect(mockDB.setXAxisRightText).not.toHaveBeenCalled(); @@ -131,7 +131,7 @@ describe('Testing quadrantChart jison file', () => { str = 'quadrantChart\n y-AxIs "Urgent(* +=[❤" --> '; expect(parserFnConstructor(str)).not.toThrow(); expect(mockDB.setYAxisBottomText).toHaveBeenCalledWith({ - text: 'Urgent(* +=[❤ --> ', + text: 'Urgent(* +=[❤ ⭢ ', type: 'text', }); expect(mockDB.setYAxisTopText).not.toHaveBeenCalled(); From b925849893d771c18297ff8bbd5de54af4fbfe80 Mon Sep 17 00:00:00 2001 From: Sidharth Vinod Date: Mon, 15 May 2023 13:36:35 +0530 Subject: [PATCH 11/22] fix: Use unicode arrows in quadrant chart axis --- .../mermaid/src/diagrams/quadrant-chart/parser/quadrant.jison | 4 ++-- .../src/diagrams/quadrant-chart/parser/quadrant.jison.spec.ts | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/packages/mermaid/src/diagrams/quadrant-chart/parser/quadrant.jison b/packages/mermaid/src/diagrams/quadrant-chart/parser/quadrant.jison index 5a4bb9d20..00c125294 100644 --- a/packages/mermaid/src/diagrams/quadrant-chart/parser/quadrant.jison +++ b/packages/mermaid/src/diagrams/quadrant-chart/parser/quadrant.jison @@ -119,10 +119,10 @@ points axisDetails : X-AXIS text AXIS-TEXT-DELIMITER text {yy.setXAxisLeftText($2); yy.setXAxisRightText($4);} - | X-AXIS text AXIS-TEXT-DELIMITER {$2.text += " ⭢ "; yy.setXAxisLeftText($2);} + | X-AXIS text AXIS-TEXT-DELIMITER {$2.text += " ⟶ "; yy.setXAxisLeftText($2);} | X-AXIS text {yy.setXAxisLeftText($2);} | Y-AXIS text AXIS-TEXT-DELIMITER text {yy.setYAxisBottomText($2); yy.setYAxisTopText($4);} - | Y-AXIS text AXIS-TEXT-DELIMITER {$2.text += " ⭢ "; yy.setYAxisBottomText($2);} + | Y-AXIS text AXIS-TEXT-DELIMITER {$2.text += " ⟶ "; yy.setYAxisBottomText($2);} | Y-AXIS text {yy.setYAxisBottomText($2);} ; diff --git a/packages/mermaid/src/diagrams/quadrant-chart/parser/quadrant.jison.spec.ts b/packages/mermaid/src/diagrams/quadrant-chart/parser/quadrant.jison.spec.ts index 5b25f22f7..05b18b935 100644 --- a/packages/mermaid/src/diagrams/quadrant-chart/parser/quadrant.jison.spec.ts +++ b/packages/mermaid/src/diagrams/quadrant-chart/parser/quadrant.jison.spec.ts @@ -93,7 +93,7 @@ describe('Testing quadrantChart jison file', () => { str = 'quadrantChart\n x-AxIs "Urgent(* +=[❤" --> '; expect(parserFnConstructor(str)).not.toThrow(); expect(mockDB.setXAxisLeftText).toHaveBeenCalledWith({ - text: 'Urgent(* +=[❤ ⭢ ', + text: 'Urgent(* +=[❤ ⟶ ', type: 'text', }); expect(mockDB.setXAxisRightText).not.toHaveBeenCalled(); @@ -131,7 +131,7 @@ describe('Testing quadrantChart jison file', () => { str = 'quadrantChart\n y-AxIs "Urgent(* +=[❤" --> '; expect(parserFnConstructor(str)).not.toThrow(); expect(mockDB.setYAxisBottomText).toHaveBeenCalledWith({ - text: 'Urgent(* +=[❤ ⭢ ', + text: 'Urgent(* +=[❤ ⟶ ', type: 'text', }); expect(mockDB.setYAxisTopText).not.toHaveBeenCalled(); From 3a5c4a149fc3d66673807d251666f44eb3b6aecc Mon Sep 17 00:00:00 2001 From: Justin Greywolf Date: Tue, 16 May 2023 04:12:03 -0700 Subject: [PATCH 12/22] fix parsing issue with class diagrams --- .../mermaid/src/diagrams/class/svgDraw.js | 66 ------------------- 1 file changed, 66 deletions(-) diff --git a/packages/mermaid/src/diagrams/class/svgDraw.js b/packages/mermaid/src/diagrams/class/svgDraw.js index 4c8b4369b..2d1af8b87 100644 --- a/packages/mermaid/src/diagrams/class/svgDraw.js +++ b/packages/mermaid/src/diagrams/class/svgDraw.js @@ -361,72 +361,6 @@ export const drawNote = function (elem, note, conf, diagObj) { }; export const parseMember = function (text) { - // Note: these two regular expressions don't parse the official UML syntax for attributes - // and methods. They parse a Java-style syntax of the form - // "String name" (for attributes) and "String name(int x)" for methods - const fieldRegEx = /^([#+~-])?(\w+)(~\w+~|\[])?\s+(\w+) *([$*])?$/; - const methodRegEx = /^([#+|~-])?(\w+) *\( *(.*)\) *([$*])? *(\w*[[\]|~]*\s*\w*~?)$/; - - let fieldMatch = text.match(fieldRegEx); - let methodMatch = text.match(methodRegEx); - - if (fieldMatch && !methodMatch) { - return buildFieldDisplay(fieldMatch); - } else if (methodMatch) { - return buildMethodDisplay(methodMatch); - } else { - return buildLegacyDisplay(text); - } -}; - -const buildFieldDisplay = function (parsedText) { - let cssStyle = ''; - let displayText = ''; - - try { - let visibility = parsedText[1] ? parsedText[1].trim() : ''; - let fieldType = parsedText[2] ? parsedText[2].trim() : ''; - let genericType = parsedText[3] ? parseGenericTypes(parsedText[3].trim()) : ''; - let fieldName = parsedText[4] ? parsedText[4].trim() : ''; - let classifier = parsedText[5] ? parsedText[5].trim() : ''; - - displayText = visibility + fieldType + genericType + ' ' + fieldName; - cssStyle = parseClassifier(classifier); - } catch (err) { - displayText = parsedText; - } - - return { - displayText: displayText, - cssStyle: cssStyle, - }; -}; - -const buildMethodDisplay = function (parsedText) { - let cssStyle = ''; - let displayText = ''; - - try { - let visibility = parsedText[1] ? parsedText[1].trim() : ''; - let methodName = parsedText[2] ? parsedText[2].trim() : ''; - let parameters = parsedText[3] ? parseGenericTypes(parsedText[3].trim()) : ''; - let classifier = parsedText[4] ? parsedText[4].trim() : ''; - let returnType = parsedText[5] ? ' : ' + parseGenericTypes(parsedText[5]).trim() : ''; - - displayText = visibility + methodName + '(' + parameters + ')' + returnType; - cssStyle = parseClassifier(classifier); - } catch (err) { - displayText = parsedText; - } - - return { - displayText: displayText, - cssStyle: cssStyle, - }; -}; - -const buildLegacyDisplay = function (text) { - // if for some reason we don't have any match, use old format to parse text let displayText = ''; let cssStyle = ''; let returnType = ''; From 78efac2c51a36a1c4de971d37e9d9fde8b482fba Mon Sep 17 00:00:00 2001 From: Justin Greywolf Date: Tue, 16 May 2023 06:13:37 -0700 Subject: [PATCH 13/22] Fix visibility issue for fields --- packages/mermaid/src/diagrams/class/svgDraw.js | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/packages/mermaid/src/diagrams/class/svgDraw.js b/packages/mermaid/src/diagrams/class/svgDraw.js index 2d1af8b87..e4afe2136 100644 --- a/packages/mermaid/src/diagrams/class/svgDraw.js +++ b/packages/mermaid/src/diagrams/class/svgDraw.js @@ -378,14 +378,15 @@ export const parseMember = function (text) { cssStyle = parseClassifier(lastChar); } - let startIndex = visibility === '' ? 0 : 1; + const startIndex = visibility === '' ? 0 : 1; let endIndex = cssStyle === '' ? text.length : text.length - 1; text = text.substring(startIndex, endIndex); - let methodStart = text.indexOf('('); - let methodEnd = text.indexOf(')'); + const methodStart = text.indexOf('('); + const methodEnd = text.indexOf(')'); + const isMethod = methodStart > 1 && methodEnd > methodStart && methodEnd <= text.length; - if (methodStart > 1 && methodEnd > methodStart && methodEnd <= text.length) { + if (isMethod) { let methodName = text.substring(0, methodStart).trim(); const parameters = text.substring(methodStart + 1, methodEnd); @@ -412,7 +413,7 @@ export const parseMember = function (text) { } } else { // finally - if all else fails, just send the text back as written (other than parsing for generic types) - displayText = parseGenericTypes(text); + displayText = visibility + parseGenericTypes(text); } return { From 9fb25310e8d4cedd7ade5e3286a5713c119296a1 Mon Sep 17 00:00:00 2001 From: Knut Sveidqvist Date: Wed, 24 May 2023 11:27:17 +0200 Subject: [PATCH 14/22] Fix for regression error in sequenceDiagrams --- cypress/platform/knsv.html | 393 +++--------------- .../mermaid/src/diagrams/sequence/svgDraw.js | 35 +- 2 files changed, 84 insertions(+), 344 deletions(-) diff --git a/cypress/platform/knsv.html b/cypress/platform/knsv.html index f6ee1ef03..32710ae8c 100644 --- a/cypress/platform/knsv.html +++ b/cypress/platform/knsv.html @@ -42,368 +42,75 @@ -
-flowchart LR
-  subgraph one
-    direction LR
-    A[myClass1] --> B[default]
-    subgraph two
-      direction BT
-      C[myClass2] --> D[default]
-    end
-  end
-
+    
+      sequenceDiagram
+      Alice->>Bob: Extremely utterly long line of longness which had previously overflown the actor box as it is much longer than what it should be
+      loop Loopy
+          Bob->>Alice: Pasten
+      end
     
-
-flowchart LR
-  classDef aPID stroke:#4e4403,fill:#fdde29,color:#4e4403,rx:5px,ry:5px;
-  classDef crm stroke:#333333,fill:#DCDCDC,color:#333333,rx:5px,ry:5px;
-  classDef type stroke:#502604,fill:#FAB565,color:#502604,rx:20px,ry:20px;;
-
-  O0("Joe")
-  class O0 aPID;
-
-  O1("Person")
-  class O1 crm;
-  O0 -- has type -->O1["Person"]
-
-  O2("aat:300411314")
-  class O2 type;
-  click O2 function "Sorry the newline html tags are not being processed correctly
So all of this appears on the
same line." - O0 -- has type -->O2["Bug"] - click O0 function "Lots of great info about Joe
Lots of great info about Joe
burt
fred"; -
-
-flowchart TD
-    subgraph test
-    direction TB
-    subgraph test2
-      direction LR
-      F --> D
-    end
-    subgraph test3
-      direction TB
-      G --> H
-    end
-    end
-    
-
-flowchart TD
-
-  release-branch[Create Release Branch]:::relClass
-  develop-branch[Update Develop Branch]:::relClass
-  github-release-draft[GitHub Release Draft]:::relClass
-  trigger-pipeline[Trigger Jenkins pipeline]:::fixClass
-  github-release[GitHub Release]:::postClass
-
-  build-ready --> release-branch
-  build-ready --> develop-branch
-  release-branch --> jenkins-release-build
-  jenkins-release-build --> github-release-draft
-  jenkins-release-build --> install-release
-  install-release --> verify-release
-  jenkins-release-build --> announce
-  github-release-draft --> github-release
-  verify-release --> verify-check
-  verify-check -- Yes --> github-release
-  verify-check -- No --> release-fix
-  release-fix --> release-branch-pr
-  verify-check -- No --> delete-artifacts
-  release-branch-pr --> trigger-pipeline
-  delete-artifacts --> trigger-pipeline
-  trigger-pipeline --> jenkins-release-build
-
-
-    
-
-flowchart LR
-        a["Haiya"]===>b
-    
-
-flowchart TD
-    A --> B
-    A --> C
-    B --> C
-    
-
-flowchart TD
-      A([stadium shape test])
-      A -->|Get money| B([Go shopping])
-      B --> C([Let me think...
Do I want something for work,
something to spend every free second with,
or something to get around?]) - C -->|One| D([Laptop]) - C -->|Two| E([iPhone]) - C -->|Three| F([Car
wroom wroom]) - click A "index.html#link-clicked" "link test" - click B testClick "click test" - classDef someclass fill:#f96; - class A someclass; - class C someclass; -
-
-   sequenceDiagram
-      title: My Sequence Diagram Title
-      accTitle: My Acc Sequence Diagram
-      accDescr: My Sequence Diagram Description
-
-      Alice->>John: Hello John, how are you?
-      John-->>Alice: Great!
-      Alice-)John: See you later!
-    
-
-graph TD
-    A -->|000| B
-    B -->|111| C
-
-    linkStyle 1 stroke:#ff3,stroke-width:4px,color:red;
-    
-
-  journey
-      accTitle: My User Journey Diagram
-      accDescr: My User Journey Diagram Description
-
-      title My working day
-      section Go to work
-        Make tea: 5: Me
-        Go upstairs: 3: Me
-        Do work: 1: Me, Cat
-      section Go home
-        Go downstairs: 5: Me
-        Sit down: 5: Me
-    
-
-        info
-    
-
-requirementDiagram
-      accTitle: My req Diagram
-      accDescr: My req Diagram Description
-
-    requirement test_req {
-    id: 1
-    text: the test text.
-    risk: high
-    verifymethod: test
-    }
-
-    functionalRequirement test_req2 {
-    id: 1.1
-    text: the second test text.
-    risk: low
-    verifymethod: inspection
-    }
-
-    performanceRequirement test_req3 {
-    id: 1.2
-    text: the third test text.
-    risk: medium
-    verifymethod: demonstration
-    }
-
-    element test_entity {
-    type: simulation
-    }
-
-    element test_entity2 {
-    type: word doc
-    docRef: reqs/test_entity
-    }
-
-
-    test_entity - satisfies -> test_req2
-    test_req - traces -> test_req2
-    test_req - contains -> test_req3
-    test_req <- copies - test_entity2
-    
-
-gantt
-    dateFormat  YYYY-MM-DD
-    title       Adding GANTT diagram functionality to mermaid
-    excludes    weekends
-    %% (`excludes` accepts specific dates in YYYY-MM-DD format, days of the week ("sunday") or "weekends", but not the word "weekdays".)
-
-    section A section
-    Completed task            :done,    des1, 2014-01-06,2014-01-08
-    Active task               :active,  des2, 2014-01-09, 3d
-    Future task               :         des3, after des2, 5d
-    Future task2              :         des4, after des3, 5d
-
-    section Critical tasks
-    Completed task in the critical line :crit, done, 2014-01-06,24h
-    Implement parser and jison          :crit, done, after des1, 2d
-    Create tests for parser             :crit, active, 3d
-    Future task in critical line        :crit, 5d
-    Create tests for renderer           :2d
-    Add to mermaid                      :1d
-    Functionality added                 :milestone, 2014-01-25, 0d
-
-    section Documentation
-    Describe gantt syntax               :active, a1, after des1, 3d
-    Add gantt diagram to demo page      :after a1  , 20h
-    Add another diagram to demo page    :doc1, after a1  , 48h
-
-    section Last section
-    Describe gantt syntax               :after doc1, 3d
-    Add gantt diagram to demo page      :20h
-    Add another diagram to demo page    :48h
-    
-
-stateDiagram
-  state Active {
-    Idle
-  }
-  Inactive --> Idle: ACT
-  Active --> Active: LOG
-    
-
-      flowchart TB
-        accTitle: My flowchart
-        accDescr: My flowchart Description
-        subgraph One
-          a1-->a2-->a3
+    
+      sequenceDiagram
+        participant Alice
+        participant Bob
+        participant John as John
Second Line + Alice ->> Bob: Hello Bob, how are you? + Bob-->>John: How about you John? + Bob--x Alice: I am good thanks! + Bob-x John: I am good thanks! + Note right of John: Bob thinks a long
long time, so long
that the text does
not fit on a row. + Bob-->Alice: Checking with John... + alt either this + Alice->>John: Yes + else or this + Alice->>John: No + else or this will happen + Alice->John: Maybe + end + par this happens in parallel + Alice -->> Bob: Parallel message 1 + and + Alice -->> John: Parallel message 2 end
-
-        sequenceDiagram
-          A ->> B: 1
-          rect rgb(204, 0, 102)
-            break yes
-              rect rgb(0, 204, 204)
-                C ->> C: 0
-              end
-            end
-          end
-          B ->> A: Return
-    
-
-classDiagram
-accTitle: My class diagram
-accDescr: My class diagram Description
-Class01 <|-- AveryLongClass : Cool
-Class09 --> C2 : Where am i?
-Class09 --* C3
-Class09 --|> Class07
-Class07 : equals()
-Class07 : Object[] elementData
-Class01 : size()
-Class01 : int chimp
-Class01 : int gorilla
-class Class10 {
-  int id
-  size()
-}
-    
-
-%%{init: {'config': {'wrap': true }}}%%
-        sequenceDiagram
-        participant A as Extremely utterly long line of longness which had previously overflown the actor box as it is much longer than what it should be
-        A->>Bob: Hola
-        Bob-->A: Pasten !
-    
-
-      gitGraph
-       commit id: "ZERO"
-       branch develop
-       commit id:"A"
-       checkout main
-       commit id:"ONE"
-       checkout develop
-       commit id:"B"
-       branch featureA
-       commit id:"FIX"
-       commit id: "FIX-2"
-       checkout main
-       commit id:"TWO"
-       cherry-pick id:"A"
-       commit id:"THREE"
-       cherry-pick id:"FIX"
-       checkout develop
-       commit id:"C"
-       merge featureA
-    
-
-flowchart TD
-      A[Christmas] -->|Get money| B(Go shopping)
-      B --> C{Let me think}
-      C -->|One| D[Laptop]
-      C -->|Two| E[iPhone]
-      C -->|Three| F[fa:fa-car Car]
-    
-
-        classDiagram
-          Animal "1" <|-- Duck
-          Animal <|-- Fish
-          Animal <--o Zebra
-          Animal : +int age
-          Animal : +String gender
-          Animal: +isMammal()
-          Animal: +mate()
-          class Duck{
-            +String beakColor
-            +swim()
-            +quack()
-          }
-          class Fish{
-            -int sizeInFeet
-            -canEat()
-          }
-          class Zebra{
-            +bool is_wild
-            +run()
-          }
-    
-
-        erDiagram
-    CAR ||--o{ NAMED-DRIVER : allows
-    CAR {
-        string registrationNumber
-        string make
-        string model
-    }
-    PERSON ||--o{ NAMED-DRIVER : is
-    PERSON {
-        string firstName
-        string lastName
-        int age
-    }
-    
- - - - diff --git a/packages/mermaid/src/diagrams/sequence/svgDraw.js b/packages/mermaid/src/diagrams/sequence/svgDraw.js index 2358b20ad..a8feea2a1 100644 --- a/packages/mermaid/src/diagrams/sequence/svgDraw.js +++ b/packages/mermaid/src/diagrams/sequence/svgDraw.js @@ -578,7 +578,7 @@ export const drawLoop = function (elem, loopModel, labelText, conf) { txt.class = 'labelText'; drawLabel(g, txt); - txt = svgDrawCommon.getTextObj(); + txt = getTextObj(); txt.text = loopModel.title; txt.x = loopModel.startx + labelBoxWidth / 2 + (loopModel.stopx - loopModel.startx) / 2; txt.y = loopModel.starty + boxMargin + boxTextMargin; @@ -764,6 +764,37 @@ export const insertArrowCrossHead = function (elem) { // this is actual shape for arrowhead }; +export const getTextObj = function () { + return { + x: 0, + y: 0, + fill: undefined, + anchor: undefined, + style: '#666', + width: undefined, + height: undefined, + textMargin: 0, + rx: 0, + ry: 0, + tspan: true, + valign: undefined, + }; +}; + +export const getNoteRect = function () { + return { + x: 0, + y: 0, + fill: '#EDF2AE', + stroke: '#666', + width: 100, + anchor: 'start', + height: 100, + rx: 0, + ry: 0, + }; +}; + const _drawTextCandidateFunc = (function () { /** * @param {any} content @@ -1004,6 +1035,8 @@ export default { insertDatabaseIcon, insertComputerIcon, insertClockIcon, + getTextObj, + getNoteRect, popupMenu, popdownMenu, fixLifeLineHeights, From bd616e0ef56bfeb6bed6fd36b924674f956b4fff Mon Sep 17 00:00:00 2001 From: Knut Sveidqvist Date: Wed, 24 May 2023 12:27:30 +0200 Subject: [PATCH 15/22] Test commit --- cypress/platform/knsv.html | 37 +++++++++++++++---------------------- 1 file changed, 15 insertions(+), 22 deletions(-) diff --git a/cypress/platform/knsv.html b/cypress/platform/knsv.html index 32710ae8c..dd4775f27 100644 --- a/cypress/platform/knsv.html +++ b/cypress/platform/knsv.html @@ -50,28 +50,21 @@ end
-      sequenceDiagram
-        participant Alice
-        participant Bob
-        participant John as John
Second Line - Alice ->> Bob: Hello Bob, how are you? - Bob-->>John: How about you John? - Bob--x Alice: I am good thanks! - Bob-x John: I am good thanks! - Note right of John: Bob thinks a long
long time, so long
that the text does
not fit on a row. - Bob-->Alice: Checking with John... - alt either this - Alice->>John: Yes - else or this - Alice->>John: No - else or this will happen - Alice->John: Maybe - end - par this happens in parallel - Alice -->> Bob: Parallel message 1 - and - Alice -->> John: Parallel message 2 - end + %%{init: {"flowchart": {"htmlLabels": false}} }%% + flowchart LR + b("`The dog in **the** hog.(1) + NL`") --"`1o **bold**`"--> c[new strings svg labels] +
+
+      %%{init: {"flowchart": {"htmlLabels": true}} }%%
+      flowchart LR
+      b("`The dog in **the** hog.(1)
+      NL`") --"`1o **bold**`"--> c[new strings html labels]
+    
+
+      %%{init: {"flowchart": {"htmlLabels": true}} }%%
+      flowchart LR
+      b("The dog in the hog.(1)\nNL") --"1o bold"--> c[old strings svg labels]