@chayns-components/format 5.0.0-beta.674 → 5.0.0-beta.683
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/cjs/constants/format.js +8 -0
- package/lib/cjs/constants/format.js.map +1 -0
- package/lib/cjs/index.js +7 -0
- package/lib/cjs/index.js.map +1 -1
- package/lib/cjs/utils/escape.js +1 -3
- package/lib/cjs/utils/escape.js.map +1 -1
- package/lib/cjs/utils/formatString/bb-code/formatBBCode.js +2 -2
- package/lib/cjs/utils/formatString/bb-code/formatBBCode.js.map +1 -1
- package/lib/cjs/utils/formatString/formatString.test.js +5 -0
- package/lib/cjs/utils/formatString/formatString.test.js.map +1 -1
- package/lib/cjs/utils/formatString/markdown/formatMarkdown.js +6 -0
- package/lib/cjs/utils/formatString/markdown/formatMarkdown.js.map +1 -1
- package/lib/esm/constants/format.js +2 -0
- package/lib/esm/constants/format.js.map +1 -0
- package/lib/esm/index.js +1 -0
- package/lib/esm/index.js.map +1 -1
- package/lib/esm/utils/escape.js +0 -2
- package/lib/esm/utils/escape.js.map +1 -1
- package/lib/esm/utils/formatString/bb-code/formatBBCode.js +1 -1
- package/lib/esm/utils/formatString/bb-code/formatBBCode.js.map +1 -1
- package/lib/esm/utils/formatString/formatString.test.js +5 -0
- package/lib/esm/utils/formatString/formatString.test.js.map +1 -1
- package/lib/esm/utils/formatString/markdown/formatMarkdown.js +6 -0
- package/lib/esm/utils/formatString/markdown/formatMarkdown.js.map +1 -1
- package/lib/types/constants/format.d.ts +1 -0
- package/lib/types/index.d.ts +2 -0
- package/lib/types/utils/escape.d.ts +0 -2
- package/lib/types/utils/formatString/bb-code/formatBBCode.d.ts +4 -1
- package/package.json +2 -2
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"format.js","names":["BB_CODE_HTML_TAG_PREFIX","exports"],"sources":["../../../src/constants/format.ts"],"sourcesContent":["export const BB_CODE_HTML_TAG_PREFIX = 'bb-code-';\n"],"mappings":";;;;;;AAAO,MAAMA,uBAAuB,GAAAC,OAAA,CAAAD,uBAAA,GAAG,UAAU","ignoreList":[]}
|
package/lib/cjs/index.js
CHANGED
|
@@ -3,11 +3,18 @@
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
|
+
Object.defineProperty(exports, "BB_CODE_HTML_TAG_PREFIX", {
|
|
7
|
+
enumerable: true,
|
|
8
|
+
get: function () {
|
|
9
|
+
return _format.BB_CODE_HTML_TAG_PREFIX;
|
|
10
|
+
}
|
|
11
|
+
});
|
|
6
12
|
Object.defineProperty(exports, "formatStringToHtml", {
|
|
7
13
|
enumerable: true,
|
|
8
14
|
get: function () {
|
|
9
15
|
return _formatString.formatStringToHtml;
|
|
10
16
|
}
|
|
11
17
|
});
|
|
18
|
+
var _format = require("./constants/format");
|
|
12
19
|
var _formatString = require("./utils/formatString/formatString");
|
|
13
20
|
//# sourceMappingURL=index.js.map
|
package/lib/cjs/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","names":["
|
|
1
|
+
{"version":3,"file":"index.js","names":["_format","require","_formatString"],"sources":["../../src/index.ts"],"sourcesContent":["export { BB_CODE_HTML_TAG_PREFIX } from './constants/format';\nexport type { TableObject } from './types/format';\nexport { formatStringToHtml } from './utils/formatString/formatString';\n"],"mappings":";;;;;;;;;;;;;;;;;AAAA,IAAAA,OAAA,GAAAC,OAAA;AAEA,IAAAC,aAAA,GAAAD,OAAA","ignoreList":[]}
|
package/lib/cjs/utils/escape.js
CHANGED
|
@@ -3,9 +3,7 @@
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
|
-
exports.escapeHtmlInText =
|
|
6
|
+
exports.escapeHtmlInText = void 0;
|
|
7
7
|
const escapeHtmlInText = text => text.replace(/</g, '<').replace(/>/g, '>');
|
|
8
8
|
exports.escapeHtmlInText = escapeHtmlInText;
|
|
9
|
-
const MESSAGE_CONVERSION_LINE_BREAK = exports.MESSAGE_CONVERSION_LINE_BREAK = '<br is-replaced-linebreak>';
|
|
10
|
-
const MESSAGE_CONVERSION_LINE_BREAK_ESCAPED = exports.MESSAGE_CONVERSION_LINE_BREAK_ESCAPED = escapeHtmlInText(MESSAGE_CONVERSION_LINE_BREAK);
|
|
11
9
|
//# sourceMappingURL=escape.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"escape.js","names":["escapeHtmlInText","text","replace","exports"
|
|
1
|
+
{"version":3,"file":"escape.js","names":["escapeHtmlInText","text","replace","exports"],"sources":["../../../src/utils/escape.ts"],"sourcesContent":["export const escapeHtmlInText = (text: string): string =>\n text.replace(/</g, '<').replace(/>/g, '>');\n"],"mappings":";;;;;;AAAO,MAAMA,gBAAgB,GAAIC,IAAY,IACzCA,IAAI,CAACC,OAAO,CAAC,IAAI,EAAE,MAAM,CAAC,CAACA,OAAO,CAAC,IAAI,EAAE,MAAM,CAAC;AAACC,OAAA,CAAAH,gBAAA,GAAAA,gBAAA","ignoreList":[]}
|
|
@@ -4,8 +4,8 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.unescapeBBCodeSquareBrackets = exports.parseBBCode = exports.escapeBBCodeSquareBrackets = void 0;
|
|
7
|
+
var _format = require("../../../constants/format");
|
|
7
8
|
var _findBBCode = require("./findBBCode");
|
|
8
|
-
const BB_CODE_HTML_TAG_PREFIX = 'bb-code-';
|
|
9
9
|
const BLOCK_LEVEL_TAGS = ['center', 'ul', 'ol', 'li', 'h1', 'h2', 'h3', 'h4', 'h5', 'h6', 'p'];
|
|
10
10
|
const INLINE_LEVEL_TAGS = ['b', 'strong', 'i', 'em', 'u', 's', 'span', 'img'];
|
|
11
11
|
// Parses BB-Code to HTML recursively.
|
|
@@ -74,7 +74,7 @@ const parseBBCode = (text, options) => {
|
|
|
74
74
|
htmlAfterTag = htmlAfterTag.replace(/^\n/, '');
|
|
75
75
|
}
|
|
76
76
|
const isCustomTag = [...customBlockLevelTags, ...customInlineLevelTags].includes(Tag);
|
|
77
|
-
const htmlTag = isCustomTag ? `${BB_CODE_HTML_TAG_PREFIX}${Tag}` : Tag;
|
|
77
|
+
const htmlTag = isCustomTag ? `${_format.BB_CODE_HTML_TAG_PREFIX}${Tag}` : Tag;
|
|
78
78
|
const openingHtmlTag = `<${htmlTag}${Object.entries(parameters).length > 0 ? ' ' : ''}${Object.entries(parameters).map(([key, value]) => `${key}="${value}"`).join(' ')}>`;
|
|
79
79
|
const closingHtmlTag = `</${htmlTag}>`;
|
|
80
80
|
const element = Tag === 'img' ? openingHtmlTag : openingHtmlTag + parsedContent + closingHtmlTag;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"formatBBCode.js","names":["
|
|
1
|
+
{"version":3,"file":"formatBBCode.js","names":["_format","require","_findBBCode","BLOCK_LEVEL_TAGS","INLINE_LEVEL_TAGS","parseBBCode","text","options","customBlockLevelBBCodeTags","customBlockLevelTags","customInlineLevelBBCodeTags","customInlineLevelTags","justEscapeSquareBrackets","html","parseBehindIndex","length","htmlToParse","slice","firstBBCodeMatch","findFirstBBCode","content","fullMatch","parameters","index","openingTag","closingTag","Tag","tag","toLowerCase","isValidTag","includes","isBlockLevelTag","parsedContent","indexOfFullMatch","indexOf","escapedOpeningTag","escapeBBCodeSquareBrackets","escapedClosingTag","replace","htmlAfterTag","isCustomTag","htmlTag","BB_CODE_HTML_TAG_PREFIX","openingHtmlTag","Object","entries","map","key","value","join","closingHtmlTag","element","exports","replaceAll","unescapeBBCodeSquareBrackets"],"sources":["../../../../../src/utils/formatString/bb-code/formatBBCode.ts"],"sourcesContent":["import { BB_CODE_HTML_TAG_PREFIX } from '../../../constants/format';\nimport { findFirstBBCode } from './findBBCode';\n\nconst BLOCK_LEVEL_TAGS = ['center', 'ul', 'ol', 'li', 'h1', 'h2', 'h3', 'h4', 'h5', 'h6', 'p'];\nconst INLINE_LEVEL_TAGS = ['b', 'strong', 'i', 'em', 'u', 's', 'span', 'img'];\n\nexport interface ParseBBCodesOptions {\n customBlockLevelBBCodeTags?: string[];\n customInlineLevelBBCodeTags?: string[];\n}\n\ninterface ParseBBCodePrivateOptions extends ParseBBCodesOptions {\n justEscapeSquareBrackets?: boolean;\n}\n\n// Parses BB-Code to HTML recursively.\n// When justEscapeSquareBrackets is true, square brackets are escaped to prevent conflicts between markdown and BB Code.\n// In that case the function only escapes square brackets and doesn't remove line breaks.\nexport const parseBBCode = (text: string, options?: ParseBBCodePrivateOptions) => {\n const {\n customBlockLevelBBCodeTags: customBlockLevelTags = [],\n customInlineLevelBBCodeTags: customInlineLevelTags = [],\n justEscapeSquareBrackets = false,\n } = options || {};\n\n let html = text;\n\n // This index is used to keep track of the position in the html string that is being parsed.\n let parseBehindIndex = 0;\n\n while (parseBehindIndex < html.length) {\n const htmlToParse = html.slice(parseBehindIndex);\n\n const firstBBCodeMatch = findFirstBBCode(htmlToParse);\n\n // Stops parsing if no BB-Code is found.\n if (!firstBBCodeMatch) {\n return html;\n }\n\n const { content, fullMatch, parameters, index, openingTag, closingTag } = firstBBCodeMatch;\n\n const Tag = firstBBCodeMatch.tag.toLowerCase();\n const isValidTag = [\n ...BLOCK_LEVEL_TAGS,\n ...customBlockLevelTags,\n ...INLINE_LEVEL_TAGS,\n ...customInlineLevelTags,\n ].includes(Tag);\n const isBlockLevelTag = [...BLOCK_LEVEL_TAGS, ...customBlockLevelTags].includes(Tag);\n\n // Ignores tags that are not supported.\n if (!isValidTag) {\n // The parsing continues behind the first square bracket of the BB-Code tag.\n parseBehindIndex += index + 1;\n // eslint-disable-next-line no-continue\n continue;\n }\n\n // Converts BB-Code tag's content before converting itself, because it may contain other BB-Codes.\n let parsedContent = parseBBCode(content, options);\n\n if (justEscapeSquareBrackets) {\n const indexOfFullMatch = html.indexOf(fullMatch);\n const escapedOpeningTag = escapeBBCodeSquareBrackets(openingTag);\n const escapedClosingTag = escapeBBCodeSquareBrackets(closingTag);\n\n // Removes leading and trailing line-breaks from within bb code elements, to prevent unwanted spacing.\n // This needs to be done before formatting Markdown, so the Markdown formatting doesn't interpret line breaks unexpectedly.\n parsedContent = parsedContent.replace(/^\\n+|\\n+$/g, '');\n\n // Simply escapes the square brackets of the BB-Code opening and closing tag.\n html =\n html.slice(0, indexOfFullMatch) +\n escapedOpeningTag +\n parsedContent +\n escapedClosingTag +\n html.slice(indexOfFullMatch + fullMatch.length);\n\n // Continues parsing behind the parsed bb-code.\n parseBehindIndex =\n indexOfFullMatch +\n escapedOpeningTag.length +\n parsedContent.length +\n escapedClosingTag.length;\n } else {\n const indexOfFullMatch = html.indexOf(fullMatch);\n\n let htmlAfterTag = html.slice(indexOfFullMatch + fullMatch.length);\n\n // Removes leading line-break (ONE, NOT ALL) after block level elements, to prevent unwanted spacing.\n if (isBlockLevelTag) {\n htmlAfterTag = htmlAfterTag.replace(/^\\n/, '');\n }\n\n const isCustomTag = [...customBlockLevelTags, ...customInlineLevelTags].includes(Tag);\n const htmlTag = isCustomTag ? `${BB_CODE_HTML_TAG_PREFIX}${Tag}` : Tag;\n const openingHtmlTag = `<${htmlTag}${Object.entries(parameters).length > 0 ? ' ' : ''}${Object.entries(\n parameters,\n )\n .map(([key, value]) => `${key}=\"${value}\"`)\n .join(' ')}>`;\n const closingHtmlTag = `</${htmlTag}>`;\n\n const element =\n Tag === 'img' ? openingHtmlTag : openingHtmlTag + parsedContent + closingHtmlTag;\n\n html = `${html.slice(0, indexOfFullMatch)}${element}${htmlAfterTag}`;\n\n // Continues parsing behind the parsed bb-code.\n parseBehindIndex = indexOfFullMatch + element.length;\n }\n }\n\n return html;\n};\n\nexport const escapeBBCodeSquareBrackets = (text: string) =>\n text.replaceAll('[', '‍[‍').replaceAll(']', '‍]‍');\n\nexport const unescapeBBCodeSquareBrackets = (text: string) =>\n text.replaceAll('‍[‍', '[').replaceAll('‍]‍', ']');\n"],"mapp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AC;AAACD,OAAA,CAAAE,4BAAA,GAAAA,4BAAA","ignoreList":[]}
|
|
@@ -184,6 +184,11 @@ const removeLinebreaks = text => text.replace(/\n/g, '');
|
|
|
184
184
|
(0, _vitest.expect)(resultWithLanguage.html).toEqual('<pre><code class="language-js">const a = 1;\nconst b = 2;</code></pre>');
|
|
185
185
|
(0, _vitest.expect)(resultWithLanguage.tables).toEqual([]);
|
|
186
186
|
});
|
|
187
|
+
(0, _vitest.test)('should not format 4 spaces as code block', () => {
|
|
188
|
+
const result = (0, _formatString.formatStringToHtml)(' const a = 1;');
|
|
189
|
+
(0, _vitest.expect)(result.html).toEqual('<p> const a = 1;</p>');
|
|
190
|
+
(0, _vitest.expect)(result.tables).toEqual([]);
|
|
191
|
+
});
|
|
187
192
|
(0, _vitest.describe)('HTML In Code', () => {
|
|
188
193
|
(0, _vitest.test)('should escape < and > within code block', () => {
|
|
189
194
|
const resultWithoutLanguage = (0, _formatString.formatStringToHtml)('```\n<div>Test</div>\n```');
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"formatString.test.js","names":["_vitest","require","_formatString","removeLinebreaks","text","replace","describe","test","result","formatStringToHtml","expect","html","toEqual","tables","resultEscape","resultEscape1","resultEscape2","boldResult","italicResult","inlineCodeResult","h1Result","h2Result","h3Result","h4Result","h5Result","h6Result","expectedUnorderedListResult","expectedOrderedListResult","unorderedListResult1","unorderedListResult2","orderedListResult","orderedListResult2","expectedThematicBreakResult","result1","result2","resultWithoutLanguage","resultWithLanguage","inputString","csv","raw","id","parseBBCode","table1","getTable1Result","index","table1Csv","table2","getTable2TResult","table2Csv","getHeadingInput","tag","getHeadingOutput","headingTags","forEach","input","output","customInlineLevelBBCodeTags","customBlockLevelBBCodeTags"],"sources":["../../../../src/utils/formatString/formatString.test.ts"],"sourcesContent":["import { describe, expect, test } from 'vitest';\nimport { formatStringToHtml } from './formatString';\n\nconst removeLinebreaks = (text: string) => text.replace(/\\n/g, '');\n\ndescribe('HTML Formatter Function', () => {\n describe('Format Plain Text', () => {\n describe('Line breaks', () => {\n test('should format line breaks correctly', () => {\n const result = formatStringToHtml('Line 1\\nLine 2');\n expect(result.html).toEqual('<p>Line 1\\nLine 2</p>');\n expect(result.tables).toEqual([]);\n });\n\n test('should format multiple line breaks correctly', () => {\n const result = formatStringToHtml('Line 1\\n\\nLine 2');\n expect(result.html).toEqual('<p>Line 1</p>\\n<p>Line 2</p>');\n expect(result.tables).toEqual([]);\n });\n\n test('should remove trailing and leading new lines', () => {\n const result = formatStringToHtml('\\n\\n\\nLine 1\\n\\n\\n');\n expect(result.html).toEqual('<p>Line 1</p>');\n expect(result.tables).toEqual([]);\n });\n });\n\n describe('Whitespaces', () => {\n test('should not remove repeated whitespaces', () => {\n const result = formatStringToHtml('Text with spaces');\n expect(result.html).toEqual('<p>Text with spaces</p>');\n expect(result.tables).toEqual([]);\n });\n\n test('should not remove leading and trailing whitespaces', () => {\n const result = formatStringToHtml(' Text ');\n expect(result.html).toEqual('<p> Text </p>');\n expect(result.tables).toEqual([]);\n });\n });\n\n describe('HTML', () => {\n test('should escape < and > correctly', () => {\n const resultEscape = formatStringToHtml('<div>Test</div>');\n expect(resultEscape.html).toEqual('<p><div>Test</div></p>');\n expect(resultEscape.tables).toEqual([]);\n });\n\n test('should not escape &', () => {\n const resultEscape1 = formatStringToHtml('<div>Test</div>');\n expect(resultEscape1.html).toEqual('<p><div>Test</div></p>');\n expect(resultEscape1.tables).toEqual([]);\n\n const resultEscape2 = formatStringToHtml(\n '&lt;div&gt;Test&lt;/div&gt;',\n );\n expect(resultEscape2.html).toEqual(\n '<p>&lt;div&gt;Test&lt;/div&gt;</p>',\n );\n expect(resultEscape2.tables).toEqual([]);\n });\n\n // TODO Decide if & should be escaped, when they are not part of an HTML entity.\n });\n\n describe('URLs', () => {\n test('should not format URLs', () => {\n const result = formatStringToHtml('https://example.com');\n expect(result.html).toEqual('<p>https://example.com</p>');\n expect(result.tables).toEqual([]);\n });\n });\n });\n\n describe('Format Markdown', () => {\n describe('All Elements', () => {\n test('should format text styling correctly', () => {\n const boldResult = formatStringToHtml('**bold**');\n expect(boldResult.html).toEqual('<p><strong>bold</strong></p>');\n expect(boldResult.tables).toEqual([]);\n\n const italicResult = formatStringToHtml('*italic*');\n expect(italicResult.html).toEqual('<p><em>italic</em></p>');\n expect(italicResult.tables).toEqual([]);\n\n const inlineCodeResult = formatStringToHtml('`inline code`');\n expect(inlineCodeResult.html).toEqual('<p><code>inline code</code></p>');\n expect(inlineCodeResult.tables).toEqual([]);\n });\n\n test('should format headings correctly', () => {\n const h1Result = formatStringToHtml('# h1');\n expect(h1Result.html).toEqual('<h1>h1</h1>');\n expect(h1Result.tables).toEqual([]);\n\n const h2Result = formatStringToHtml('## h2');\n expect(h2Result.html).toEqual('<h2>h2</h2>');\n expect(h2Result.tables).toEqual([]);\n\n const h3Result = formatStringToHtml('### h3');\n expect(h3Result.html).toEqual('<h3>h3</h3>');\n expect(h3Result.tables).toEqual([]);\n\n const h4Result = formatStringToHtml('#### h4');\n expect(h4Result.html).toEqual('<h4>h4</h4>');\n expect(h4Result.tables).toEqual([]);\n\n const h5Result = formatStringToHtml('##### h5');\n expect(h5Result.html).toEqual('<h5>h5</h5>');\n expect(h5Result.tables).toEqual([]);\n\n const h6Result = formatStringToHtml('###### h6');\n expect(h6Result.html).toEqual('<h6>h6</h6>');\n expect(h6Result.tables).toEqual([]);\n });\n\n test('should format links correctly', () => {\n const result = formatStringToHtml('[Link](https://example.com)');\n expect(result.html).toEqual('<p><a href=\"https://example.com\">Link</a></p>');\n expect(result.tables).toEqual([]);\n });\n\n test('should format images correctly', () => {\n const result = formatStringToHtml('');\n expect(result.html).toEqual(\n '<p><img src=\"https://example.com/image.jpg\" alt=\"Alt Text\"></p>',\n );\n expect(result.tables).toEqual([]);\n });\n\n test('should format lists correctly', () => {\n const expectedUnorderedListResult =\n '<ul>\\n<li>Item 1</li>\\n<li>Item 2</li>\\n<li>Item 3</li>\\n</ul>';\n const expectedOrderedListResult =\n '<ol>\\n<li>Item 1</li>\\n<li>Item 2</li>\\n<li>Item 3</li>\\n</ol>';\n\n const unorderedListResult1 = formatStringToHtml('- Item 1\\n- Item 2\\n- Item 3');\n expect(unorderedListResult1.html).toEqual(expectedUnorderedListResult);\n expect(unorderedListResult1.tables).toEqual([]);\n\n const unorderedListResult2 = formatStringToHtml('* Item 1\\n* Item 2\\n* Item 3');\n expect(unorderedListResult2.html).toEqual(expectedUnorderedListResult);\n expect(unorderedListResult2.tables).toEqual([]);\n\n const orderedListResult = formatStringToHtml('1. Item 1\\n2. Item 2\\n3. Item 3');\n expect(orderedListResult.html).toEqual(expectedOrderedListResult);\n expect(orderedListResult.tables).toEqual([]);\n\n const orderedListResult2 = formatStringToHtml('1) Item 1\\n2) Item 2\\n3) Item 3');\n expect(orderedListResult2.html).toEqual(expectedOrderedListResult);\n expect(orderedListResult2.tables).toEqual([]);\n });\n\n test('should format thematic breaks correctly', () => {\n const expectedThematicBreakResult = '<hr>';\n\n const result1 = formatStringToHtml('---');\n expect(result1.html).toEqual(expectedThematicBreakResult);\n expect(result1.tables).toEqual([]);\n\n const result2 = formatStringToHtml('***');\n expect(result2.html).toEqual(expectedThematicBreakResult);\n expect(result2.tables).toEqual([]);\n });\n\n test('should format code blocks correctly', () => {\n const resultWithoutLanguage = formatStringToHtml('```\\nconst a = 1;\\n```');\n expect(resultWithoutLanguage.html).toEqual('<pre><code>const a = 1;</code></pre>');\n expect(resultWithoutLanguage.tables).toEqual([]);\n\n const resultWithLanguage = formatStringToHtml('```js\\nconst a = 1;\\n```');\n expect(resultWithLanguage.html).toEqual(\n '<pre><code class=\"language-js\">const a = 1;</code></pre>',\n );\n expect(resultWithLanguage.tables).toEqual([]);\n });\n\n test('should format tables correctly', () => {\n const inputString =\n '| Header 1 | Header 2 |\\n|----------|----------|\\n| Cell 1 | Cell 2 |';\n const result = formatStringToHtml(inputString);\n expect(removeLinebreaks(result.html)).toEqual(\n '<table id=\"formatted-table-0\"><thead><tr><th>Header 1</th><th>Header 2</th></tr></thead><tbody><tr><td>Cell 1</td><td>Cell 2</td></tr></tbody></table>',\n );\n expect(result.tables).toEqual([\n {\n csv: 'Header 1,Header 2\\nCell 1,Cell 2\\n',\n raw: inputString,\n id: 'formatted-table-0',\n },\n ]);\n });\n });\n\n describe('Inline Code', () => {\n describe('HTML In Code', () => {\n test('should escape < and > within inline code correctly', () => {\n const result1 = formatStringToHtml('`<div>Test</div>`');\n expect(result1.html).toEqual('<p><code><div>Test</div></code></p>');\n expect(result1.tables).toEqual([]);\n });\n\n test('should not escape & within inline code', () => {\n const resultEscape1 = formatStringToHtml('`<div>Test</div>`');\n expect(resultEscape1.html).toEqual(\n '<p><code><div>Test</div></code></p>',\n );\n expect(resultEscape1.tables).toEqual([]);\n\n const resultEscape2 = formatStringToHtml(\n '`&lt;div&gt;Test&lt;/div&gt;`',\n );\n expect(resultEscape2.html).toEqual(\n '<p><code>&lt;div&gt;Test&lt;/div&gt;</code></p>',\n );\n expect(resultEscape2.tables).toEqual([]);\n });\n });\n\n test('should not format markdown within inline code', () => {\n const result = formatStringToHtml('`**bold** *italic*`');\n expect(result.html).toEqual('<p><code>**bold** *italic*</code></p>');\n expect(result.tables).toEqual([]);\n });\n\n test('should not format bb-code within inline code', () => {\n const result = formatStringToHtml('`[b]bold[/b]`', { parseBBCode: true });\n expect(result.html).toEqual('<p><code>[b]bold[/b]</code></p>');\n expect(result.tables).toEqual([]);\n });\n });\n\n describe('Codeblock', () => {\n test('should format code blocks with multiple lines correctly', () => {\n const resultWithoutLanguage = formatStringToHtml(\n '```\\nconst a = 1;\\nconst b = 2;\\n```',\n );\n expect(resultWithoutLanguage.html).toEqual(\n '<pre><code>const a = 1;\\nconst b = 2;</code></pre>',\n );\n expect(resultWithoutLanguage.tables).toEqual([]);\n\n const resultWithLanguage = formatStringToHtml(\n '```js\\nconst a = 1;\\nconst b = 2;\\n```',\n );\n expect(resultWithLanguage.html).toEqual(\n '<pre><code class=\"language-js\">const a = 1;\\nconst b = 2;</code></pre>',\n );\n expect(resultWithLanguage.tables).toEqual([]);\n });\n\n describe('HTML In Code', () => {\n test('should escape < and > within code block', () => {\n const resultWithoutLanguage = formatStringToHtml('```\\n<div>Test</div>\\n```');\n expect(resultWithoutLanguage.html).toEqual(\n '<pre><code><div>Test</div></code></pre>',\n );\n expect(resultWithoutLanguage.tables).toEqual([]);\n\n const resultWithLanguage = formatStringToHtml('```html\\n<div>Test</div>\\n```');\n expect(resultWithLanguage.html).toEqual(\n '<pre><code class=\"language-html\"><div>Test</div></code></pre>',\n );\n expect(resultWithLanguage.tables).toEqual([]);\n });\n\n test('should not escape & within code block', () => {\n const resultEscape1 = formatStringToHtml(\n '```\\n<div>Test</div>\\n```',\n );\n expect(resultEscape1.html).toEqual(\n '<pre><code><div>Test</div></code></pre>',\n );\n expect(resultEscape1.tables).toEqual([]);\n\n const resultEscape2 = formatStringToHtml(\n '```\\n&lt;div&gt;Test&lt;/div&gt;\\n```',\n );\n expect(resultEscape2.html).toEqual(\n '<pre><code>&lt;div&gt;Test&lt;/div&gt;</code></pre>',\n );\n expect(resultEscape2.tables).toEqual([]);\n });\n });\n\n test('should not format markdown within code block', () => {\n const resultWithoutLanguage = formatStringToHtml('```\\n**Test**\\n```');\n expect(resultWithoutLanguage.html).toEqual('<pre><code>**Test**</code></pre>');\n expect(resultWithoutLanguage.tables).toEqual([]);\n\n const resultWithLanguage = formatStringToHtml('```html\\n**Test**\\n```');\n expect(resultWithLanguage.html).toEqual(\n '<pre><code class=\"language-html\">**Test**</code></pre>',\n );\n expect(resultWithLanguage.tables).toEqual([]);\n });\n\n test('should not format bb-code within code block', () => {\n const resultWithoutLanguage = formatStringToHtml('```\\n[b]Test[/b]\\n```');\n expect(resultWithoutLanguage.html).toEqual('<pre><code>[b]Test[/b]</code></pre>');\n expect(resultWithoutLanguage.tables).toEqual([]);\n\n const resultWithLanguage = formatStringToHtml('```html\\n[b]Test[/b]\\n```');\n expect(resultWithLanguage.html).toEqual(\n '<pre><code class=\"language-html\">[b]Test[/b]</code></pre>',\n );\n expect(resultWithLanguage.tables).toEqual([]);\n });\n });\n\n describe('Table', () => {\n test('should format markdown within table correctly', () => {\n const inputString =\n '| Header 1 | Header 2 |\\n|----------|----------|\\n| **Cell 1** | *Cell 2* |';\n const result = formatStringToHtml(inputString);\n expect(removeLinebreaks(result.html)).toEqual(\n '<table id=\"formatted-table-0\"><thead><tr><th>Header 1</th><th>Header 2</th></tr></thead><tbody><tr><td><strong>Cell 1</strong></td><td><em>Cell 2</em></td></tr></tbody></table>',\n );\n expect(result.tables).toEqual([\n {\n csv: 'Header 1,Header 2\\n**Cell 1**,*Cell 2*\\n',\n raw: inputString,\n id: 'formatted-table-0',\n },\n ]);\n });\n\n test('should format bb-code within table correctly', () => {\n const inputString =\n '| Header 1 | Header 2 |\\n|----------|----------|\\n| [b]Cell 1[/b] | [i]Cell 2[/i] |';\n const result = formatStringToHtml(inputString, {\n parseBBCode: true,\n });\n expect(removeLinebreaks(result.html)).toEqual(\n '<table id=\"formatted-table-0\"><thead><tr><th>Header 1</th><th>Header 2</th></tr></thead><tbody><tr><td><b>Cell 1</b></td><td><i>Cell 2</i></td></tr></tbody></table>',\n );\n expect(result.tables).toEqual([\n {\n csv: 'Header 1,Header 2\\n[b]Cell 1[/b],[i]Cell 2[/i]\\n',\n raw: inputString,\n id: 'formatted-table-0',\n },\n ]);\n });\n\n test('should format html within table correctly', () => {\n const inputString =\n '| Header 1 | Header 2 | Header 3 |\\n|----------|----------|----------|\\n| <div>Cell 1</div> | <div>Cell 2</div> | &lt;div&gt;Cell 3&lt;/div&gt; |';\n const result = formatStringToHtml(inputString, {\n parseBBCode: true,\n });\n expect(removeLinebreaks(result.html)).toEqual(\n '<table id=\"formatted-table-0\"><thead><tr><th>Header 1</th><th>Header 2</th><th>Header 3</th></tr></thead><tbody><tr><td><div>Cell 1</div></td><td><div>Cell 2</div></td><td>&lt;div&gt;Cell 3&lt;/div&gt;</td></tr></tbody></table>',\n );\n expect(result.tables).toEqual([\n {\n csv: 'Header 1,Header 2,Header 3\\n<div>Cell 1</div>,<div>Cell 2</div>,<div>Cell 3</div>\\n',\n raw: '| Header 1 | Header 2 | Header 3 |\\n|----------|----------|----------|\\n| <div>Cell 1</div> | <div>Cell 2</div> | <div>Cell 3</div> |',\n id: 'formatted-table-0',\n },\n ]);\n });\n\n test('should format multiple tables correctly', () => {\n const table1 =\n '| Header 1 | Header 2 |\\n|----------|----------|\\n| Cell 1 | Cell 2 |';\n const getTable1Result = (index: number) =>\n `<table id=\"formatted-table-${index}\"><thead><tr><th>Header 1</th><th>Header 2</th></tr></thead><tbody><tr><td>Cell 1</td><td>Cell 2</td></tr></tbody></table>`;\n const table1Csv = 'Header 1,Header 2\\nCell 1,Cell 2\\n';\n const table2 =\n '| Header 3 | Header 4 |\\n|----------|----------|\\n| Cell 3 | Cell 4 |';\n const getTable2TResult = (index: number) =>\n `<table id=\"formatted-table-${index}\"><thead><tr><th>Header 3</th><th>Header 4</th></tr></thead><tbody><tr><td>Cell 3</td><td>Cell 4</td></tr></tbody></table>`;\n const table2Csv = 'Header 3,Header 4\\nCell 3,Cell 4\\n';\n\n const result1 = formatStringToHtml(`${table1}\\n\\n${table2}`);\n expect(removeLinebreaks(result1.html)).toEqual(\n `${getTable1Result(0)}${getTable2TResult(1)}`,\n );\n expect(result1.tables).toEqual([\n {\n csv: table1Csv,\n raw: `${table1}\\n\\n`,\n id: 'formatted-table-0',\n },\n {\n csv: table2Csv,\n raw: table2,\n id: 'formatted-table-1',\n },\n ]);\n\n // Tables in reverse order.\n const result2 = formatStringToHtml(`${table2}\\n\\n${table1}`);\n expect(removeLinebreaks(result2.html)).toEqual(\n `${getTable2TResult(0)}${getTable1Result(1)}`,\n );\n expect(result2.tables).toEqual([\n {\n csv: table2Csv,\n raw: `${table2}\\n\\n`,\n id: 'formatted-table-0',\n },\n {\n csv: table1Csv,\n raw: table1,\n id: 'formatted-table-1',\n },\n ]);\n });\n });\n\n describe('List', () => {\n test('should format markdown within list correctly', () => {\n const result = formatStringToHtml('- **Item 1**\\n- *Item 2*');\n expect(removeLinebreaks(result.html)).toEqual(\n '<ul><li><strong>Item 1</strong></li><li><em>Item 2</em></li></ul>',\n );\n expect(result.tables).toEqual([]);\n });\n\n test('should format task lists correctly', () => {\n const result1 = formatStringToHtml('- [ ] 1\\n- [x] 2\\n- [X] 3');\n expect(removeLinebreaks(result1.html)).toEqual(\n '<ul><li>[ ] 1</li><li>[x] 2</li><li>[x] 3</li></ul>',\n );\n expect(result1.tables).toEqual([]);\n });\n });\n\n describe('Combined Elements', () => {\n test('should format code block within list correctly', () => {\n const result = formatStringToHtml('* test\\n ```\\n test\\n ```');\n expect(removeLinebreaks(result.html)).toEqual(\n '<ul><li>test<pre><code>test</code></pre></li></ul>',\n );\n expect(result.tables).toEqual([]);\n });\n });\n\n describe('Conflicts with BB-Code', () => {\n test('should not format bb code tag followed by paranthese to link', () => {\n const result = formatStringToHtml('[b]bold[/b](test)', { parseBBCode: true });\n expect(result.html).toEqual('<p><b>bold</b>(test)</p>');\n expect(result.tables).toEqual([]);\n });\n });\n });\n\n describe('Format BB-Code', () => {\n describe('All Elements', () => {\n describe('Inline Elements', () => {\n // b, strong, i, em, u, s, span, img\n test('should format b tag correctly', () => {\n const result = formatStringToHtml('[b]bold[/b]', {\n parseBBCode: true,\n });\n expect(result.html).toEqual('<p><b>bold</b></p>');\n expect(result.tables).toEqual([]);\n });\n\n test('should format strong tag correctly', () => {\n const result = formatStringToHtml('[strong]bold[/strong]', {\n parseBBCode: true,\n });\n expect(result.html).toEqual('<p><strong>bold</strong></p>');\n expect(result.tables).toEqual([]);\n });\n\n test('should format i tag correctly', () => {\n const result = formatStringToHtml('[i]italic[/i]', {\n parseBBCode: true,\n });\n expect(result.html).toEqual('<p><i>italic</i></p>');\n expect(result.tables).toEqual([]);\n });\n\n test('should format em tag correctly', () => {\n const result = formatStringToHtml('[em]italic[/em]', {\n parseBBCode: true,\n });\n expect(result.html).toEqual('<p><em>italic</em></p>');\n expect(result.tables).toEqual([]);\n });\n\n test('should format u tag correctly', () => {\n const result = formatStringToHtml('[u]underline[/u]', {\n parseBBCode: true,\n });\n expect(result.html).toEqual('<p><u>underline</u></p>');\n expect(result.tables).toEqual([]);\n });\n\n test('should format s tag correctly', () => {\n const result = formatStringToHtml('[s]strike[/s]', {\n parseBBCode: true,\n });\n expect(result.html).toEqual('<p><s>strike</s></p>');\n expect(result.tables).toEqual([]);\n });\n\n test('should format span tag correctly', () => {\n const result = formatStringToHtml('[span]span[/span]', {\n parseBBCode: true,\n });\n expect(result.html).toEqual('<p><span>span</span></p>');\n expect(result.tables).toEqual([]);\n });\n\n test('should format img tag correctly', () => {\n const result = formatStringToHtml(\n '[img src=\"https://example.com/image.jpg\"][/img]',\n {\n parseBBCode: true,\n },\n );\n expect(result.html).toEqual('<p><img src=\"https://example.com/image.jpg\"></p>');\n expect(result.tables).toEqual([]);\n });\n });\n\n describe('Block Level Elements', () => {\n test('should format center tag correctly', () => {\n const result = formatStringToHtml('[center]centered text[/center]', {\n parseBBCode: true,\n });\n expect(result.html).toEqual('<p><center>centered text</center></p>');\n expect(result.tables).toEqual([]);\n });\n\n test('should format ul tag correctly', () => {\n const result = formatStringToHtml('[ul][li]Item 1[/li][li]Item 2[/li][/ul]', {\n parseBBCode: true,\n });\n expect(result.html).toEqual('<p><ul><li>Item 1</li><li>Item 2</li></ul></p>');\n expect(result.tables).toEqual([]);\n });\n\n test('should format ol tag correctly', () => {\n const result = formatStringToHtml('[ol][li]Item 1[/li][li]Item 2[/li][/ol]', {\n parseBBCode: true,\n });\n expect(result.html).toEqual('<p><ol><li>Item 1</li><li>Item 2</li></ol></p>');\n expect(result.tables).toEqual([]);\n });\n\n test('should format li tag correctly', () => {\n const result = formatStringToHtml('[li]Item[/li]', {\n parseBBCode: true,\n });\n expect(result.html).toEqual('<p><li>Item</li></p>');\n expect(result.tables).toEqual([]);\n });\n\n test('should format heading tags correctly', () => {\n const getHeadingInput = (tag: string) => `[${tag}]${tag}[/${tag}]`;\n const getHeadingOutput = (tag: string) => `<p><${tag}>${tag}</${tag}></p>`;\n const headingTags = ['h1', 'h2', 'h3', 'h4', 'h5', 'h6'];\n\n headingTags.forEach((tag) => {\n const result = formatStringToHtml(getHeadingInput(tag), {\n parseBBCode: true,\n });\n expect(result.html).toEqual(getHeadingOutput(tag));\n expect(result.tables).toEqual([]);\n });\n });\n\n test('should format p tag correctly', () => {\n const result = formatStringToHtml('[p]paragraph[/p]', {\n parseBBCode: true,\n });\n expect(result.html).toEqual('<p><p>paragraph</p></p>');\n expect(result.tables).toEqual([]);\n });\n });\n\n describe('Custom Elements', () => {\n test('should format custom tags correctly', () => {\n const input = '[custom attribute1=\"test1\" attribute2=\"test2\"]custom[/custom]';\n const output =\n '<p><bb-code-custom attribute1=\"test1\" attribute2=\"test2\">custom</bb-code-custom></p>';\n const result1 = formatStringToHtml(input, {\n parseBBCode: true,\n customInlineLevelBBCodeTags: ['custom'],\n });\n expect(result1.html).toEqual(output);\n expect(result1.tables).toEqual([]);\n\n const result2 = formatStringToHtml(input, {\n parseBBCode: true,\n customBlockLevelBBCodeTags: ['custom'],\n });\n expect(result2.html).toEqual(output);\n expect(result2.tables).toEqual([]);\n });\n\n test('should not format unknown custom tags', () => {\n const result = formatStringToHtml('[unknown]unknown[/unknown]', {\n parseBBCode: true,\n });\n expect(result.html).toEqual('<p>[unknown]unknown[/unknown]</p>');\n expect(result.tables).toEqual([]);\n });\n });\n\n describe('Line breaks', () => {\n describe('Between Elements', () => {\n test('should format line breaks between block level elements correctly', () => {\n const result1 = formatStringToHtml('[h1]h1[/h1]\\n[h2]h2[/h2]', {\n parseBBCode: true,\n });\n expect(result1.html).toEqual('<p><h1>h1</h1><h2>h2</h2></p>');\n expect(result1.tables).toEqual([]);\n\n const result2 = formatStringToHtml('[h1]h1[/h1]\\n\\n[h2]h2[/h2]', {\n parseBBCode: true,\n });\n expect(result2.html).toEqual('<p><h1>h1</h1></p>\\n<p><h2>h2</h2></p>');\n expect(result2.tables).toEqual([]);\n });\n\n test('should format line breaks between inline elements correctly', () => {\n const result1 = formatStringToHtml('[b]bold[/b]\\n[i]italic[/i]', {\n parseBBCode: true,\n });\n expect(result1.html).toEqual('<p><b>bold</b>\\n<i>italic</i></p>');\n expect(result1.tables).toEqual([]);\n\n const result2 = formatStringToHtml('[b]bold[/b]\\n\\n[i]italic[/i]', {\n parseBBCode: true,\n });\n expect(result2.html).toEqual('<p><b>bold</b></p>\\n<p><i>italic</i></p>');\n expect(result2.tables).toEqual([]);\n });\n });\n\n describe('Within Elements', () => {\n test('should format line breaks within block level elements correctly', () => {\n const result = formatStringToHtml('[h1]Line 1\\nLine 2[/h1]', {\n parseBBCode: true,\n });\n expect(result.html).toEqual('<p><h1>Line 1\\nLine 2</h1></p>');\n expect(result.tables).toEqual([]);\n });\n\n // This is a test that would fail!\n // test('should format multiple line breaks within block level elements correctly', () => {\n // const result = formatStringToHtml('[h1]Line 1\\n\\nLine 2[/h1]', {\n // parseBBCode: true,\n // });\n // expect(result.html).toEqual('<p><h1>Line 1\\nLine 2</h1></p>');\n // expect(result.tables).toEqual([]);\n // });\n\n test('should remove trailing and leading new lines within block level elements', () => {\n const result = formatStringToHtml('[h1]\\n\\n\\nLine 1\\n\\n\\n[/h1]', {\n parseBBCode: true,\n });\n expect(result.html).toEqual('<p><h1>Line 1</h1></p>');\n expect(result.tables).toEqual([]);\n });\n });\n });\n\n test('should not format url in tag attributes', () => {\n const result = formatStringToHtml(\n '[link url=\"https://www.google.com\"]Google[/link]',\n {\n parseBBCode: true,\n customInlineLevelBBCodeTags: ['link'],\n },\n );\n expect(result.html).toEqual(\n '<p><bb-code-link url=\"https://www.google.com\">Google</bb-code-link></p>',\n );\n expect(result.tables).toEqual([]);\n });\n\n test('should apply style attribute correctly', () => {\n const result = formatStringToHtml('[span style=\"color: red;\"]red text[/span]', {\n parseBBCode: true,\n });\n expect(result.html).toEqual('<p><span style=\"color: red;\">red text</span></p>');\n expect(result.tables).toEqual([]);\n });\n\n test('should format nested elements correctly', () => {\n const result = formatStringToHtml('[b][i]bold italic[/i][/b]', {\n parseBBCode: true,\n });\n expect(result.html).toEqual('<p><b><i>bold italic</i></b></p>');\n expect(result.tables).toEqual([]);\n });\n });\n });\n\n describe('Combined Formatting (Markdown + BB-Code)', () => {\n test('should format bb-code within markdown correctly', () => {\n const result = formatStringToHtml('*[b]bold[/b]*', {\n parseBBCode: true,\n });\n expect(result.html).toEqual('<p><em><b>bold</b></em></p>');\n expect(result.tables).toEqual([]);\n });\n\n test('should format markdown within bb-code correctly', () => {\n const result = formatStringToHtml('[b]*bold*[/b]', {\n parseBBCode: true,\n });\n expect(result.html).toEqual('<p><b><em>bold</em></b></p>');\n expect(result.tables).toEqual([]);\n });\n });\n});\n"],"mappings":";;AAAA,IAAAA,OAAA,GAAAC,OAAA;AACA,IAAAC,aAAA,GAAAD,OAAA;AAEA,MAAME,gBAAgB,GAAIC,IAAY,IAAKA,IAAI,CAACC,OAAO,CAAC,KAAK,EAAE,EAAE,CAAC;AAElE,IAAAC,gBAAQ,EAAC,yBAAyB,EAAE,MAAM;EACtC,IAAAA,gBAAQ,EAAC,mBAAmB,EAAE,MAAM;IAChC,IAAAA,gBAAQ,EAAC,aAAa,EAAE,MAAM;MAC1B,IAAAC,YAAI,EAAC,qCAAqC,EAAE,MAAM;QAC9C,MAAMC,MAAM,GAAG,IAAAC,gCAAkB,EAAC,gBAAgB,CAAC;QACnD,IAAAC,cAAM,EAACF,MAAM,CAACG,IAAI,CAAC,CAACC,OAAO,CAAC,uBAAuB,CAAC;QACpD,IAAAF,cAAM,EAACF,MAAM,CAACK,MAAM,CAAC,CAACD,OAAO,CAAC,EAAE,CAAC;MACrC,CAAC,CAAC;MAEF,IAAAL,YAAI,EAAC,8CAA8C,EAAE,MAAM;QACvD,MAAMC,MAAM,GAAG,IAAAC,gCAAkB,EAAC,kBAAkB,CAAC;QACrD,IAAAC,cAAM,EAACF,MAAM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AC,CAAC;EAEF,IAAAN,gBAAQ,EAAC,0CAA0C,EAAE,MAAM;IACvD,IAAAC,YAAI,EAAC,iDAAiD,EAAE,MAAM;MAC1D,MAAMC,MAAM,GAAG,IAAAC,gCAAkB,EAAC,eAAe,EAAE;QAC/CgC,WAAW,EAAE;MACjB,CAAC,CAAC;MACF,IAAA/B,cAAM,EAACF,MAAM,CAACG,IAAI,CAAC,CAACC,OAAO,CAAC,6BAA6B,CAAC;MAC1D,IAAAF,cAAM,EAACF,MAAM,CAACK,MAAM,CAAC,CAACD,OAAO,CAAC,EAAE,CAAC;IACrC,CAAC,CAAC;IAEF,IAAAL,YAAI,EAAC,iDAAiD,EAAE,MAAM;MAC1D,MAAMC,MAAM,GAAG,IAAAC,gCAAkB,EAAC,eAAe,EAAE;QAC/CgC,WAAW,EAAE;MACjB,CAAC,CAAC;MACF,IAAA/B,cAAM,EAACF,MAAM,CAACG,IAAI,CAAC,CAACC,OAAO,CAAC,6BAA6B,CAAC;MAC1D,IAAAF,cAAM,EAACF,MAAM,CAACK,MAAM,CAAC,CAACD,OAAO,CAAC,EAAE,CAAC;IACrC,CAAC,CAAC;EACN,CAAC,CAAC;AACN,CAAC,CAAC","ignoreList":[]}
|
|
1
|
+
{"version":3,"file":"formatString.test.js","names":["_vitest","require","_formatString","removeLinebreaks","text","replace","describe","test","result","formatStringToHtml","expect","html","toEqual","tables","resultEscape","resultEscape1","resultEscape2","boldResult","italicResult","inlineCodeResult","h1Result","h2Result","h3Result","h4Result","h5Result","h6Result","expectedUnorderedListResult","expectedOrderedListResult","unorderedListResult1","unorderedListResult2","orderedListResult","orderedListResult2","expectedThematicBreakResult","result1","result2","resultWithoutLanguage","resultWithLanguage","inputString","csv","raw","id","parseBBCode","table1","getTable1Result","index","table1Csv","table2","getTable2TResult","table2Csv","getHeadingInput","tag","getHeadingOutput","headingTags","forEach","input","output","customInlineLevelBBCodeTags","customBlockLevelBBCodeTags"],"sources":["../../../../src/utils/formatString/formatString.test.ts"],"sourcesContent":["import { describe, expect, test } from 'vitest';\nimport { formatStringToHtml } from './formatString';\n\nconst removeLinebreaks = (text: string) => text.replace(/\\n/g, '');\n\ndescribe('HTML Formatter Function', () => {\n describe('Format Plain Text', () => {\n describe('Line breaks', () => {\n test('should format line breaks correctly', () => {\n const result = formatStringToHtml('Line 1\\nLine 2');\n expect(result.html).toEqual('<p>Line 1\\nLine 2</p>');\n expect(result.tables).toEqual([]);\n });\n\n test('should format multiple line breaks correctly', () => {\n const result = formatStringToHtml('Line 1\\n\\nLine 2');\n expect(result.html).toEqual('<p>Line 1</p>\\n<p>Line 2</p>');\n expect(result.tables).toEqual([]);\n });\n\n test('should remove trailing and leading new lines', () => {\n const result = formatStringToHtml('\\n\\n\\nLine 1\\n\\n\\n');\n expect(result.html).toEqual('<p>Line 1</p>');\n expect(result.tables).toEqual([]);\n });\n });\n\n describe('Whitespaces', () => {\n test('should not remove repeated whitespaces', () => {\n const result = formatStringToHtml('Text with spaces');\n expect(result.html).toEqual('<p>Text with spaces</p>');\n expect(result.tables).toEqual([]);\n });\n\n test('should not remove leading and trailing whitespaces', () => {\n const result = formatStringToHtml(' Text ');\n expect(result.html).toEqual('<p> Text </p>');\n expect(result.tables).toEqual([]);\n });\n });\n\n describe('HTML', () => {\n test('should escape < and > correctly', () => {\n const resultEscape = formatStringToHtml('<div>Test</div>');\n expect(resultEscape.html).toEqual('<p><div>Test</div></p>');\n expect(resultEscape.tables).toEqual([]);\n });\n\n test('should not escape &', () => {\n const resultEscape1 = formatStringToHtml('<div>Test</div>');\n expect(resultEscape1.html).toEqual('<p><div>Test</div></p>');\n expect(resultEscape1.tables).toEqual([]);\n\n const resultEscape2 = formatStringToHtml(\n '&lt;div&gt;Test&lt;/div&gt;',\n );\n expect(resultEscape2.html).toEqual(\n '<p>&lt;div&gt;Test&lt;/div&gt;</p>',\n );\n expect(resultEscape2.tables).toEqual([]);\n });\n\n // TODO Decide if & should be escaped, when they are not part of an HTML entity.\n });\n\n describe('URLs', () => {\n test('should not format URLs', () => {\n const result = formatStringToHtml('https://example.com');\n expect(result.html).toEqual('<p>https://example.com</p>');\n expect(result.tables).toEqual([]);\n });\n });\n });\n\n describe('Format Markdown', () => {\n describe('All Elements', () => {\n test('should format text styling correctly', () => {\n const boldResult = formatStringToHtml('**bold**');\n expect(boldResult.html).toEqual('<p><strong>bold</strong></p>');\n expect(boldResult.tables).toEqual([]);\n\n const italicResult = formatStringToHtml('*italic*');\n expect(italicResult.html).toEqual('<p><em>italic</em></p>');\n expect(italicResult.tables).toEqual([]);\n\n const inlineCodeResult = formatStringToHtml('`inline code`');\n expect(inlineCodeResult.html).toEqual('<p><code>inline code</code></p>');\n expect(inlineCodeResult.tables).toEqual([]);\n });\n\n test('should format headings correctly', () => {\n const h1Result = formatStringToHtml('# h1');\n expect(h1Result.html).toEqual('<h1>h1</h1>');\n expect(h1Result.tables).toEqual([]);\n\n const h2Result = formatStringToHtml('## h2');\n expect(h2Result.html).toEqual('<h2>h2</h2>');\n expect(h2Result.tables).toEqual([]);\n\n const h3Result = formatStringToHtml('### h3');\n expect(h3Result.html).toEqual('<h3>h3</h3>');\n expect(h3Result.tables).toEqual([]);\n\n const h4Result = formatStringToHtml('#### h4');\n expect(h4Result.html).toEqual('<h4>h4</h4>');\n expect(h4Result.tables).toEqual([]);\n\n const h5Result = formatStringToHtml('##### h5');\n expect(h5Result.html).toEqual('<h5>h5</h5>');\n expect(h5Result.tables).toEqual([]);\n\n const h6Result = formatStringToHtml('###### h6');\n expect(h6Result.html).toEqual('<h6>h6</h6>');\n expect(h6Result.tables).toEqual([]);\n });\n\n test('should format links correctly', () => {\n const result = formatStringToHtml('[Link](https://example.com)');\n expect(result.html).toEqual('<p><a href=\"https://example.com\">Link</a></p>');\n expect(result.tables).toEqual([]);\n });\n\n test('should format images correctly', () => {\n const result = formatStringToHtml('');\n expect(result.html).toEqual(\n '<p><img src=\"https://example.com/image.jpg\" alt=\"Alt Text\"></p>',\n );\n expect(result.tables).toEqual([]);\n });\n\n test('should format lists correctly', () => {\n const expectedUnorderedListResult =\n '<ul>\\n<li>Item 1</li>\\n<li>Item 2</li>\\n<li>Item 3</li>\\n</ul>';\n const expectedOrderedListResult =\n '<ol>\\n<li>Item 1</li>\\n<li>Item 2</li>\\n<li>Item 3</li>\\n</ol>';\n\n const unorderedListResult1 = formatStringToHtml('- Item 1\\n- Item 2\\n- Item 3');\n expect(unorderedListResult1.html).toEqual(expectedUnorderedListResult);\n expect(unorderedListResult1.tables).toEqual([]);\n\n const unorderedListResult2 = formatStringToHtml('* Item 1\\n* Item 2\\n* Item 3');\n expect(unorderedListResult2.html).toEqual(expectedUnorderedListResult);\n expect(unorderedListResult2.tables).toEqual([]);\n\n const orderedListResult = formatStringToHtml('1. Item 1\\n2. Item 2\\n3. Item 3');\n expect(orderedListResult.html).toEqual(expectedOrderedListResult);\n expect(orderedListResult.tables).toEqual([]);\n\n const orderedListResult2 = formatStringToHtml('1) Item 1\\n2) Item 2\\n3) Item 3');\n expect(orderedListResult2.html).toEqual(expectedOrderedListResult);\n expect(orderedListResult2.tables).toEqual([]);\n });\n\n test('should format thematic breaks correctly', () => {\n const expectedThematicBreakResult = '<hr>';\n\n const result1 = formatStringToHtml('---');\n expect(result1.html).toEqual(expectedThematicBreakResult);\n expect(result1.tables).toEqual([]);\n\n const result2 = formatStringToHtml('***');\n expect(result2.html).toEqual(expectedThematicBreakResult);\n expect(result2.tables).toEqual([]);\n });\n\n test('should format code blocks correctly', () => {\n const resultWithoutLanguage = formatStringToHtml('```\\nconst a = 1;\\n```');\n expect(resultWithoutLanguage.html).toEqual('<pre><code>const a = 1;</code></pre>');\n expect(resultWithoutLanguage.tables).toEqual([]);\n\n const resultWithLanguage = formatStringToHtml('```js\\nconst a = 1;\\n```');\n expect(resultWithLanguage.html).toEqual(\n '<pre><code class=\"language-js\">const a = 1;</code></pre>',\n );\n expect(resultWithLanguage.tables).toEqual([]);\n });\n\n test('should format tables correctly', () => {\n const inputString =\n '| Header 1 | Header 2 |\\n|----------|----------|\\n| Cell 1 | Cell 2 |';\n const result = formatStringToHtml(inputString);\n expect(removeLinebreaks(result.html)).toEqual(\n '<table id=\"formatted-table-0\"><thead><tr><th>Header 1</th><th>Header 2</th></tr></thead><tbody><tr><td>Cell 1</td><td>Cell 2</td></tr></tbody></table>',\n );\n expect(result.tables).toEqual([\n {\n csv: 'Header 1,Header 2\\nCell 1,Cell 2\\n',\n raw: inputString,\n id: 'formatted-table-0',\n },\n ]);\n });\n });\n\n describe('Inline Code', () => {\n describe('HTML In Code', () => {\n test('should escape < and > within inline code correctly', () => {\n const result1 = formatStringToHtml('`<div>Test</div>`');\n expect(result1.html).toEqual('<p><code><div>Test</div></code></p>');\n expect(result1.tables).toEqual([]);\n });\n\n test('should not escape & within inline code', () => {\n const resultEscape1 = formatStringToHtml('`<div>Test</div>`');\n expect(resultEscape1.html).toEqual(\n '<p><code><div>Test</div></code></p>',\n );\n expect(resultEscape1.tables).toEqual([]);\n\n const resultEscape2 = formatStringToHtml(\n '`&lt;div&gt;Test&lt;/div&gt;`',\n );\n expect(resultEscape2.html).toEqual(\n '<p><code>&lt;div&gt;Test&lt;/div&gt;</code></p>',\n );\n expect(resultEscape2.tables).toEqual([]);\n });\n });\n\n test('should not format markdown within inline code', () => {\n const result = formatStringToHtml('`**bold** *italic*`');\n expect(result.html).toEqual('<p><code>**bold** *italic*</code></p>');\n expect(result.tables).toEqual([]);\n });\n\n test('should not format bb-code within inline code', () => {\n const result = formatStringToHtml('`[b]bold[/b]`', { parseBBCode: true });\n expect(result.html).toEqual('<p><code>[b]bold[/b]</code></p>');\n expect(result.tables).toEqual([]);\n });\n });\n\n describe('Codeblock', () => {\n test('should format code blocks with multiple lines correctly', () => {\n const resultWithoutLanguage = formatStringToHtml(\n '```\\nconst a = 1;\\nconst b = 2;\\n```',\n );\n expect(resultWithoutLanguage.html).toEqual(\n '<pre><code>const a = 1;\\nconst b = 2;</code></pre>',\n );\n expect(resultWithoutLanguage.tables).toEqual([]);\n\n const resultWithLanguage = formatStringToHtml(\n '```js\\nconst a = 1;\\nconst b = 2;\\n```',\n );\n expect(resultWithLanguage.html).toEqual(\n '<pre><code class=\"language-js\">const a = 1;\\nconst b = 2;</code></pre>',\n );\n expect(resultWithLanguage.tables).toEqual([]);\n });\n\n test('should not format 4 spaces as code block', () => {\n const result = formatStringToHtml(' const a = 1;');\n expect(result.html).toEqual('<p> const a = 1;</p>');\n expect(result.tables).toEqual([]);\n });\n\n describe('HTML In Code', () => {\n test('should escape < and > within code block', () => {\n const resultWithoutLanguage = formatStringToHtml('```\\n<div>Test</div>\\n```');\n expect(resultWithoutLanguage.html).toEqual(\n '<pre><code><div>Test</div></code></pre>',\n );\n expect(resultWithoutLanguage.tables).toEqual([]);\n\n const resultWithLanguage = formatStringToHtml('```html\\n<div>Test</div>\\n```');\n expect(resultWithLanguage.html).toEqual(\n '<pre><code class=\"language-html\"><div>Test</div></code></pre>',\n );\n expect(resultWithLanguage.tables).toEqual([]);\n });\n\n test('should not escape & within code block', () => {\n const resultEscape1 = formatStringToHtml(\n '```\\n<div>Test</div>\\n```',\n );\n expect(resultEscape1.html).toEqual(\n '<pre><code><div>Test</div></code></pre>',\n );\n expect(resultEscape1.tables).toEqual([]);\n\n const resultEscape2 = formatStringToHtml(\n '```\\n&lt;div&gt;Test&lt;/div&gt;\\n```',\n );\n expect(resultEscape2.html).toEqual(\n '<pre><code>&lt;div&gt;Test&lt;/div&gt;</code></pre>',\n );\n expect(resultEscape2.tables).toEqual([]);\n });\n });\n\n test('should not format markdown within code block', () => {\n const resultWithoutLanguage = formatStringToHtml('```\\n**Test**\\n```');\n expect(resultWithoutLanguage.html).toEqual('<pre><code>**Test**</code></pre>');\n expect(resultWithoutLanguage.tables).toEqual([]);\n\n const resultWithLanguage = formatStringToHtml('```html\\n**Test**\\n```');\n expect(resultWithLanguage.html).toEqual(\n '<pre><code class=\"language-html\">**Test**</code></pre>',\n );\n expect(resultWithLanguage.tables).toEqual([]);\n });\n\n test('should not format bb-code within code block', () => {\n const resultWithoutLanguage = formatStringToHtml('```\\n[b]Test[/b]\\n```');\n expect(resultWithoutLanguage.html).toEqual('<pre><code>[b]Test[/b]</code></pre>');\n expect(resultWithoutLanguage.tables).toEqual([]);\n\n const resultWithLanguage = formatStringToHtml('```html\\n[b]Test[/b]\\n```');\n expect(resultWithLanguage.html).toEqual(\n '<pre><code class=\"language-html\">[b]Test[/b]</code></pre>',\n );\n expect(resultWithLanguage.tables).toEqual([]);\n });\n });\n\n describe('Table', () => {\n test('should format markdown within table correctly', () => {\n const inputString =\n '| Header 1 | Header 2 |\\n|----------|----------|\\n| **Cell 1** | *Cell 2* |';\n const result = formatStringToHtml(inputString);\n expect(removeLinebreaks(result.html)).toEqual(\n '<table id=\"formatted-table-0\"><thead><tr><th>Header 1</th><th>Header 2</th></tr></thead><tbody><tr><td><strong>Cell 1</strong></td><td><em>Cell 2</em></td></tr></tbody></table>',\n );\n expect(result.tables).toEqual([\n {\n csv: 'Header 1,Header 2\\n**Cell 1**,*Cell 2*\\n',\n raw: inputString,\n id: 'formatted-table-0',\n },\n ]);\n });\n\n test('should format bb-code within table correctly', () => {\n const inputString =\n '| Header 1 | Header 2 |\\n|----------|----------|\\n| [b]Cell 1[/b] | [i]Cell 2[/i] |';\n const result = formatStringToHtml(inputString, {\n parseBBCode: true,\n });\n expect(removeLinebreaks(result.html)).toEqual(\n '<table id=\"formatted-table-0\"><thead><tr><th>Header 1</th><th>Header 2</th></tr></thead><tbody><tr><td><b>Cell 1</b></td><td><i>Cell 2</i></td></tr></tbody></table>',\n );\n expect(result.tables).toEqual([\n {\n csv: 'Header 1,Header 2\\n[b]Cell 1[/b],[i]Cell 2[/i]\\n',\n raw: inputString,\n id: 'formatted-table-0',\n },\n ]);\n });\n\n test('should format html within table correctly', () => {\n const inputString =\n '| Header 1 | Header 2 | Header 3 |\\n|----------|----------|----------|\\n| <div>Cell 1</div> | <div>Cell 2</div> | &lt;div&gt;Cell 3&lt;/div&gt; |';\n const result = formatStringToHtml(inputString, {\n parseBBCode: true,\n });\n expect(removeLinebreaks(result.html)).toEqual(\n '<table id=\"formatted-table-0\"><thead><tr><th>Header 1</th><th>Header 2</th><th>Header 3</th></tr></thead><tbody><tr><td><div>Cell 1</div></td><td><div>Cell 2</div></td><td>&lt;div&gt;Cell 3&lt;/div&gt;</td></tr></tbody></table>',\n );\n expect(result.tables).toEqual([\n {\n csv: 'Header 1,Header 2,Header 3\\n<div>Cell 1</div>,<div>Cell 2</div>,<div>Cell 3</div>\\n',\n raw: '| Header 1 | Header 2 | Header 3 |\\n|----------|----------|----------|\\n| <div>Cell 1</div> | <div>Cell 2</div> | <div>Cell 3</div> |',\n id: 'formatted-table-0',\n },\n ]);\n });\n\n test('should format multiple tables correctly', () => {\n const table1 =\n '| Header 1 | Header 2 |\\n|----------|----------|\\n| Cell 1 | Cell 2 |';\n const getTable1Result = (index: number) =>\n `<table id=\"formatted-table-${index}\"><thead><tr><th>Header 1</th><th>Header 2</th></tr></thead><tbody><tr><td>Cell 1</td><td>Cell 2</td></tr></tbody></table>`;\n const table1Csv = 'Header 1,Header 2\\nCell 1,Cell 2\\n';\n const table2 =\n '| Header 3 | Header 4 |\\n|----------|----------|\\n| Cell 3 | Cell 4 |';\n const getTable2TResult = (index: number) =>\n `<table id=\"formatted-table-${index}\"><thead><tr><th>Header 3</th><th>Header 4</th></tr></thead><tbody><tr><td>Cell 3</td><td>Cell 4</td></tr></tbody></table>`;\n const table2Csv = 'Header 3,Header 4\\nCell 3,Cell 4\\n';\n\n const result1 = formatStringToHtml(`${table1}\\n\\n${table2}`);\n expect(removeLinebreaks(result1.html)).toEqual(\n `${getTable1Result(0)}${getTable2TResult(1)}`,\n );\n expect(result1.tables).toEqual([\n {\n csv: table1Csv,\n raw: `${table1}\\n\\n`,\n id: 'formatted-table-0',\n },\n {\n csv: table2Csv,\n raw: table2,\n id: 'formatted-table-1',\n },\n ]);\n\n // Tables in reverse order.\n const result2 = formatStringToHtml(`${table2}\\n\\n${table1}`);\n expect(removeLinebreaks(result2.html)).toEqual(\n `${getTable2TResult(0)}${getTable1Result(1)}`,\n );\n expect(result2.tables).toEqual([\n {\n csv: table2Csv,\n raw: `${table2}\\n\\n`,\n id: 'formatted-table-0',\n },\n {\n csv: table1Csv,\n raw: table1,\n id: 'formatted-table-1',\n },\n ]);\n });\n });\n\n describe('List', () => {\n test('should format markdown within list correctly', () => {\n const result = formatStringToHtml('- **Item 1**\\n- *Item 2*');\n expect(removeLinebreaks(result.html)).toEqual(\n '<ul><li><strong>Item 1</strong></li><li><em>Item 2</em></li></ul>',\n );\n expect(result.tables).toEqual([]);\n });\n\n test('should format task lists correctly', () => {\n const result1 = formatStringToHtml('- [ ] 1\\n- [x] 2\\n- [X] 3');\n expect(removeLinebreaks(result1.html)).toEqual(\n '<ul><li>[ ] 1</li><li>[x] 2</li><li>[x] 3</li></ul>',\n );\n expect(result1.tables).toEqual([]);\n });\n });\n\n describe('Combined Elements', () => {\n test('should format code block within list correctly', () => {\n const result = formatStringToHtml('* test\\n ```\\n test\\n ```');\n expect(removeLinebreaks(result.html)).toEqual(\n '<ul><li>test<pre><code>test</code></pre></li></ul>',\n );\n expect(result.tables).toEqual([]);\n });\n });\n\n describe('Conflicts with BB-Code', () => {\n test('should not format bb code tag followed by paranthese to link', () => {\n const result = formatStringToHtml('[b]bold[/b](test)', { parseBBCode: true });\n expect(result.html).toEqual('<p><b>bold</b>(test)</p>');\n expect(result.tables).toEqual([]);\n });\n });\n });\n\n describe('Format BB-Code', () => {\n describe('All Elements', () => {\n describe('Inline Elements', () => {\n // b, strong, i, em, u, s, span, img\n test('should format b tag correctly', () => {\n const result = formatStringToHtml('[b]bold[/b]', {\n parseBBCode: true,\n });\n expect(result.html).toEqual('<p><b>bold</b></p>');\n expect(result.tables).toEqual([]);\n });\n\n test('should format strong tag correctly', () => {\n const result = formatStringToHtml('[strong]bold[/strong]', {\n parseBBCode: true,\n });\n expect(result.html).toEqual('<p><strong>bold</strong></p>');\n expect(result.tables).toEqual([]);\n });\n\n test('should format i tag correctly', () => {\n const result = formatStringToHtml('[i]italic[/i]', {\n parseBBCode: true,\n });\n expect(result.html).toEqual('<p><i>italic</i></p>');\n expect(result.tables).toEqual([]);\n });\n\n test('should format em tag correctly', () => {\n const result = formatStringToHtml('[em]italic[/em]', {\n parseBBCode: true,\n });\n expect(result.html).toEqual('<p><em>italic</em></p>');\n expect(result.tables).toEqual([]);\n });\n\n test('should format u tag correctly', () => {\n const result = formatStringToHtml('[u]underline[/u]', {\n parseBBCode: true,\n });\n expect(result.html).toEqual('<p><u>underline</u></p>');\n expect(result.tables).toEqual([]);\n });\n\n test('should format s tag correctly', () => {\n const result = formatStringToHtml('[s]strike[/s]', {\n parseBBCode: true,\n });\n expect(result.html).toEqual('<p><s>strike</s></p>');\n expect(result.tables).toEqual([]);\n });\n\n test('should format span tag correctly', () => {\n const result = formatStringToHtml('[span]span[/span]', {\n parseBBCode: true,\n });\n expect(result.html).toEqual('<p><span>span</span></p>');\n expect(result.tables).toEqual([]);\n });\n\n test('should format img tag correctly', () => {\n const result = formatStringToHtml(\n '[img src=\"https://example.com/image.jpg\"][/img]',\n {\n parseBBCode: true,\n },\n );\n expect(result.html).toEqual('<p><img src=\"https://example.com/image.jpg\"></p>');\n expect(result.tables).toEqual([]);\n });\n });\n\n describe('Block Level Elements', () => {\n test('should format center tag correctly', () => {\n const result = formatStringToHtml('[center]centered text[/center]', {\n parseBBCode: true,\n });\n expect(result.html).toEqual('<p><center>centered text</center></p>');\n expect(result.tables).toEqual([]);\n });\n\n test('should format ul tag correctly', () => {\n const result = formatStringToHtml('[ul][li]Item 1[/li][li]Item 2[/li][/ul]', {\n parseBBCode: true,\n });\n expect(result.html).toEqual('<p><ul><li>Item 1</li><li>Item 2</li></ul></p>');\n expect(result.tables).toEqual([]);\n });\n\n test('should format ol tag correctly', () => {\n const result = formatStringToHtml('[ol][li]Item 1[/li][li]Item 2[/li][/ol]', {\n parseBBCode: true,\n });\n expect(result.html).toEqual('<p><ol><li>Item 1</li><li>Item 2</li></ol></p>');\n expect(result.tables).toEqual([]);\n });\n\n test('should format li tag correctly', () => {\n const result = formatStringToHtml('[li]Item[/li]', {\n parseBBCode: true,\n });\n expect(result.html).toEqual('<p><li>Item</li></p>');\n expect(result.tables).toEqual([]);\n });\n\n test('should format heading tags correctly', () => {\n const getHeadingInput = (tag: string) => `[${tag}]${tag}[/${tag}]`;\n const getHeadingOutput = (tag: string) => `<p><${tag}>${tag}</${tag}></p>`;\n const headingTags = ['h1', 'h2', 'h3', 'h4', 'h5', 'h6'];\n\n headingTags.forEach((tag) => {\n const result = formatStringToHtml(getHeadingInput(tag), {\n parseBBCode: true,\n });\n expect(result.html).toEqual(getHeadingOutput(tag));\n expect(result.tables).toEqual([]);\n });\n });\n\n test('should format p tag correctly', () => {\n const result = formatStringToHtml('[p]paragraph[/p]', {\n parseBBCode: true,\n });\n expect(result.html).toEqual('<p><p>paragraph</p></p>');\n expect(result.tables).toEqual([]);\n });\n });\n\n describe('Custom Elements', () => {\n test('should format custom tags correctly', () => {\n const input = '[custom attribute1=\"test1\" attribute2=\"test2\"]custom[/custom]';\n const output =\n '<p><bb-code-custom attribute1=\"test1\" attribute2=\"test2\">custom</bb-code-custom></p>';\n const result1 = formatStringToHtml(input, {\n parseBBCode: true,\n customInlineLevelBBCodeTags: ['custom'],\n });\n expect(result1.html).toEqual(output);\n expect(result1.tables).toEqual([]);\n\n const result2 = formatStringToHtml(input, {\n parseBBCode: true,\n customBlockLevelBBCodeTags: ['custom'],\n });\n expect(result2.html).toEqual(output);\n expect(result2.tables).toEqual([]);\n });\n\n test('should not format unknown custom tags', () => {\n const result = formatStringToHtml('[unknown]unknown[/unknown]', {\n parseBBCode: true,\n });\n expect(result.html).toEqual('<p>[unknown]unknown[/unknown]</p>');\n expect(result.tables).toEqual([]);\n });\n });\n\n describe('Line breaks', () => {\n describe('Between Elements', () => {\n test('should format line breaks between block level elements correctly', () => {\n const result1 = formatStringToHtml('[h1]h1[/h1]\\n[h2]h2[/h2]', {\n parseBBCode: true,\n });\n expect(result1.html).toEqual('<p><h1>h1</h1><h2>h2</h2></p>');\n expect(result1.tables).toEqual([]);\n\n const result2 = formatStringToHtml('[h1]h1[/h1]\\n\\n[h2]h2[/h2]', {\n parseBBCode: true,\n });\n expect(result2.html).toEqual('<p><h1>h1</h1></p>\\n<p><h2>h2</h2></p>');\n expect(result2.tables).toEqual([]);\n });\n\n test('should format line breaks between inline elements correctly', () => {\n const result1 = formatStringToHtml('[b]bold[/b]\\n[i]italic[/i]', {\n parseBBCode: true,\n });\n expect(result1.html).toEqual('<p><b>bold</b>\\n<i>italic</i></p>');\n expect(result1.tables).toEqual([]);\n\n const result2 = formatStringToHtml('[b]bold[/b]\\n\\n[i]italic[/i]', {\n parseBBCode: true,\n });\n expect(result2.html).toEqual('<p><b>bold</b></p>\\n<p><i>italic</i></p>');\n expect(result2.tables).toEqual([]);\n });\n });\n\n describe('Within Elements', () => {\n test('should format line breaks within block level elements correctly', () => {\n const result = formatStringToHtml('[h1]Line 1\\nLine 2[/h1]', {\n parseBBCode: true,\n });\n expect(result.html).toEqual('<p><h1>Line 1\\nLine 2</h1></p>');\n expect(result.tables).toEqual([]);\n });\n\n // This is a test that would fail!\n // test('should format multiple line breaks within block level elements correctly', () => {\n // const result = formatStringToHtml('[h1]Line 1\\n\\nLine 2[/h1]', {\n // parseBBCode: true,\n // });\n // expect(result.html).toEqual('<p><h1>Line 1\\nLine 2</h1></p>');\n // expect(result.tables).toEqual([]);\n // });\n\n test('should remove trailing and leading new lines within block level elements', () => {\n const result = formatStringToHtml('[h1]\\n\\n\\nLine 1\\n\\n\\n[/h1]', {\n parseBBCode: true,\n });\n expect(result.html).toEqual('<p><h1>Line 1</h1></p>');\n expect(result.tables).toEqual([]);\n });\n });\n });\n\n test('should not format url in tag attributes', () => {\n const result = formatStringToHtml(\n '[link url=\"https://www.google.com\"]Google[/link]',\n {\n parseBBCode: true,\n customInlineLevelBBCodeTags: ['link'],\n },\n );\n expect(result.html).toEqual(\n '<p><bb-code-link url=\"https://www.google.com\">Google</bb-code-link></p>',\n );\n expect(result.tables).toEqual([]);\n });\n\n test('should apply style attribute correctly', () => {\n const result = formatStringToHtml('[span style=\"color: red;\"]red text[/span]', {\n parseBBCode: true,\n });\n expect(result.html).toEqual('<p><span style=\"color: red;\">red text</span></p>');\n expect(result.tables).toEqual([]);\n });\n\n test('should format nested elements correctly', () => {\n const result = formatStringToHtml('[b][i]bold italic[/i][/b]', {\n parseBBCode: true,\n });\n expect(result.html).toEqual('<p><b><i>bold italic</i></b></p>');\n expect(result.tables).toEqual([]);\n });\n });\n });\n\n describe('Combined Formatting (Markdown + BB-Code)', () => {\n test('should format bb-code within markdown correctly', () => {\n const result = formatStringToHtml('*[b]bold[/b]*', {\n parseBBCode: true,\n });\n expect(result.html).toEqual('<p><em><b>bold</b></em></p>');\n expect(result.tables).toEqual([]);\n });\n\n test('should format markdown within bb-code correctly', () => {\n const result = formatStringToHtml('[b]*bold*[/b]', {\n parseBBCode: true,\n });\n expect(result.html).toEqual('<p><b><em>bold</em></b></p>');\n expect(result.tables).toEqual([]);\n });\n });\n});\n"],"mappings":";;AAAA,IAAAA,OAAA,GAAAC,OAAA;AACA,IAAAC,aAAA,GAAAD,OAAA;AAEA,MAAME,gBAAgB,GAAIC,IAAY,IAAKA,IAAI,CAACC,OAAO,CAAC,KAAK,EAAE,EAAE,CAAC;AAElE,IAAAC,gBAAQ,EAAC,yBAAyB,EAAE,MAAM;EACtC,IAAAA,gBAAQ,EAAC,mBAAmB,EAAE,MAAM;IAChC,IAAAA,gBAAQ,EAAC,aAAa,EAAE,MAAM;MAC1B,IAAAC,YAAI,EAAC,qCAAqC,EAAE,MAAM;QAC9C,MAAMC,MAAM,GAAG,IAAAC,gCAAkB,EAAC,gBAAgB,CAAC;QACnD,IAAAC,cAAM,EAACF,MAAM,CAACG,IAAI,CAAC,CAACC,OAAO,CAAC,uBAAuB,CAAC;QACpD,IAAA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AAC;AACN,CAAC,CAAC","ignoreList":[]}
|
|
@@ -38,12 +38,18 @@ const tokenizer = {
|
|
|
38
38
|
}
|
|
39
39
|
return undefined;
|
|
40
40
|
},
|
|
41
|
+
// Disables Markdown formatting for setext headings.
|
|
41
42
|
lheading() {
|
|
42
43
|
return undefined;
|
|
43
44
|
},
|
|
45
|
+
// Disables converting urls to hyperlinks.
|
|
44
46
|
url() {
|
|
45
47
|
return undefined;
|
|
46
48
|
},
|
|
49
|
+
// Disables converting text with 4 leading spaces to code block.
|
|
50
|
+
code() {
|
|
51
|
+
return undefined;
|
|
52
|
+
},
|
|
47
53
|
// inlineText is overwritten to prevent html escaping, specifically since quote characters are escaped, which breaks the attributes of bb-code elements.
|
|
48
54
|
// The function is copied from marked.js and slightly modified: https://github.com/markedjs/marked/blob/42954aaba960b6f815b24ec0d39da464960e4ec9/src/Tokenizer.ts#L854
|
|
49
55
|
inlineText(src) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"formatMarkdown.js","names":["_marked","require","_sync","_formatBBCode","inlineCodeRule","inlineTextRule","TABLE_ID_PREFIX","tokenizer","codespan","src","cap","exec","text","replace","hasNonSpaceChars","test","hasSpaceCharsOnBothEnds","substring","length","type","raw","undefined","lheading","url","inlineText","renderer","code","lang","_match","langString","match","checkbox","checked","postprocess","html","tableIndex","modifiedString","result","marked","use","hooks","parseMarkdown","parseBBCode","parse","walkTokens","token","escapeBBCodeSquareBrackets","exports","unescapeHtml","replaceAll","getMarkdownTables","tableTokens","push","tables","forEach","tableToken","index","_tableToken$header","_tableToken$rows","tableArray","header","rowArray","rows","row","cell","csv","stringify","id"],"sources":["../../../../../src/utils/formatString/markdown/formatMarkdown.ts"],"sourcesContent":["import { marked, Tokens } from 'marked';\nimport type { TableObject } from '../../../types/format';\n// eslint-disable-next-line import/extensions,import/no-unresolved\nimport { stringify } from 'csv-stringify/browser/esm/sync';\nimport { escapeBBCodeSquareBrackets } from '../bb-code/formatBBCode';\n\nconst inlineCodeRule = /^(`+)([^`]|[^`][\\s\\S]*?[^`])\\1(?!`)/;\nconst inlineTextRule = /^(`+|[^`])(?:(?= {2,}\\n)|[\\s\\S]*?(?:(?=[\\\\<![`*_]|\\b_|$)|[^ ](?= {2,}\\n)))/;\n\nconst TABLE_ID_PREFIX = 'formatted-table-';\n\n/*\n The marked Pipeline, including tokenizer, renderer and hooks are explained here:\n https://marked.js.org/using_pro\n*/\n\nconst tokenizer = {\n // Codespan Tokenizer is overwritten to prevent html escaping, since html is already escaped.\n // The function is copied from marked.js and slightly modified: https://github.com/markedjs/marked/blob/42954aaba960b6f815b24ec0d39da464960e4ec9/src/Tokenizer.ts#L749\n codespan(src: string): Tokens.Codespan | undefined {\n const cap = inlineCodeRule.exec(src);\n if (cap) {\n let text = (cap[2] as string).replace(/\\n/g, ' ');\n const hasNonSpaceChars = /[^ ]/.test(text);\n const hasSpaceCharsOnBothEnds = /^ /.test(text) && / $/.test(text);\n if (hasNonSpaceChars && hasSpaceCharsOnBothEnds) {\n text = text.substring(1, text.length - 1);\n }\n\n return {\n type: 'codespan',\n raw: cap[0],\n text,\n };\n }\n\n return undefined;\n },\n lheading(): Tokens.Heading | undefined {\n return undefined;\n },\n url() {\n return undefined;\n },\n // inlineText is overwritten to prevent html escaping, specifically since quote characters are escaped, which breaks the attributes of bb-code elements.\n // The function is copied from marked.js and slightly modified: https://github.com/markedjs/marked/blob/42954aaba960b6f815b24ec0d39da464960e4ec9/src/Tokenizer.ts#L854\n inlineText(src: string) {\n const cap = inlineTextRule.exec(src);\n if (cap) {\n return {\n type: 'text',\n raw: cap[0],\n text: cap[0],\n };\n }\n return undefined;\n },\n};\n\nconst renderer = {\n // Code Renderer is overwritten to prevent html escaping, since html is already escaped.\n // The function is copied from marked.js and slightly modified: https://github.com/markedjs/marked/blob/42954aaba960b6f815b24ec0d39da464960e4ec9/src/Renderer.ts#L24\n code(text: string, lang: string): string {\n const langString = (lang || '').match(/^\\S*/)?.[0];\n\n const code = `${text.replace(/\\n$/, '')}`;\n\n if (!langString) {\n return `<pre><code>${code}</code></pre>\\n`;\n }\n\n return `<pre><code class=\"language-${langString}\">${code}</code></pre>\\n`;\n },\n // Replaces the checkbox input elements with markdown checkboxes.\n // This is the easiest way to prevent the formatting of markdown checkboxes in lists.\n // This can modify the input string slightly, since the capitalization of the checkbox can be lost.\n // If a user types '- [X]' it will be replaced with '- [x]' => the capitalization is lost.\n checkbox({ checked }: Tokens.Checkbox) {\n return checked ? '[x]' : '[ ]';\n },\n};\n\nconst postprocess = (html: string): string => {\n let tableIndex = 0;\n // Assigns ids to tables.\n const modifiedString = html.replace(/(<table>)/g, () => {\n const result = `<table id=\"${TABLE_ID_PREFIX}${tableIndex}\">`;\n tableIndex++;\n return result;\n });\n\n return modifiedString;\n};\n\n// eslint-disable-next-line @typescript-eslint/ban-ts-comment\n// @ts-ignore\nmarked.use({ tokenizer, renderer, hooks: { postprocess } });\n\n// Parses markdown following the Github Flavored Markdown specification.\n// The tokenizer and renderer are slightly modified to prevent html escaping in code block and inline code.\nexport const parseMarkdown = (text: string, parseBBCode: boolean) =>\n marked.parse(text, {\n walkTokens: (token) => {\n if (parseBBCode && (token.type === 'codespan' || token.type === 'code')) {\n // eslint-disable-next-line no-param-reassign\n (token as Tokens.Codespan).text = escapeBBCodeSquareBrackets(\n (token as Tokens.Codespan).text,\n );\n }\n },\n }) as string;\n\n// It is important that, & is replaced lastly to prevent double escaping.\nconst unescapeHtml = (text: string) =>\n text.replaceAll('<', '<').replaceAll('>', '>').replaceAll('&', '&');\n\nexport const getMarkdownTables = (text: string): TableObject[] => {\n const tableTokens: Tokens.Table[] = [];\n\n marked.parse(text, {\n walkTokens: (token) => {\n if (token.type === 'table') {\n tableTokens.push(token as Tokens.Table);\n }\n },\n }) as string;\n\n const tables: TableObject[] = [];\n\n tableTokens.forEach((tableToken, index) => {\n const tableArray: string[][] = [];\n\n if (tableToken.header?.length > 0) {\n const rowArray: string[] = [];\n\n tableToken.header.forEach((header) => {\n rowArray.push(unescapeHtml(header.text));\n });\n\n tableArray.push(rowArray);\n }\n if (tableToken.rows?.length > 0) {\n tableToken.rows.forEach((row) => {\n const rowArray: string[] = [];\n\n row.forEach((cell) => {\n rowArray.push(unescapeHtml(cell.text));\n });\n\n tableArray.push(rowArray);\n });\n }\n\n const csv = stringify(tableArray || []);\n\n tables.push({\n raw: unescapeHtml(tableToken.raw),\n csv,\n id: `${TABLE_ID_PREFIX}${index}`,\n });\n });\n\n return tables;\n};\n"],"mappings":";;;;;;AAAA,IAAAA,OAAA,GAAAC,OAAA;AAGA,IAAAC,KAAA,GAAAD,OAAA;AACA,IAAAE,aAAA,GAAAF,OAAA;AAFA;;AAIA,MAAMG,cAAc,GAAG,qCAAqC;AAC5D,MAAMC,cAAc,GAAG,4EAA4E;AAEnG,MAAMC,eAAe,GAAG,kBAAkB;;AAE1C;AACA;AACA;AACA;;AAEA,MAAMC,SAAS,GAAG;EACd;EACA;EACAC,QAAQA,CAACC,GAAW,EAA+B;IAC/C,MAAMC,GAAG,GAAGN,cAAc,CAACO,IAAI,CAACF,GAAG,CAAC;IACpC,IAAIC,GAAG,EAAE;MACL,IAAIE,IAAI,GAAIF,GAAG,CAAC,CAAC,CAAC,CAAYG,OAAO,CAAC,KAAK,EAAE,GAAG,CAAC;MACjD,MAAMC,gBAAgB,GAAG,MAAM,CAACC,IAAI,CAACH,IAAI,CAAC;MAC1C,MAAMI,uBAAuB,GAAG,IAAI,CAACD,IAAI,CAACH,IAAI,CAAC,IAAI,IAAI,CAACG,IAAI,CAACH,IAAI,CAAC;MAClE,IAAIE,gBAAgB,IAAIE,uBAAuB,EAAE;QAC7CJ,IAAI,GAAGA,IAAI,CAACK,SAAS,CAAC,CAAC,EAAEL,IAAI,CAACM,MAAM,GAAG,CAAC,CAAC;MAC7C;MAEA,OAAO;QACHC,IAAI,EAAE,UAAU;QAChBC,GAAG,EAAEV,GAAG,CAAC,CAAC,CAAC;QACXE;MACJ,CAAC;IACL;IAEA,OAA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ACvC,MAAMC,UAAsB,GAAG,EAAE;IAEjC,IAAI,EAAAF,kBAAA,GAAAF,UAAU,CAACK,MAAM,cAAAH,kBAAA,uBAAjBA,kBAAA,CAAmBvC,MAAM,IAAG,CAAC,EAAE;MAC/B,MAAM2C,QAAkB,GAAG,EAAE;MAE7BN,UAAU,CAACK,MAAM,CAACN,OAAO,CAAEM,MAAM,IAAK;QAClCC,QAAQ,CAACT,IAAI,CAACJ,YAAY,CAACY,MAAM,CAAChD,IAAI,CAAC,CAAC;MAC5C,CAAC,CAAC;MAEF+C,UAAU,CAACP,IAAI,CAACS,QAAQ,CAAC;IAC7B;IACA,IAAI,EAAAH,gBAAA,GAAAH,UAAU,CAACO,IAAI,cAAAJ,gBAAA,uBAAfA,gBAAA,CAAiBxC,MAAM,IAAG,CAAC,EAAE;MAC7BqC,UAAU,CAACO,IAAI,CAACR,OAAO,CAAES,GAAG,IAAK;QAC7B,MAAMF,QAAkB,GAAG,EAAE;QAE7BE,GAAG,CAACT,OAAO,CAAEU,IAAI,IAAK;UAClBH,QAAQ,CAACT,IAAI,CAACJ,YAAY,CAACgB,IAAI,CAACpD,IAAI,CAAC,CAAC;QAC1C,CAAC,CAAC;QAEF+C,UAAU,CAACP,IAAI,CAACS,QAAQ,CAAC;MAC7B,CAAC,CAAC;IACN;IAEA,MAAMI,GAAG,GAAG,IAAAC,eAAS,EAACP,UAAU,IAAI,EAAE,CAAC;IAEvCN,MAAM,CAACD,IAAI,CAAC;MACRhC,GAAG,EAAE4B,YAAY,CAACO,UAAU,CAACnC,GAAG,CAAC;MACjC6C,GAAG;MACHE,EAAE,EAAE,GAAG7D,eAAe,GAAGkD,KAAK;IAClC,CAAC,CAAC;EACN,CAAC,CAAC;EAEF,OAAOH,MAAM;AACjB,CAAC;AAACN,OAAA,CAAAG,iBAAA,GAAAA,iBAAA","ignoreList":[]}
|
|
1
|
+
{"version":3,"file":"formatMarkdown.js","names":["_marked","require","_sync","_formatBBCode","inlineCodeRule","inlineTextRule","TABLE_ID_PREFIX","tokenizer","codespan","src","cap","exec","text","replace","hasNonSpaceChars","test","hasSpaceCharsOnBothEnds","substring","length","type","raw","undefined","lheading","url","code","inlineText","renderer","lang","_match","langString","match","checkbox","checked","postprocess","html","tableIndex","modifiedString","result","marked","use","hooks","parseMarkdown","parseBBCode","parse","walkTokens","token","escapeBBCodeSquareBrackets","exports","unescapeHtml","replaceAll","getMarkdownTables","tableTokens","push","tables","forEach","tableToken","index","_tableToken$header","_tableToken$rows","tableArray","header","rowArray","rows","row","cell","csv","stringify","id"],"sources":["../../../../../src/utils/formatString/markdown/formatMarkdown.ts"],"sourcesContent":["import { marked, Tokens } from 'marked';\nimport type { TableObject } from '../../../types/format';\n// eslint-disable-next-line import/extensions,import/no-unresolved\nimport { stringify } from 'csv-stringify/browser/esm/sync';\nimport { escapeBBCodeSquareBrackets } from '../bb-code/formatBBCode';\n\nconst inlineCodeRule = /^(`+)([^`]|[^`][\\s\\S]*?[^`])\\1(?!`)/;\nconst inlineTextRule = /^(`+|[^`])(?:(?= {2,}\\n)|[\\s\\S]*?(?:(?=[\\\\<![`*_]|\\b_|$)|[^ ](?= {2,}\\n)))/;\n\nconst TABLE_ID_PREFIX = 'formatted-table-';\n\n/*\n The marked Pipeline, including tokenizer, renderer and hooks are explained here:\n https://marked.js.org/using_pro\n*/\n\nconst tokenizer = {\n // Codespan Tokenizer is overwritten to prevent html escaping, since html is already escaped.\n // The function is copied from marked.js and slightly modified: https://github.com/markedjs/marked/blob/42954aaba960b6f815b24ec0d39da464960e4ec9/src/Tokenizer.ts#L749\n codespan(src: string): Tokens.Codespan | undefined {\n const cap = inlineCodeRule.exec(src);\n if (cap) {\n let text = (cap[2] as string).replace(/\\n/g, ' ');\n const hasNonSpaceChars = /[^ ]/.test(text);\n const hasSpaceCharsOnBothEnds = /^ /.test(text) && / $/.test(text);\n if (hasNonSpaceChars && hasSpaceCharsOnBothEnds) {\n text = text.substring(1, text.length - 1);\n }\n\n return {\n type: 'codespan',\n raw: cap[0],\n text,\n };\n }\n\n return undefined;\n },\n // Disables Markdown formatting for setext headings.\n lheading(): Tokens.Heading | undefined {\n return undefined;\n },\n // Disables converting urls to hyperlinks.\n url() {\n return undefined;\n },\n // Disables converting text with 4 leading spaces to code block.\n code() {\n return undefined;\n },\n // inlineText is overwritten to prevent html escaping, specifically since quote characters are escaped, which breaks the attributes of bb-code elements.\n // The function is copied from marked.js and slightly modified: https://github.com/markedjs/marked/blob/42954aaba960b6f815b24ec0d39da464960e4ec9/src/Tokenizer.ts#L854\n inlineText(src: string) {\n const cap = inlineTextRule.exec(src);\n if (cap) {\n return {\n type: 'text',\n raw: cap[0],\n text: cap[0],\n };\n }\n return undefined;\n },\n};\n\nconst renderer = {\n // Code Renderer is overwritten to prevent html escaping, since html is already escaped.\n // The function is copied from marked.js and slightly modified: https://github.com/markedjs/marked/blob/42954aaba960b6f815b24ec0d39da464960e4ec9/src/Renderer.ts#L24\n code(text: string, lang: string): string {\n const langString = (lang || '').match(/^\\S*/)?.[0];\n\n const code = `${text.replace(/\\n$/, '')}`;\n\n if (!langString) {\n return `<pre><code>${code}</code></pre>\\n`;\n }\n\n return `<pre><code class=\"language-${langString}\">${code}</code></pre>\\n`;\n },\n // Replaces the checkbox input elements with markdown checkboxes.\n // This is the easiest way to prevent the formatting of markdown checkboxes in lists.\n // This can modify the input string slightly, since the capitalization of the checkbox can be lost.\n // If a user types '- [X]' it will be replaced with '- [x]' => the capitalization is lost.\n checkbox({ checked }: Tokens.Checkbox) {\n return checked ? '[x]' : '[ ]';\n },\n};\n\nconst postprocess = (html: string): string => {\n let tableIndex = 0;\n // Assigns ids to tables.\n const modifiedString = html.replace(/(<table>)/g, () => {\n const result = `<table id=\"${TABLE_ID_PREFIX}${tableIndex}\">`;\n tableIndex++;\n return result;\n });\n\n return modifiedString;\n};\n\n// eslint-disable-next-line @typescript-eslint/ban-ts-comment\n// @ts-ignore\nmarked.use({ tokenizer, renderer, hooks: { postprocess } });\n\n// Parses markdown following the Github Flavored Markdown specification.\n// The tokenizer and renderer are slightly modified to prevent html escaping in code block and inline code.\nexport const parseMarkdown = (text: string, parseBBCode: boolean) =>\n marked.parse(text, {\n walkTokens: (token) => {\n if (parseBBCode && (token.type === 'codespan' || token.type === 'code')) {\n // eslint-disable-next-line no-param-reassign\n (token as Tokens.Codespan).text = escapeBBCodeSquareBrackets(\n (token as Tokens.Codespan).text,\n );\n }\n },\n }) as string;\n\n// It is important that, & is replaced lastly to prevent double escaping.\nconst unescapeHtml = (text: string) =>\n text.replaceAll('<', '<').replaceAll('>', '>').replaceAll('&', '&');\n\nexport const getMarkdownTables = (text: string): TableObject[] => {\n const tableTokens: Tokens.Table[] = [];\n\n marked.parse(text, {\n walkTokens: (token) => {\n if (token.type === 'table') {\n tableTokens.push(token as Tokens.Table);\n }\n },\n }) as string;\n\n const tables: TableObject[] = [];\n\n tableTokens.forEach((tableToken, index) => {\n const tableArray: string[][] = [];\n\n if (tableToken.header?.length > 0) {\n const rowArray: string[] = [];\n\n tableToken.header.forEach((header) => {\n rowArray.push(unescapeHtml(header.text));\n });\n\n tableArray.push(rowArray);\n }\n if (tableToken.rows?.length > 0) {\n tableToken.rows.forEach((row) => {\n const rowArray: string[] = [];\n\n row.forEach((cell) => {\n rowArray.push(unescapeHtml(cell.text));\n });\n\n tableArray.push(rowArray);\n });\n }\n\n const csv = stringify(tableArray || []);\n\n tables.push({\n raw: unescapeHtml(tableToken.raw),\n csv,\n id: `${TABLE_ID_PREFIX}${index}`,\n });\n });\n\n return tables;\n};\n"],"mappings":";;;;;;AAAA,IAAAA,OAAA,GAAAC,OAAA;AAGA,IAAAC,KAAA,GAAAD,OAAA;AACA,IAAAE,aAAA,GAAAF,OAAA;AAFA;;AAIA,MAAMG,cAAc,GAAG,qCAAqC;AAC5D,MAAMC,cAAc,GAAG,4EAA4E;AAEnG,MAAMC,eAAe,GAAG,kBAAkB;;AAE1C;AACA;AACA;AACA;;AAEA,MAAMC,SAAS,GAAG;EACd;EACA;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qC,UAAU,CAACO,IAAI,CAACR,OAAO,CAAES,GAAG,IAAK;QAC7B,MAAMF,QAAkB,GAAG,EAAE;QAE7BE,GAAG,CAACT,OAAO,CAAEU,IAAI,IAAK;UAClBH,QAAQ,CAACT,IAAI,CAACJ,YAAY,CAACgB,IAAI,CAACpD,IAAI,CAAC,CAAC;QAC1C,CAAC,CAAC;QAEF+C,UAAU,CAACP,IAAI,CAACS,QAAQ,CAAC;MAC7B,CAAC,CAAC;IACN;IAEA,MAAMI,GAAG,GAAG,IAAAC,eAAS,EAACP,UAAU,IAAI,EAAE,CAAC;IAEvCN,MAAM,CAACD,IAAI,CAAC;MACRhC,GAAG,EAAE4B,YAAY,CAACO,UAAU,CAACnC,GAAG,CAAC;MACjC6C,GAAG;MACHE,EAAE,EAAE,GAAG7D,eAAe,GAAGkD,KAAK;IAClC,CAAC,CAAC;EACN,CAAC,CAAC;EAEF,OAAOH,MAAM;AACjB,CAAC;AAACN,OAAA,CAAAG,iBAAA,GAAAA,iBAAA","ignoreList":[]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"format.js","names":["BB_CODE_HTML_TAG_PREFIX"],"sources":["../../../src/constants/format.ts"],"sourcesContent":["export const BB_CODE_HTML_TAG_PREFIX = 'bb-code-';\n"],"mappings":"AAAA,OAAO,MAAMA,uBAAuB,GAAG,UAAU","ignoreList":[]}
|
package/lib/esm/index.js
CHANGED
package/lib/esm/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","names":["formatStringToHtml"],"sources":["../../src/index.ts"],"sourcesContent":["export { formatStringToHtml } from './utils/formatString/formatString';\n"],"mappings":"AAAA,SAASA,kBAAkB,QAAQ,mCAAmC","ignoreList":[]}
|
|
1
|
+
{"version":3,"file":"index.js","names":["BB_CODE_HTML_TAG_PREFIX","formatStringToHtml"],"sources":["../../src/index.ts"],"sourcesContent":["export { BB_CODE_HTML_TAG_PREFIX } from './constants/format';\nexport type { TableObject } from './types/format';\nexport { formatStringToHtml } from './utils/formatString/formatString';\n"],"mappings":"AAAA,SAASA,uBAAuB,QAAQ,oBAAoB;AAE5D,SAASC,kBAAkB,QAAQ,mCAAmC","ignoreList":[]}
|
package/lib/esm/utils/escape.js
CHANGED
|
@@ -1,4 +1,2 @@
|
|
|
1
1
|
export const escapeHtmlInText = text => text.replace(/</g, '<').replace(/>/g, '>');
|
|
2
|
-
export const MESSAGE_CONVERSION_LINE_BREAK = '<br is-replaced-linebreak>';
|
|
3
|
-
export const MESSAGE_CONVERSION_LINE_BREAK_ESCAPED = escapeHtmlInText(MESSAGE_CONVERSION_LINE_BREAK);
|
|
4
2
|
//# sourceMappingURL=escape.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"escape.js","names":["escapeHtmlInText","text","replace"
|
|
1
|
+
{"version":3,"file":"escape.js","names":["escapeHtmlInText","text","replace"],"sources":["../../../src/utils/escape.ts"],"sourcesContent":["export const escapeHtmlInText = (text: string): string =>\n text.replace(/</g, '<').replace(/>/g, '>');\n"],"mappings":"AAAA,OAAO,MAAMA,gBAAgB,GAAIC,IAAY,IACzCA,IAAI,CAACC,OAAO,CAAC,IAAI,EAAE,MAAM,CAAC,CAACA,OAAO,CAAC,IAAI,EAAE,MAAM,CAAC","ignoreList":[]}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
+
import { BB_CODE_HTML_TAG_PREFIX } from '../../../constants/format';
|
|
1
2
|
import { findFirstBBCode } from './findBBCode';
|
|
2
|
-
const BB_CODE_HTML_TAG_PREFIX = 'bb-code-';
|
|
3
3
|
const BLOCK_LEVEL_TAGS = ['center', 'ul', 'ol', 'li', 'h1', 'h2', 'h3', 'h4', 'h5', 'h6', 'p'];
|
|
4
4
|
const INLINE_LEVEL_TAGS = ['b', 'strong', 'i', 'em', 'u', 's', 'span', 'img'];
|
|
5
5
|
// Parses BB-Code to HTML recursively.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"formatBBCode.js","names":["
|
|
1
|
+
{"version":3,"file":"formatBBCode.js","names":["BB_CODE_HTML_TAG_PREFIX","findFirstBBCode","BLOCK_LEVEL_TAGS","INLINE_LEVEL_TAGS","parseBBCode","text","options","customBlockLevelBBCodeTags","customBlockLevelTags","customInlineLevelBBCodeTags","customInlineLevelTags","justEscapeSquareBrackets","html","parseBehindIndex","length","htmlToParse","slice","firstBBCodeMatch","content","fullMatch","parameters","index","openingTag","closingTag","Tag","tag","toLowerCase","isValidTag","includes","isBlockLevelTag","parsedContent","indexOfFullMatch","indexOf","escapedOpeningTag","escapeBBCodeSquareBrackets","escapedClosingTag","replace","htmlAfterTag","isCustomTag","htmlTag","openingHtmlTag","Object","entries","map","_ref","key","value","join","closingHtmlTag","element","replaceAll","unescapeBBCodeSquareBrackets"],"sources":["../../../../../src/utils/formatString/bb-code/formatBBCode.ts"],"sourcesContent":["import { BB_CODE_HTML_TAG_PREFIX } from '../../../constants/format';\nimport { findFirstBBCode } from './findBBCode';\n\nconst BLOCK_LEVEL_TAGS = ['center', 'ul', 'ol', 'li', 'h1', 'h2', 'h3', 'h4', 'h5', 'h6', 'p'];\nconst INLINE_LEVEL_TAGS = ['b', 'strong', 'i', 'em', 'u', 's', 'span', 'img'];\n\nexport interface ParseBBCodesOptions {\n customBlockLevelBBCodeTags?: string[];\n customInlineLevelBBCodeTags?: string[];\n}\n\ninterface ParseBBCodePrivateOptions extends ParseBBCodesOptions {\n justEscapeSquareBrackets?: boolean;\n}\n\n// Parses BB-Code to HTML recursively.\n// When justEscapeSquareBrackets is true, square brackets are escaped to prevent conflicts between markdown and BB Code.\n// In that case the function only escapes square brackets and doesn't remove line breaks.\nexport const parseBBCode = (text: string, options?: ParseBBCodePrivateOptions) => {\n const {\n customBlockLevelBBCodeTags: customBlockLevelTags = [],\n customInlineLevelBBCodeTags: customInlineLevelTags = [],\n justEscapeSquareBrackets = false,\n } = options || {};\n\n let html = text;\n\n // This index is used to keep track of the position in the html string that is being parsed.\n let parseBehindIndex = 0;\n\n while (parseBehindIndex < html.length) {\n const htmlToParse = html.slice(parseBehindIndex);\n\n const firstBBCodeMatch = findFirstBBCode(htmlToParse);\n\n // Stops parsing if no BB-Code is found.\n if (!firstBBCodeMatch) {\n return html;\n }\n\n const { content, fullMatch, parameters, index, openingTag, closingTag } = firstBBCodeMatch;\n\n const Tag = firstBBCodeMatch.tag.toLowerCase();\n const isValidTag = [\n ...BLOCK_LEVEL_TAGS,\n ...customBlockLevelTags,\n ...INLINE_LEVEL_TAGS,\n ...customInlineLevelTags,\n ].includes(Tag);\n const isBlockLevelTag = [...BLOCK_LEVEL_TAGS, ...customBlockLevelTags].includes(Tag);\n\n // Ignores tags that are not supported.\n if (!isValidTag) {\n // The parsing continues behind the first square bracket of the BB-Code tag.\n parseBehindIndex += index + 1;\n // eslint-disable-next-line no-continue\n continue;\n }\n\n // Converts BB-Code tag's content before converting itself, because it may contain other BB-Codes.\n let parsedContent = parseBBCode(content, options);\n\n if (justEscapeSquareBrackets) {\n const indexOfFullMatch = html.indexOf(fullMatch);\n const escapedOpeningTag = escapeBBCodeSquareBrackets(openingTag);\n const escapedClosingTag = escapeBBCodeSquareBrackets(closingTag);\n\n // Removes leading and trailing line-breaks from within bb code elements, to prevent unwanted spacing.\n // This needs to be done before formatting Markdown, so the Markdown formatting doesn't interpret line breaks unexpectedly.\n parsedContent = parsedContent.replace(/^\\n+|\\n+$/g, '');\n\n // Simply escapes the square brackets of the BB-Code opening and closing tag.\n html =\n html.slice(0, indexOfFullMatch) +\n escapedOpeningTag +\n parsedContent +\n escapedClosingTag +\n html.slice(indexOfFullMatch + fullMatch.length);\n\n // Continues parsing behind the parsed bb-code.\n parseBehindIndex =\n indexOfFullMatch +\n escapedOpeningTag.length +\n parsedContent.length +\n escapedClosingTag.length;\n } else {\n const indexOfFullMatch = html.indexOf(fullMatch);\n\n let htmlAfterTag = html.slice(indexOfFullMatch + fullMatch.length);\n\n // Removes leading line-break (ONE, NOT ALL) after block level elements, to prevent unwanted spacing.\n if (isBlockLevelTag) {\n htmlAfterTag = htmlAfterTag.replace(/^\\n/, '');\n }\n\n const isCustomTag = [...customBlockLevelTags, ...customInlineLevelTags].includes(Tag);\n const htmlTag = isCustomTag ? `${BB_CODE_HTML_TAG_PREFIX}${Tag}` : Tag;\n const openingHtmlTag = `<${htmlTag}${Object.entries(parameters).length > 0 ? ' ' : ''}${Object.entries(\n parameters,\n )\n .map(([key, value]) => `${key}=\"${value}\"`)\n .join(' ')}>`;\n const closingHtmlTag = `</${htmlTag}>`;\n\n const element =\n Tag === 'img' ? openingHtmlTag : openingHtmlTag + parsedContent + closingHtmlTag;\n\n html = `${html.slice(0, indexOfFullMatch)}${element}${htmlAfterTag}`;\n\n // Continues parsing behind the parsed bb-code.\n parseBehindIndex = indexOfFullMatch + element.length;\n }\n }\n\n return html;\n};\n\nexport const escapeBBCodeSquareBrackets = (text: string) =>\n text.replaceAll('[', '‍[‍').replaceAll(']', '‍]‍');\n\nexport const unescapeBBCodeSquareBrackets = (text: string) =>\n text.replaceAll('‍[‍', '[').replaceAll('‍]‍', ']');\n"],"mappings":"AAAA,SAASA,uBAAuB,QAAQ,2BAA2B;AACnE,SAASC,eAAe,QAAQ,cAAc;AAE9C,MAAMC,gBAAgB,GAAG,CAAC,QAAQ,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,GAAG,CAAC;AAC9F,MAAMC,iBAAiB,GAAG,CAAC,GAAG,EAAE,QAAQ,EAAE,GAAG,EAAE,IAAI,EAAE,GAAG,EAAE,GAAG,EAAE,MAAM,EAAE,KAAK,CAAC;AAW7E;AACA;AACA;AACA,OAAO,MAAMC,WAAW,GAAGA,CAACC,IAAY,EAAEC,OAAmC,KAAK;EAC9E,MAAM;IACFC,0BAA0B,EAAEC,oBAAoB,GAAG,EAAE;IACrDC,2BAA2B,EAAEC,qBAAqB,GAAG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,MAAMC,cAAc,GAAG,KAAKT,OAAO,GAAG;MAEtC,MAAMU,OAAO,GACTzB,GAAG,KAAK,KAAK,GAAGgB,cAAc,GAAGA,cAAc,GAAGV,aAAa,GAAGkB,cAAc;MAEpFpC,IAAI,GAAG,GAAGA,IAAI,CAACI,KAAK,CAAC,CAAC,EAAEe,gBAAgB,CAAC,GAAGkB,OAAO,GAAGZ,YAAY,EAAE;;MAEpE;MACAxB,gBAAgB,GAAGkB,gBAAgB,GAAGkB,OAAO,CAACnC,MAAM;IACxD;EACJ;EAEA,OAAOF,IAAI;AACf,CAAC;AAED,OAAO,MAAMsB,0BAA0B,GAAI7B,IAAY,IACnDA,IAAI,CAAC6C,UAAU,CAAC,GAAG,EAAE,aAAa,CAAC,CAACA,UAAU,CAAC,GAAG,EAAE,aAAa,CAAC;AAEtE,OAAO,MAAMC,4BAA4B,GAAI9C,IAAY,IACrDA,IAAI,CAAC6C,UAAU,CAAC,aAAa,EAAE,GAAG,CAAC,CAACA,UAAU,CAAC,aAAa,EAAE,GAAG,CAAC","ignoreList":[]}
|
|
@@ -182,6 +182,11 @@ describe('HTML Formatter Function', () => {
|
|
|
182
182
|
expect(resultWithLanguage.html).toEqual('<pre><code class="language-js">const a = 1;\nconst b = 2;</code></pre>');
|
|
183
183
|
expect(resultWithLanguage.tables).toEqual([]);
|
|
184
184
|
});
|
|
185
|
+
test('should not format 4 spaces as code block', () => {
|
|
186
|
+
const result = formatStringToHtml(' const a = 1;');
|
|
187
|
+
expect(result.html).toEqual('<p> const a = 1;</p>');
|
|
188
|
+
expect(result.tables).toEqual([]);
|
|
189
|
+
});
|
|
185
190
|
describe('HTML In Code', () => {
|
|
186
191
|
test('should escape < and > within code block', () => {
|
|
187
192
|
const resultWithoutLanguage = formatStringToHtml('```\n<div>Test</div>\n```');
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"formatString.test.js","names":["describe","expect","test","formatStringToHtml","removeLinebreaks","text","replace","result","html","toEqual","tables","resultEscape","resultEscape1","resultEscape2","boldResult","italicResult","inlineCodeResult","h1Result","h2Result","h3Result","h4Result","h5Result","h6Result","expectedUnorderedListResult","expectedOrderedListResult","unorderedListResult1","unorderedListResult2","orderedListResult","orderedListResult2","expectedThematicBreakResult","result1","result2","resultWithoutLanguage","resultWithLanguage","inputString","csv","raw","id","parseBBCode","table1","getTable1Result","index","table1Csv","table2","getTable2TResult","table2Csv","getHeadingInput","tag","getHeadingOutput","headingTags","forEach","input","output","customInlineLevelBBCodeTags","customBlockLevelBBCodeTags"],"sources":["../../../../src/utils/formatString/formatString.test.ts"],"sourcesContent":["import { describe, expect, test } from 'vitest';\nimport { formatStringToHtml } from './formatString';\n\nconst removeLinebreaks = (text: string) => text.replace(/\\n/g, '');\n\ndescribe('HTML Formatter Function', () => {\n describe('Format Plain Text', () => {\n describe('Line breaks', () => {\n test('should format line breaks correctly', () => {\n const result = formatStringToHtml('Line 1\\nLine 2');\n expect(result.html).toEqual('<p>Line 1\\nLine 2</p>');\n expect(result.tables).toEqual([]);\n });\n\n test('should format multiple line breaks correctly', () => {\n const result = formatStringToHtml('Line 1\\n\\nLine 2');\n expect(result.html).toEqual('<p>Line 1</p>\\n<p>Line 2</p>');\n expect(result.tables).toEqual([]);\n });\n\n test('should remove trailing and leading new lines', () => {\n const result = formatStringToHtml('\\n\\n\\nLine 1\\n\\n\\n');\n expect(result.html).toEqual('<p>Line 1</p>');\n expect(result.tables).toEqual([]);\n });\n });\n\n describe('Whitespaces', () => {\n test('should not remove repeated whitespaces', () => {\n const result = formatStringToHtml('Text with spaces');\n expect(result.html).toEqual('<p>Text with spaces</p>');\n expect(result.tables).toEqual([]);\n });\n\n test('should not remove leading and trailing whitespaces', () => {\n const result = formatStringToHtml(' Text ');\n expect(result.html).toEqual('<p> Text </p>');\n expect(result.tables).toEqual([]);\n });\n });\n\n describe('HTML', () => {\n test('should escape < and > correctly', () => {\n const resultEscape = formatStringToHtml('<div>Test</div>');\n expect(resultEscape.html).toEqual('<p><div>Test</div></p>');\n expect(resultEscape.tables).toEqual([]);\n });\n\n test('should not escape &', () => {\n const resultEscape1 = formatStringToHtml('<div>Test</div>');\n expect(resultEscape1.html).toEqual('<p><div>Test</div></p>');\n expect(resultEscape1.tables).toEqual([]);\n\n const resultEscape2 = formatStringToHtml(\n '&lt;div&gt;Test&lt;/div&gt;',\n );\n expect(resultEscape2.html).toEqual(\n '<p>&lt;div&gt;Test&lt;/div&gt;</p>',\n );\n expect(resultEscape2.tables).toEqual([]);\n });\n\n // TODO Decide if & should be escaped, when they are not part of an HTML entity.\n });\n\n describe('URLs', () => {\n test('should not format URLs', () => {\n const result = formatStringToHtml('https://example.com');\n expect(result.html).toEqual('<p>https://example.com</p>');\n expect(result.tables).toEqual([]);\n });\n });\n });\n\n describe('Format Markdown', () => {\n describe('All Elements', () => {\n test('should format text styling correctly', () => {\n const boldResult = formatStringToHtml('**bold**');\n expect(boldResult.html).toEqual('<p><strong>bold</strong></p>');\n expect(boldResult.tables).toEqual([]);\n\n const italicResult = formatStringToHtml('*italic*');\n expect(italicResult.html).toEqual('<p><em>italic</em></p>');\n expect(italicResult.tables).toEqual([]);\n\n const inlineCodeResult = formatStringToHtml('`inline code`');\n expect(inlineCodeResult.html).toEqual('<p><code>inline code</code></p>');\n expect(inlineCodeResult.tables).toEqual([]);\n });\n\n test('should format headings correctly', () => {\n const h1Result = formatStringToHtml('# h1');\n expect(h1Result.html).toEqual('<h1>h1</h1>');\n expect(h1Result.tables).toEqual([]);\n\n const h2Result = formatStringToHtml('## h2');\n expect(h2Result.html).toEqual('<h2>h2</h2>');\n expect(h2Result.tables).toEqual([]);\n\n const h3Result = formatStringToHtml('### h3');\n expect(h3Result.html).toEqual('<h3>h3</h3>');\n expect(h3Result.tables).toEqual([]);\n\n const h4Result = formatStringToHtml('#### h4');\n expect(h4Result.html).toEqual('<h4>h4</h4>');\n expect(h4Result.tables).toEqual([]);\n\n const h5Result = formatStringToHtml('##### h5');\n expect(h5Result.html).toEqual('<h5>h5</h5>');\n expect(h5Result.tables).toEqual([]);\n\n const h6Result = formatStringToHtml('###### h6');\n expect(h6Result.html).toEqual('<h6>h6</h6>');\n expect(h6Result.tables).toEqual([]);\n });\n\n test('should format links correctly', () => {\n const result = formatStringToHtml('[Link](https://example.com)');\n expect(result.html).toEqual('<p><a href=\"https://example.com\">Link</a></p>');\n expect(result.tables).toEqual([]);\n });\n\n test('should format images correctly', () => {\n const result = formatStringToHtml('');\n expect(result.html).toEqual(\n '<p><img src=\"https://example.com/image.jpg\" alt=\"Alt Text\"></p>',\n );\n expect(result.tables).toEqual([]);\n });\n\n test('should format lists correctly', () => {\n const expectedUnorderedListResult =\n '<ul>\\n<li>Item 1</li>\\n<li>Item 2</li>\\n<li>Item 3</li>\\n</ul>';\n const expectedOrderedListResult =\n '<ol>\\n<li>Item 1</li>\\n<li>Item 2</li>\\n<li>Item 3</li>\\n</ol>';\n\n const unorderedListResult1 = formatStringToHtml('- Item 1\\n- Item 2\\n- Item 3');\n expect(unorderedListResult1.html).toEqual(expectedUnorderedListResult);\n expect(unorderedListResult1.tables).toEqual([]);\n\n const unorderedListResult2 = formatStringToHtml('* Item 1\\n* Item 2\\n* Item 3');\n expect(unorderedListResult2.html).toEqual(expectedUnorderedListResult);\n expect(unorderedListResult2.tables).toEqual([]);\n\n const orderedListResult = formatStringToHtml('1. Item 1\\n2. Item 2\\n3. Item 3');\n expect(orderedListResult.html).toEqual(expectedOrderedListResult);\n expect(orderedListResult.tables).toEqual([]);\n\n const orderedListResult2 = formatStringToHtml('1) Item 1\\n2) Item 2\\n3) Item 3');\n expect(orderedListResult2.html).toEqual(expectedOrderedListResult);\n expect(orderedListResult2.tables).toEqual([]);\n });\n\n test('should format thematic breaks correctly', () => {\n const expectedThematicBreakResult = '<hr>';\n\n const result1 = formatStringToHtml('---');\n expect(result1.html).toEqual(expectedThematicBreakResult);\n expect(result1.tables).toEqual([]);\n\n const result2 = formatStringToHtml('***');\n expect(result2.html).toEqual(expectedThematicBreakResult);\n expect(result2.tables).toEqual([]);\n });\n\n test('should format code blocks correctly', () => {\n const resultWithoutLanguage = formatStringToHtml('```\\nconst a = 1;\\n```');\n expect(resultWithoutLanguage.html).toEqual('<pre><code>const a = 1;</code></pre>');\n expect(resultWithoutLanguage.tables).toEqual([]);\n\n const resultWithLanguage = formatStringToHtml('```js\\nconst a = 1;\\n```');\n expect(resultWithLanguage.html).toEqual(\n '<pre><code class=\"language-js\">const a = 1;</code></pre>',\n );\n expect(resultWithLanguage.tables).toEqual([]);\n });\n\n test('should format tables correctly', () => {\n const inputString =\n '| Header 1 | Header 2 |\\n|----------|----------|\\n| Cell 1 | Cell 2 |';\n const result = formatStringToHtml(inputString);\n expect(removeLinebreaks(result.html)).toEqual(\n '<table id=\"formatted-table-0\"><thead><tr><th>Header 1</th><th>Header 2</th></tr></thead><tbody><tr><td>Cell 1</td><td>Cell 2</td></tr></tbody></table>',\n );\n expect(result.tables).toEqual([\n {\n csv: 'Header 1,Header 2\\nCell 1,Cell 2\\n',\n raw: inputString,\n id: 'formatted-table-0',\n },\n ]);\n });\n });\n\n describe('Inline Code', () => {\n describe('HTML In Code', () => {\n test('should escape < and > within inline code correctly', () => {\n const result1 = formatStringToHtml('`<div>Test</div>`');\n expect(result1.html).toEqual('<p><code><div>Test</div></code></p>');\n expect(result1.tables).toEqual([]);\n });\n\n test('should not escape & within inline code', () => {\n const resultEscape1 = formatStringToHtml('`<div>Test</div>`');\n expect(resultEscape1.html).toEqual(\n '<p><code><div>Test</div></code></p>',\n );\n expect(resultEscape1.tables).toEqual([]);\n\n const resultEscape2 = formatStringToHtml(\n '`&lt;div&gt;Test&lt;/div&gt;`',\n );\n expect(resultEscape2.html).toEqual(\n '<p><code>&lt;div&gt;Test&lt;/div&gt;</code></p>',\n );\n expect(resultEscape2.tables).toEqual([]);\n });\n });\n\n test('should not format markdown within inline code', () => {\n const result = formatStringToHtml('`**bold** *italic*`');\n expect(result.html).toEqual('<p><code>**bold** *italic*</code></p>');\n expect(result.tables).toEqual([]);\n });\n\n test('should not format bb-code within inline code', () => {\n const result = formatStringToHtml('`[b]bold[/b]`', { parseBBCode: true });\n expect(result.html).toEqual('<p><code>[b]bold[/b]</code></p>');\n expect(result.tables).toEqual([]);\n });\n });\n\n describe('Codeblock', () => {\n test('should format code blocks with multiple lines correctly', () => {\n const resultWithoutLanguage = formatStringToHtml(\n '```\\nconst a = 1;\\nconst b = 2;\\n```',\n );\n expect(resultWithoutLanguage.html).toEqual(\n '<pre><code>const a = 1;\\nconst b = 2;</code></pre>',\n );\n expect(resultWithoutLanguage.tables).toEqual([]);\n\n const resultWithLanguage = formatStringToHtml(\n '```js\\nconst a = 1;\\nconst b = 2;\\n```',\n );\n expect(resultWithLanguage.html).toEqual(\n '<pre><code class=\"language-js\">const a = 1;\\nconst b = 2;</code></pre>',\n );\n expect(resultWithLanguage.tables).toEqual([]);\n });\n\n describe('HTML In Code', () => {\n test('should escape < and > within code block', () => {\n const resultWithoutLanguage = formatStringToHtml('```\\n<div>Test</div>\\n```');\n expect(resultWithoutLanguage.html).toEqual(\n '<pre><code><div>Test</div></code></pre>',\n );\n expect(resultWithoutLanguage.tables).toEqual([]);\n\n const resultWithLanguage = formatStringToHtml('```html\\n<div>Test</div>\\n```');\n expect(resultWithLanguage.html).toEqual(\n '<pre><code class=\"language-html\"><div>Test</div></code></pre>',\n );\n expect(resultWithLanguage.tables).toEqual([]);\n });\n\n test('should not escape & within code block', () => {\n const resultEscape1 = formatStringToHtml(\n '```\\n<div>Test</div>\\n```',\n );\n expect(resultEscape1.html).toEqual(\n '<pre><code><div>Test</div></code></pre>',\n );\n expect(resultEscape1.tables).toEqual([]);\n\n const resultEscape2 = formatStringToHtml(\n '```\\n&lt;div&gt;Test&lt;/div&gt;\\n```',\n );\n expect(resultEscape2.html).toEqual(\n '<pre><code>&lt;div&gt;Test&lt;/div&gt;</code></pre>',\n );\n expect(resultEscape2.tables).toEqual([]);\n });\n });\n\n test('should not format markdown within code block', () => {\n const resultWithoutLanguage = formatStringToHtml('```\\n**Test**\\n```');\n expect(resultWithoutLanguage.html).toEqual('<pre><code>**Test**</code></pre>');\n expect(resultWithoutLanguage.tables).toEqual([]);\n\n const resultWithLanguage = formatStringToHtml('```html\\n**Test**\\n```');\n expect(resultWithLanguage.html).toEqual(\n '<pre><code class=\"language-html\">**Test**</code></pre>',\n );\n expect(resultWithLanguage.tables).toEqual([]);\n });\n\n test('should not format bb-code within code block', () => {\n const resultWithoutLanguage = formatStringToHtml('```\\n[b]Test[/b]\\n```');\n expect(resultWithoutLanguage.html).toEqual('<pre><code>[b]Test[/b]</code></pre>');\n expect(resultWithoutLanguage.tables).toEqual([]);\n\n const resultWithLanguage = formatStringToHtml('```html\\n[b]Test[/b]\\n```');\n expect(resultWithLanguage.html).toEqual(\n '<pre><code class=\"language-html\">[b]Test[/b]</code></pre>',\n );\n expect(resultWithLanguage.tables).toEqual([]);\n });\n });\n\n describe('Table', () => {\n test('should format markdown within table correctly', () => {\n const inputString =\n '| Header 1 | Header 2 |\\n|----------|----------|\\n| **Cell 1** | *Cell 2* |';\n const result = formatStringToHtml(inputString);\n expect(removeLinebreaks(result.html)).toEqual(\n '<table id=\"formatted-table-0\"><thead><tr><th>Header 1</th><th>Header 2</th></tr></thead><tbody><tr><td><strong>Cell 1</strong></td><td><em>Cell 2</em></td></tr></tbody></table>',\n );\n expect(result.tables).toEqual([\n {\n csv: 'Header 1,Header 2\\n**Cell 1**,*Cell 2*\\n',\n raw: inputString,\n id: 'formatted-table-0',\n },\n ]);\n });\n\n test('should format bb-code within table correctly', () => {\n const inputString =\n '| Header 1 | Header 2 |\\n|----------|----------|\\n| [b]Cell 1[/b] | [i]Cell 2[/i] |';\n const result = formatStringToHtml(inputString, {\n parseBBCode: true,\n });\n expect(removeLinebreaks(result.html)).toEqual(\n '<table id=\"formatted-table-0\"><thead><tr><th>Header 1</th><th>Header 2</th></tr></thead><tbody><tr><td><b>Cell 1</b></td><td><i>Cell 2</i></td></tr></tbody></table>',\n );\n expect(result.tables).toEqual([\n {\n csv: 'Header 1,Header 2\\n[b]Cell 1[/b],[i]Cell 2[/i]\\n',\n raw: inputString,\n id: 'formatted-table-0',\n },\n ]);\n });\n\n test('should format html within table correctly', () => {\n const inputString =\n '| Header 1 | Header 2 | Header 3 |\\n|----------|----------|----------|\\n| <div>Cell 1</div> | <div>Cell 2</div> | &lt;div&gt;Cell 3&lt;/div&gt; |';\n const result = formatStringToHtml(inputString, {\n parseBBCode: true,\n });\n expect(removeLinebreaks(result.html)).toEqual(\n '<table id=\"formatted-table-0\"><thead><tr><th>Header 1</th><th>Header 2</th><th>Header 3</th></tr></thead><tbody><tr><td><div>Cell 1</div></td><td><div>Cell 2</div></td><td>&lt;div&gt;Cell 3&lt;/div&gt;</td></tr></tbody></table>',\n );\n expect(result.tables).toEqual([\n {\n csv: 'Header 1,Header 2,Header 3\\n<div>Cell 1</div>,<div>Cell 2</div>,<div>Cell 3</div>\\n',\n raw: '| Header 1 | Header 2 | Header 3 |\\n|----------|----------|----------|\\n| <div>Cell 1</div> | <div>Cell 2</div> | <div>Cell 3</div> |',\n id: 'formatted-table-0',\n },\n ]);\n });\n\n test('should format multiple tables correctly', () => {\n const table1 =\n '| Header 1 | Header 2 |\\n|----------|----------|\\n| Cell 1 | Cell 2 |';\n const getTable1Result = (index: number) =>\n `<table id=\"formatted-table-${index}\"><thead><tr><th>Header 1</th><th>Header 2</th></tr></thead><tbody><tr><td>Cell 1</td><td>Cell 2</td></tr></tbody></table>`;\n const table1Csv = 'Header 1,Header 2\\nCell 1,Cell 2\\n';\n const table2 =\n '| Header 3 | Header 4 |\\n|----------|----------|\\n| Cell 3 | Cell 4 |';\n const getTable2TResult = (index: number) =>\n `<table id=\"formatted-table-${index}\"><thead><tr><th>Header 3</th><th>Header 4</th></tr></thead><tbody><tr><td>Cell 3</td><td>Cell 4</td></tr></tbody></table>`;\n const table2Csv = 'Header 3,Header 4\\nCell 3,Cell 4\\n';\n\n const result1 = formatStringToHtml(`${table1}\\n\\n${table2}`);\n expect(removeLinebreaks(result1.html)).toEqual(\n `${getTable1Result(0)}${getTable2TResult(1)}`,\n );\n expect(result1.tables).toEqual([\n {\n csv: table1Csv,\n raw: `${table1}\\n\\n`,\n id: 'formatted-table-0',\n },\n {\n csv: table2Csv,\n raw: table2,\n id: 'formatted-table-1',\n },\n ]);\n\n // Tables in reverse order.\n const result2 = formatStringToHtml(`${table2}\\n\\n${table1}`);\n expect(removeLinebreaks(result2.html)).toEqual(\n `${getTable2TResult(0)}${getTable1Result(1)}`,\n );\n expect(result2.tables).toEqual([\n {\n csv: table2Csv,\n raw: `${table2}\\n\\n`,\n id: 'formatted-table-0',\n },\n {\n csv: table1Csv,\n raw: table1,\n id: 'formatted-table-1',\n },\n ]);\n });\n });\n\n describe('List', () => {\n test('should format markdown within list correctly', () => {\n const result = formatStringToHtml('- **Item 1**\\n- *Item 2*');\n expect(removeLinebreaks(result.html)).toEqual(\n '<ul><li><strong>Item 1</strong></li><li><em>Item 2</em></li></ul>',\n );\n expect(result.tables).toEqual([]);\n });\n\n test('should format task lists correctly', () => {\n const result1 = formatStringToHtml('- [ ] 1\\n- [x] 2\\n- [X] 3');\n expect(removeLinebreaks(result1.html)).toEqual(\n '<ul><li>[ ] 1</li><li>[x] 2</li><li>[x] 3</li></ul>',\n );\n expect(result1.tables).toEqual([]);\n });\n });\n\n describe('Combined Elements', () => {\n test('should format code block within list correctly', () => {\n const result = formatStringToHtml('* test\\n ```\\n test\\n ```');\n expect(removeLinebreaks(result.html)).toEqual(\n '<ul><li>test<pre><code>test</code></pre></li></ul>',\n );\n expect(result.tables).toEqual([]);\n });\n });\n\n describe('Conflicts with BB-Code', () => {\n test('should not format bb code tag followed by paranthese to link', () => {\n const result = formatStringToHtml('[b]bold[/b](test)', { parseBBCode: true });\n expect(result.html).toEqual('<p><b>bold</b>(test)</p>');\n expect(result.tables).toEqual([]);\n });\n });\n });\n\n describe('Format BB-Code', () => {\n describe('All Elements', () => {\n describe('Inline Elements', () => {\n // b, strong, i, em, u, s, span, img\n test('should format b tag correctly', () => {\n const result = formatStringToHtml('[b]bold[/b]', {\n parseBBCode: true,\n });\n expect(result.html).toEqual('<p><b>bold</b></p>');\n expect(result.tables).toEqual([]);\n });\n\n test('should format strong tag correctly', () => {\n const result = formatStringToHtml('[strong]bold[/strong]', {\n parseBBCode: true,\n });\n expect(result.html).toEqual('<p><strong>bold</strong></p>');\n expect(result.tables).toEqual([]);\n });\n\n test('should format i tag correctly', () => {\n const result = formatStringToHtml('[i]italic[/i]', {\n parseBBCode: true,\n });\n expect(result.html).toEqual('<p><i>italic</i></p>');\n expect(result.tables).toEqual([]);\n });\n\n test('should format em tag correctly', () => {\n const result = formatStringToHtml('[em]italic[/em]', {\n parseBBCode: true,\n });\n expect(result.html).toEqual('<p><em>italic</em></p>');\n expect(result.tables).toEqual([]);\n });\n\n test('should format u tag correctly', () => {\n const result = formatStringToHtml('[u]underline[/u]', {\n parseBBCode: true,\n });\n expect(result.html).toEqual('<p><u>underline</u></p>');\n expect(result.tables).toEqual([]);\n });\n\n test('should format s tag correctly', () => {\n const result = formatStringToHtml('[s]strike[/s]', {\n parseBBCode: true,\n });\n expect(result.html).toEqual('<p><s>strike</s></p>');\n expect(result.tables).toEqual([]);\n });\n\n test('should format span tag correctly', () => {\n const result = formatStringToHtml('[span]span[/span]', {\n parseBBCode: true,\n });\n expect(result.html).toEqual('<p><span>span</span></p>');\n expect(result.tables).toEqual([]);\n });\n\n test('should format img tag correctly', () => {\n const result = formatStringToHtml(\n '[img src=\"https://example.com/image.jpg\"][/img]',\n {\n parseBBCode: true,\n },\n );\n expect(result.html).toEqual('<p><img src=\"https://example.com/image.jpg\"></p>');\n expect(result.tables).toEqual([]);\n });\n });\n\n describe('Block Level Elements', () => {\n test('should format center tag correctly', () => {\n const result = formatStringToHtml('[center]centered text[/center]', {\n parseBBCode: true,\n });\n expect(result.html).toEqual('<p><center>centered text</center></p>');\n expect(result.tables).toEqual([]);\n });\n\n test('should format ul tag correctly', () => {\n const result = formatStringToHtml('[ul][li]Item 1[/li][li]Item 2[/li][/ul]', {\n parseBBCode: true,\n });\n expect(result.html).toEqual('<p><ul><li>Item 1</li><li>Item 2</li></ul></p>');\n expect(result.tables).toEqual([]);\n });\n\n test('should format ol tag correctly', () => {\n const result = formatStringToHtml('[ol][li]Item 1[/li][li]Item 2[/li][/ol]', {\n parseBBCode: true,\n });\n expect(result.html).toEqual('<p><ol><li>Item 1</li><li>Item 2</li></ol></p>');\n expect(result.tables).toEqual([]);\n });\n\n test('should format li tag correctly', () => {\n const result = formatStringToHtml('[li]Item[/li]', {\n parseBBCode: true,\n });\n expect(result.html).toEqual('<p><li>Item</li></p>');\n expect(result.tables).toEqual([]);\n });\n\n test('should format heading tags correctly', () => {\n const getHeadingInput = (tag: string) => `[${tag}]${tag}[/${tag}]`;\n const getHeadingOutput = (tag: string) => `<p><${tag}>${tag}</${tag}></p>`;\n const headingTags = ['h1', 'h2', 'h3', 'h4', 'h5', 'h6'];\n\n headingTags.forEach((tag) => {\n const result = formatStringToHtml(getHeadingInput(tag), {\n parseBBCode: true,\n });\n expect(result.html).toEqual(getHeadingOutput(tag));\n expect(result.tables).toEqual([]);\n });\n });\n\n test('should format p tag correctly', () => {\n const result = formatStringToHtml('[p]paragraph[/p]', {\n parseBBCode: true,\n });\n expect(result.html).toEqual('<p><p>paragraph</p></p>');\n expect(result.tables).toEqual([]);\n });\n });\n\n describe('Custom Elements', () => {\n test('should format custom tags correctly', () => {\n const input = '[custom attribute1=\"test1\" attribute2=\"test2\"]custom[/custom]';\n const output =\n '<p><bb-code-custom attribute1=\"test1\" attribute2=\"test2\">custom</bb-code-custom></p>';\n const result1 = formatStringToHtml(input, {\n parseBBCode: true,\n customInlineLevelBBCodeTags: ['custom'],\n });\n expect(result1.html).toEqual(output);\n expect(result1.tables).toEqual([]);\n\n const result2 = formatStringToHtml(input, {\n parseBBCode: true,\n customBlockLevelBBCodeTags: ['custom'],\n });\n expect(result2.html).toEqual(output);\n expect(result2.tables).toEqual([]);\n });\n\n test('should not format unknown custom tags', () => {\n const result = formatStringToHtml('[unknown]unknown[/unknown]', {\n parseBBCode: true,\n });\n expect(result.html).toEqual('<p>[unknown]unknown[/unknown]</p>');\n expect(result.tables).toEqual([]);\n });\n });\n\n describe('Line breaks', () => {\n describe('Between Elements', () => {\n test('should format line breaks between block level elements correctly', () => {\n const result1 = formatStringToHtml('[h1]h1[/h1]\\n[h2]h2[/h2]', {\n parseBBCode: true,\n });\n expect(result1.html).toEqual('<p><h1>h1</h1><h2>h2</h2></p>');\n expect(result1.tables).toEqual([]);\n\n const result2 = formatStringToHtml('[h1]h1[/h1]\\n\\n[h2]h2[/h2]', {\n parseBBCode: true,\n });\n expect(result2.html).toEqual('<p><h1>h1</h1></p>\\n<p><h2>h2</h2></p>');\n expect(result2.tables).toEqual([]);\n });\n\n test('should format line breaks between inline elements correctly', () => {\n const result1 = formatStringToHtml('[b]bold[/b]\\n[i]italic[/i]', {\n parseBBCode: true,\n });\n expect(result1.html).toEqual('<p><b>bold</b>\\n<i>italic</i></p>');\n expect(result1.tables).toEqual([]);\n\n const result2 = formatStringToHtml('[b]bold[/b]\\n\\n[i]italic[/i]', {\n parseBBCode: true,\n });\n expect(result2.html).toEqual('<p><b>bold</b></p>\\n<p><i>italic</i></p>');\n expect(result2.tables).toEqual([]);\n });\n });\n\n describe('Within Elements', () => {\n test('should format line breaks within block level elements correctly', () => {\n const result = formatStringToHtml('[h1]Line 1\\nLine 2[/h1]', {\n parseBBCode: true,\n });\n expect(result.html).toEqual('<p><h1>Line 1\\nLine 2</h1></p>');\n expect(result.tables).toEqual([]);\n });\n\n // This is a test that would fail!\n // test('should format multiple line breaks within block level elements correctly', () => {\n // const result = formatStringToHtml('[h1]Line 1\\n\\nLine 2[/h1]', {\n // parseBBCode: true,\n // });\n // expect(result.html).toEqual('<p><h1>Line 1\\nLine 2</h1></p>');\n // expect(result.tables).toEqual([]);\n // });\n\n test('should remove trailing and leading new lines within block level elements', () => {\n const result = formatStringToHtml('[h1]\\n\\n\\nLine 1\\n\\n\\n[/h1]', {\n parseBBCode: true,\n });\n expect(result.html).toEqual('<p><h1>Line 1</h1></p>');\n expect(result.tables).toEqual([]);\n });\n });\n });\n\n test('should not format url in tag attributes', () => {\n const result = formatStringToHtml(\n '[link url=\"https://www.google.com\"]Google[/link]',\n {\n parseBBCode: true,\n customInlineLevelBBCodeTags: ['link'],\n },\n );\n expect(result.html).toEqual(\n '<p><bb-code-link url=\"https://www.google.com\">Google</bb-code-link></p>',\n );\n expect(result.tables).toEqual([]);\n });\n\n test('should apply style attribute correctly', () => {\n const result = formatStringToHtml('[span style=\"color: red;\"]red text[/span]', {\n parseBBCode: true,\n });\n expect(result.html).toEqual('<p><span style=\"color: red;\">red text</span></p>');\n expect(result.tables).toEqual([]);\n });\n\n test('should format nested elements correctly', () => {\n const result = formatStringToHtml('[b][i]bold italic[/i][/b]', {\n parseBBCode: true,\n });\n expect(result.html).toEqual('<p><b><i>bold italic</i></b></p>');\n expect(result.tables).toEqual([]);\n });\n });\n });\n\n describe('Combined Formatting (Markdown + BB-Code)', () => {\n test('should format bb-code within markdown correctly', () => {\n const result = formatStringToHtml('*[b]bold[/b]*', {\n parseBBCode: true,\n });\n expect(result.html).toEqual('<p><em><b>bold</b></em></p>');\n expect(result.tables).toEqual([]);\n });\n\n test('should format markdown within bb-code correctly', () => {\n const result = formatStringToHtml('[b]*bold*[/b]', {\n parseBBCode: true,\n });\n expect(result.html).toEqual('<p><b><em>bold</em></b></p>');\n expect(result.tables).toEqual([]);\n });\n });\n});\n"],"mappings":"AAAA,SAASA,QAAQ,EAAEC,MAAM,EAAEC,IAAI,QAAQ,QAAQ;AAC/C,SAASC,kBAAkB,QAAQ,gBAAgB;AAEnD,MAAMC,gBAAgB,GAAIC,IAAY,IAAKA,IAAI,CAACC,OAAO,CAAC,KAAK,EAAE,EAAE,CAAC;AAElEN,QAAQ,CAAC,yBAAyB,EAAE,MAAM;EACtCA,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M,GAAGJ,kBAAkB,CAAC,eAAe,EAAE;QAC/CmC,WAAW,EAAE;MACjB,CAAC,CAAC;MACFrC,MAAM,CAACM,MAAM,CAACC,IAAI,CAAC,CAACC,OAAO,CAAC,6BAA6B,CAAC;MAC1DR,MAAM,CAACM,MAAM,CAACG,MAAM,CAAC,CAACD,OAAO,CAAC,EAAE,CAAC;IACrC,CAAC,CAAC;IAEFP,IAAI,CAAC,iDAAiD,EAAE,MAAM;MAC1D,MAAMK,MAAM,GAAGJ,kBAAkB,CAAC,eAAe,EAAE;QAC/CmC,WAAW,EAAE;MACjB,CAAC,CAAC;MACFrC,MAAM,CAACM,MAAM,CAACC,IAAI,CAAC,CAACC,OAAO,CAAC,6BAA6B,CAAC;MAC1DR,MAAM,CAACM,MAAM,CAACG,MAAM,CAAC,CAACD,OAAO,CAAC,EAAE,CAAC;IACrC,CAAC,CAAC;EACN,CAAC,CAAC;AACN,CAAC,CAAC","ignoreList":[]}
|
|
1
|
+
{"version":3,"file":"formatString.test.js","names":["describe","expect","test","formatStringToHtml","removeLinebreaks","text","replace","result","html","toEqual","tables","resultEscape","resultEscape1","resultEscape2","boldResult","italicResult","inlineCodeResult","h1Result","h2Result","h3Result","h4Result","h5Result","h6Result","expectedUnorderedListResult","expectedOrderedListResult","unorderedListResult1","unorderedListResult2","orderedListResult","orderedListResult2","expectedThematicBreakResult","result1","result2","resultWithoutLanguage","resultWithLanguage","inputString","csv","raw","id","parseBBCode","table1","getTable1Result","index","table1Csv","table2","getTable2TResult","table2Csv","getHeadingInput","tag","getHeadingOutput","headingTags","forEach","input","output","customInlineLevelBBCodeTags","customBlockLevelBBCodeTags"],"sources":["../../../../src/utils/formatString/formatString.test.ts"],"sourcesContent":["import { describe, expect, test } from 'vitest';\nimport { formatStringToHtml } from './formatString';\n\nconst removeLinebreaks = (text: string) => text.replace(/\\n/g, '');\n\ndescribe('HTML Formatter Function', () => {\n describe('Format Plain Text', () => {\n describe('Line breaks', () => {\n test('should format line breaks correctly', () => {\n const result = formatStringToHtml('Line 1\\nLine 2');\n expect(result.html).toEqual('<p>Line 1\\nLine 2</p>');\n expect(result.tables).toEqual([]);\n });\n\n test('should format multiple line breaks correctly', () => {\n const result = formatStringToHtml('Line 1\\n\\nLine 2');\n expect(result.html).toEqual('<p>Line 1</p>\\n<p>Line 2</p>');\n expect(result.tables).toEqual([]);\n });\n\n test('should remove trailing and leading new lines', () => {\n const result = formatStringToHtml('\\n\\n\\nLine 1\\n\\n\\n');\n expect(result.html).toEqual('<p>Line 1</p>');\n expect(result.tables).toEqual([]);\n });\n });\n\n describe('Whitespaces', () => {\n test('should not remove repeated whitespaces', () => {\n const result = formatStringToHtml('Text with spaces');\n expect(result.html).toEqual('<p>Text with spaces</p>');\n expect(result.tables).toEqual([]);\n });\n\n test('should not remove leading and trailing whitespaces', () => {\n const result = formatStringToHtml(' Text ');\n expect(result.html).toEqual('<p> Text </p>');\n expect(result.tables).toEqual([]);\n });\n });\n\n describe('HTML', () => {\n test('should escape < and > correctly', () => {\n const resultEscape = formatStringToHtml('<div>Test</div>');\n expect(resultEscape.html).toEqual('<p><div>Test</div></p>');\n expect(resultEscape.tables).toEqual([]);\n });\n\n test('should not escape &', () => {\n const resultEscape1 = formatStringToHtml('<div>Test</div>');\n expect(resultEscape1.html).toEqual('<p><div>Test</div></p>');\n expect(resultEscape1.tables).toEqual([]);\n\n const resultEscape2 = formatStringToHtml(\n '&lt;div&gt;Test&lt;/div&gt;',\n );\n expect(resultEscape2.html).toEqual(\n '<p>&lt;div&gt;Test&lt;/div&gt;</p>',\n );\n expect(resultEscape2.tables).toEqual([]);\n });\n\n // TODO Decide if & should be escaped, when they are not part of an HTML entity.\n });\n\n describe('URLs', () => {\n test('should not format URLs', () => {\n const result = formatStringToHtml('https://example.com');\n expect(result.html).toEqual('<p>https://example.com</p>');\n expect(result.tables).toEqual([]);\n });\n });\n });\n\n describe('Format Markdown', () => {\n describe('All Elements', () => {\n test('should format text styling correctly', () => {\n const boldResult = formatStringToHtml('**bold**');\n expect(boldResult.html).toEqual('<p><strong>bold</strong></p>');\n expect(boldResult.tables).toEqual([]);\n\n const italicResult = formatStringToHtml('*italic*');\n expect(italicResult.html).toEqual('<p><em>italic</em></p>');\n expect(italicResult.tables).toEqual([]);\n\n const inlineCodeResult = formatStringToHtml('`inline code`');\n expect(inlineCodeResult.html).toEqual('<p><code>inline code</code></p>');\n expect(inlineCodeResult.tables).toEqual([]);\n });\n\n test('should format headings correctly', () => {\n const h1Result = formatStringToHtml('# h1');\n expect(h1Result.html).toEqual('<h1>h1</h1>');\n expect(h1Result.tables).toEqual([]);\n\n const h2Result = formatStringToHtml('## h2');\n expect(h2Result.html).toEqual('<h2>h2</h2>');\n expect(h2Result.tables).toEqual([]);\n\n const h3Result = formatStringToHtml('### h3');\n expect(h3Result.html).toEqual('<h3>h3</h3>');\n expect(h3Result.tables).toEqual([]);\n\n const h4Result = formatStringToHtml('#### h4');\n expect(h4Result.html).toEqual('<h4>h4</h4>');\n expect(h4Result.tables).toEqual([]);\n\n const h5Result = formatStringToHtml('##### h5');\n expect(h5Result.html).toEqual('<h5>h5</h5>');\n expect(h5Result.tables).toEqual([]);\n\n const h6Result = formatStringToHtml('###### h6');\n expect(h6Result.html).toEqual('<h6>h6</h6>');\n expect(h6Result.tables).toEqual([]);\n });\n\n test('should format links correctly', () => {\n const result = formatStringToHtml('[Link](https://example.com)');\n expect(result.html).toEqual('<p><a href=\"https://example.com\">Link</a></p>');\n expect(result.tables).toEqual([]);\n });\n\n test('should format images correctly', () => {\n const result = formatStringToHtml('');\n expect(result.html).toEqual(\n '<p><img src=\"https://example.com/image.jpg\" alt=\"Alt Text\"></p>',\n );\n expect(result.tables).toEqual([]);\n });\n\n test('should format lists correctly', () => {\n const expectedUnorderedListResult =\n '<ul>\\n<li>Item 1</li>\\n<li>Item 2</li>\\n<li>Item 3</li>\\n</ul>';\n const expectedOrderedListResult =\n '<ol>\\n<li>Item 1</li>\\n<li>Item 2</li>\\n<li>Item 3</li>\\n</ol>';\n\n const unorderedListResult1 = formatStringToHtml('- Item 1\\n- Item 2\\n- Item 3');\n expect(unorderedListResult1.html).toEqual(expectedUnorderedListResult);\n expect(unorderedListResult1.tables).toEqual([]);\n\n const unorderedListResult2 = formatStringToHtml('* Item 1\\n* Item 2\\n* Item 3');\n expect(unorderedListResult2.html).toEqual(expectedUnorderedListResult);\n expect(unorderedListResult2.tables).toEqual([]);\n\n const orderedListResult = formatStringToHtml('1. Item 1\\n2. Item 2\\n3. Item 3');\n expect(orderedListResult.html).toEqual(expectedOrderedListResult);\n expect(orderedListResult.tables).toEqual([]);\n\n const orderedListResult2 = formatStringToHtml('1) Item 1\\n2) Item 2\\n3) Item 3');\n expect(orderedListResult2.html).toEqual(expectedOrderedListResult);\n expect(orderedListResult2.tables).toEqual([]);\n });\n\n test('should format thematic breaks correctly', () => {\n const expectedThematicBreakResult = '<hr>';\n\n const result1 = formatStringToHtml('---');\n expect(result1.html).toEqual(expectedThematicBreakResult);\n expect(result1.tables).toEqual([]);\n\n const result2 = formatStringToHtml('***');\n expect(result2.html).toEqual(expectedThematicBreakResult);\n expect(result2.tables).toEqual([]);\n });\n\n test('should format code blocks correctly', () => {\n const resultWithoutLanguage = formatStringToHtml('```\\nconst a = 1;\\n```');\n expect(resultWithoutLanguage.html).toEqual('<pre><code>const a = 1;</code></pre>');\n expect(resultWithoutLanguage.tables).toEqual([]);\n\n const resultWithLanguage = formatStringToHtml('```js\\nconst a = 1;\\n```');\n expect(resultWithLanguage.html).toEqual(\n '<pre><code class=\"language-js\">const a = 1;</code></pre>',\n );\n expect(resultWithLanguage.tables).toEqual([]);\n });\n\n test('should format tables correctly', () => {\n const inputString =\n '| Header 1 | Header 2 |\\n|----------|----------|\\n| Cell 1 | Cell 2 |';\n const result = formatStringToHtml(inputString);\n expect(removeLinebreaks(result.html)).toEqual(\n '<table id=\"formatted-table-0\"><thead><tr><th>Header 1</th><th>Header 2</th></tr></thead><tbody><tr><td>Cell 1</td><td>Cell 2</td></tr></tbody></table>',\n );\n expect(result.tables).toEqual([\n {\n csv: 'Header 1,Header 2\\nCell 1,Cell 2\\n',\n raw: inputString,\n id: 'formatted-table-0',\n },\n ]);\n });\n });\n\n describe('Inline Code', () => {\n describe('HTML In Code', () => {\n test('should escape < and > within inline code correctly', () => {\n const result1 = formatStringToHtml('`<div>Test</div>`');\n expect(result1.html).toEqual('<p><code><div>Test</div></code></p>');\n expect(result1.tables).toEqual([]);\n });\n\n test('should not escape & within inline code', () => {\n const resultEscape1 = formatStringToHtml('`<div>Test</div>`');\n expect(resultEscape1.html).toEqual(\n '<p><code><div>Test</div></code></p>',\n );\n expect(resultEscape1.tables).toEqual([]);\n\n const resultEscape2 = formatStringToHtml(\n '`&lt;div&gt;Test&lt;/div&gt;`',\n );\n expect(resultEscape2.html).toEqual(\n '<p><code>&lt;div&gt;Test&lt;/div&gt;</code></p>',\n );\n expect(resultEscape2.tables).toEqual([]);\n });\n });\n\n test('should not format markdown within inline code', () => {\n const result = formatStringToHtml('`**bold** *italic*`');\n expect(result.html).toEqual('<p><code>**bold** *italic*</code></p>');\n expect(result.tables).toEqual([]);\n });\n\n test('should not format bb-code within inline code', () => {\n const result = formatStringToHtml('`[b]bold[/b]`', { parseBBCode: true });\n expect(result.html).toEqual('<p><code>[b]bold[/b]</code></p>');\n expect(result.tables).toEqual([]);\n });\n });\n\n describe('Codeblock', () => {\n test('should format code blocks with multiple lines correctly', () => {\n const resultWithoutLanguage = formatStringToHtml(\n '```\\nconst a = 1;\\nconst b = 2;\\n```',\n );\n expect(resultWithoutLanguage.html).toEqual(\n '<pre><code>const a = 1;\\nconst b = 2;</code></pre>',\n );\n expect(resultWithoutLanguage.tables).toEqual([]);\n\n const resultWithLanguage = formatStringToHtml(\n '```js\\nconst a = 1;\\nconst b = 2;\\n```',\n );\n expect(resultWithLanguage.html).toEqual(\n '<pre><code class=\"language-js\">const a = 1;\\nconst b = 2;</code></pre>',\n );\n expect(resultWithLanguage.tables).toEqual([]);\n });\n\n test('should not format 4 spaces as code block', () => {\n const result = formatStringToHtml(' const a = 1;');\n expect(result.html).toEqual('<p> const a = 1;</p>');\n expect(result.tables).toEqual([]);\n });\n\n describe('HTML In Code', () => {\n test('should escape < and > within code block', () => {\n const resultWithoutLanguage = formatStringToHtml('```\\n<div>Test</div>\\n```');\n expect(resultWithoutLanguage.html).toEqual(\n '<pre><code><div>Test</div></code></pre>',\n );\n expect(resultWithoutLanguage.tables).toEqual([]);\n\n const resultWithLanguage = formatStringToHtml('```html\\n<div>Test</div>\\n```');\n expect(resultWithLanguage.html).toEqual(\n '<pre><code class=\"language-html\"><div>Test</div></code></pre>',\n );\n expect(resultWithLanguage.tables).toEqual([]);\n });\n\n test('should not escape & within code block', () => {\n const resultEscape1 = formatStringToHtml(\n '```\\n<div>Test</div>\\n```',\n );\n expect(resultEscape1.html).toEqual(\n '<pre><code><div>Test</div></code></pre>',\n );\n expect(resultEscape1.tables).toEqual([]);\n\n const resultEscape2 = formatStringToHtml(\n '```\\n&lt;div&gt;Test&lt;/div&gt;\\n```',\n );\n expect(resultEscape2.html).toEqual(\n '<pre><code>&lt;div&gt;Test&lt;/div&gt;</code></pre>',\n );\n expect(resultEscape2.tables).toEqual([]);\n });\n });\n\n test('should not format markdown within code block', () => {\n const resultWithoutLanguage = formatStringToHtml('```\\n**Test**\\n```');\n expect(resultWithoutLanguage.html).toEqual('<pre><code>**Test**</code></pre>');\n expect(resultWithoutLanguage.tables).toEqual([]);\n\n const resultWithLanguage = formatStringToHtml('```html\\n**Test**\\n```');\n expect(resultWithLanguage.html).toEqual(\n '<pre><code class=\"language-html\">**Test**</code></pre>',\n );\n expect(resultWithLanguage.tables).toEqual([]);\n });\n\n test('should not format bb-code within code block', () => {\n const resultWithoutLanguage = formatStringToHtml('```\\n[b]Test[/b]\\n```');\n expect(resultWithoutLanguage.html).toEqual('<pre><code>[b]Test[/b]</code></pre>');\n expect(resultWithoutLanguage.tables).toEqual([]);\n\n const resultWithLanguage = formatStringToHtml('```html\\n[b]Test[/b]\\n```');\n expect(resultWithLanguage.html).toEqual(\n '<pre><code class=\"language-html\">[b]Test[/b]</code></pre>',\n );\n expect(resultWithLanguage.tables).toEqual([]);\n });\n });\n\n describe('Table', () => {\n test('should format markdown within table correctly', () => {\n const inputString =\n '| Header 1 | Header 2 |\\n|----------|----------|\\n| **Cell 1** | *Cell 2* |';\n const result = formatStringToHtml(inputString);\n expect(removeLinebreaks(result.html)).toEqual(\n '<table id=\"formatted-table-0\"><thead><tr><th>Header 1</th><th>Header 2</th></tr></thead><tbody><tr><td><strong>Cell 1</strong></td><td><em>Cell 2</em></td></tr></tbody></table>',\n );\n expect(result.tables).toEqual([\n {\n csv: 'Header 1,Header 2\\n**Cell 1**,*Cell 2*\\n',\n raw: inputString,\n id: 'formatted-table-0',\n },\n ]);\n });\n\n test('should format bb-code within table correctly', () => {\n const inputString =\n '| Header 1 | Header 2 |\\n|----------|----------|\\n| [b]Cell 1[/b] | [i]Cell 2[/i] |';\n const result = formatStringToHtml(inputString, {\n parseBBCode: true,\n });\n expect(removeLinebreaks(result.html)).toEqual(\n '<table id=\"formatted-table-0\"><thead><tr><th>Header 1</th><th>Header 2</th></tr></thead><tbody><tr><td><b>Cell 1</b></td><td><i>Cell 2</i></td></tr></tbody></table>',\n );\n expect(result.tables).toEqual([\n {\n csv: 'Header 1,Header 2\\n[b]Cell 1[/b],[i]Cell 2[/i]\\n',\n raw: inputString,\n id: 'formatted-table-0',\n },\n ]);\n });\n\n test('should format html within table correctly', () => {\n const inputString =\n '| Header 1 | Header 2 | Header 3 |\\n|----------|----------|----------|\\n| <div>Cell 1</div> | <div>Cell 2</div> | &lt;div&gt;Cell 3&lt;/div&gt; |';\n const result = formatStringToHtml(inputString, {\n parseBBCode: true,\n });\n expect(removeLinebreaks(result.html)).toEqual(\n '<table id=\"formatted-table-0\"><thead><tr><th>Header 1</th><th>Header 2</th><th>Header 3</th></tr></thead><tbody><tr><td><div>Cell 1</div></td><td><div>Cell 2</div></td><td>&lt;div&gt;Cell 3&lt;/div&gt;</td></tr></tbody></table>',\n );\n expect(result.tables).toEqual([\n {\n csv: 'Header 1,Header 2,Header 3\\n<div>Cell 1</div>,<div>Cell 2</div>,<div>Cell 3</div>\\n',\n raw: '| Header 1 | Header 2 | Header 3 |\\n|----------|----------|----------|\\n| <div>Cell 1</div> | <div>Cell 2</div> | <div>Cell 3</div> |',\n id: 'formatted-table-0',\n },\n ]);\n });\n\n test('should format multiple tables correctly', () => {\n const table1 =\n '| Header 1 | Header 2 |\\n|----------|----------|\\n| Cell 1 | Cell 2 |';\n const getTable1Result = (index: number) =>\n `<table id=\"formatted-table-${index}\"><thead><tr><th>Header 1</th><th>Header 2</th></tr></thead><tbody><tr><td>Cell 1</td><td>Cell 2</td></tr></tbody></table>`;\n const table1Csv = 'Header 1,Header 2\\nCell 1,Cell 2\\n';\n const table2 =\n '| Header 3 | Header 4 |\\n|----------|----------|\\n| Cell 3 | Cell 4 |';\n const getTable2TResult = (index: number) =>\n `<table id=\"formatted-table-${index}\"><thead><tr><th>Header 3</th><th>Header 4</th></tr></thead><tbody><tr><td>Cell 3</td><td>Cell 4</td></tr></tbody></table>`;\n const table2Csv = 'Header 3,Header 4\\nCell 3,Cell 4\\n';\n\n const result1 = formatStringToHtml(`${table1}\\n\\n${table2}`);\n expect(removeLinebreaks(result1.html)).toEqual(\n `${getTable1Result(0)}${getTable2TResult(1)}`,\n );\n expect(result1.tables).toEqual([\n {\n csv: table1Csv,\n raw: `${table1}\\n\\n`,\n id: 'formatted-table-0',\n },\n {\n csv: table2Csv,\n raw: table2,\n id: 'formatted-table-1',\n },\n ]);\n\n // Tables in reverse order.\n const result2 = formatStringToHtml(`${table2}\\n\\n${table1}`);\n expect(removeLinebreaks(result2.html)).toEqual(\n `${getTable2TResult(0)}${getTable1Result(1)}`,\n );\n expect(result2.tables).toEqual([\n {\n csv: table2Csv,\n raw: `${table2}\\n\\n`,\n id: 'formatted-table-0',\n },\n {\n csv: table1Csv,\n raw: table1,\n id: 'formatted-table-1',\n },\n ]);\n });\n });\n\n describe('List', () => {\n test('should format markdown within list correctly', () => {\n const result = formatStringToHtml('- **Item 1**\\n- *Item 2*');\n expect(removeLinebreaks(result.html)).toEqual(\n '<ul><li><strong>Item 1</strong></li><li><em>Item 2</em></li></ul>',\n );\n expect(result.tables).toEqual([]);\n });\n\n test('should format task lists correctly', () => {\n const result1 = formatStringToHtml('- [ ] 1\\n- [x] 2\\n- [X] 3');\n expect(removeLinebreaks(result1.html)).toEqual(\n '<ul><li>[ ] 1</li><li>[x] 2</li><li>[x] 3</li></ul>',\n );\n expect(result1.tables).toEqual([]);\n });\n });\n\n describe('Combined Elements', () => {\n test('should format code block within list correctly', () => {\n const result = formatStringToHtml('* test\\n ```\\n test\\n ```');\n expect(removeLinebreaks(result.html)).toEqual(\n '<ul><li>test<pre><code>test</code></pre></li></ul>',\n );\n expect(result.tables).toEqual([]);\n });\n });\n\n describe('Conflicts with BB-Code', () => {\n test('should not format bb code tag followed by paranthese to link', () => {\n const result = formatStringToHtml('[b]bold[/b](test)', { parseBBCode: true });\n expect(result.html).toEqual('<p><b>bold</b>(test)</p>');\n expect(result.tables).toEqual([]);\n });\n });\n });\n\n describe('Format BB-Code', () => {\n describe('All Elements', () => {\n describe('Inline Elements', () => {\n // b, strong, i, em, u, s, span, img\n test('should format b tag correctly', () => {\n const result = formatStringToHtml('[b]bold[/b]', {\n parseBBCode: true,\n });\n expect(result.html).toEqual('<p><b>bold</b></p>');\n expect(result.tables).toEqual([]);\n });\n\n test('should format strong tag correctly', () => {\n const result = formatStringToHtml('[strong]bold[/strong]', {\n parseBBCode: true,\n });\n expect(result.html).toEqual('<p><strong>bold</strong></p>');\n expect(result.tables).toEqual([]);\n });\n\n test('should format i tag correctly', () => {\n const result = formatStringToHtml('[i]italic[/i]', {\n parseBBCode: true,\n });\n expect(result.html).toEqual('<p><i>italic</i></p>');\n expect(result.tables).toEqual([]);\n });\n\n test('should format em tag correctly', () => {\n const result = formatStringToHtml('[em]italic[/em]', {\n parseBBCode: true,\n });\n expect(result.html).toEqual('<p><em>italic</em></p>');\n expect(result.tables).toEqual([]);\n });\n\n test('should format u tag correctly', () => {\n const result = formatStringToHtml('[u]underline[/u]', {\n parseBBCode: true,\n });\n expect(result.html).toEqual('<p><u>underline</u></p>');\n expect(result.tables).toEqual([]);\n });\n\n test('should format s tag correctly', () => {\n const result = formatStringToHtml('[s]strike[/s]', {\n parseBBCode: true,\n });\n expect(result.html).toEqual('<p><s>strike</s></p>');\n expect(result.tables).toEqual([]);\n });\n\n test('should format span tag correctly', () => {\n const result = formatStringToHtml('[span]span[/span]', {\n parseBBCode: true,\n });\n expect(result.html).toEqual('<p><span>span</span></p>');\n expect(result.tables).toEqual([]);\n });\n\n test('should format img tag correctly', () => {\n const result = formatStringToHtml(\n '[img src=\"https://example.com/image.jpg\"][/img]',\n {\n parseBBCode: true,\n },\n );\n expect(result.html).toEqual('<p><img src=\"https://example.com/image.jpg\"></p>');\n expect(result.tables).toEqual([]);\n });\n });\n\n describe('Block Level Elements', () => {\n test('should format center tag correctly', () => {\n const result = formatStringToHtml('[center]centered text[/center]', {\n parseBBCode: true,\n });\n expect(result.html).toEqual('<p><center>centered text</center></p>');\n expect(result.tables).toEqual([]);\n });\n\n test('should format ul tag correctly', () => {\n const result = formatStringToHtml('[ul][li]Item 1[/li][li]Item 2[/li][/ul]', {\n parseBBCode: true,\n });\n expect(result.html).toEqual('<p><ul><li>Item 1</li><li>Item 2</li></ul></p>');\n expect(result.tables).toEqual([]);\n });\n\n test('should format ol tag correctly', () => {\n const result = formatStringToHtml('[ol][li]Item 1[/li][li]Item 2[/li][/ol]', {\n parseBBCode: true,\n });\n expect(result.html).toEqual('<p><ol><li>Item 1</li><li>Item 2</li></ol></p>');\n expect(result.tables).toEqual([]);\n });\n\n test('should format li tag correctly', () => {\n const result = formatStringToHtml('[li]Item[/li]', {\n parseBBCode: true,\n });\n expect(result.html).toEqual('<p><li>Item</li></p>');\n expect(result.tables).toEqual([]);\n });\n\n test('should format heading tags correctly', () => {\n const getHeadingInput = (tag: string) => `[${tag}]${tag}[/${tag}]`;\n const getHeadingOutput = (tag: string) => `<p><${tag}>${tag}</${tag}></p>`;\n const headingTags = ['h1', 'h2', 'h3', 'h4', 'h5', 'h6'];\n\n headingTags.forEach((tag) => {\n const result = formatStringToHtml(getHeadingInput(tag), {\n parseBBCode: true,\n });\n expect(result.html).toEqual(getHeadingOutput(tag));\n expect(result.tables).toEqual([]);\n });\n });\n\n test('should format p tag correctly', () => {\n const result = formatStringToHtml('[p]paragraph[/p]', {\n parseBBCode: true,\n });\n expect(result.html).toEqual('<p><p>paragraph</p></p>');\n expect(result.tables).toEqual([]);\n });\n });\n\n describe('Custom Elements', () => {\n test('should format custom tags correctly', () => {\n const input = '[custom attribute1=\"test1\" attribute2=\"test2\"]custom[/custom]';\n const output =\n '<p><bb-code-custom attribute1=\"test1\" attribute2=\"test2\">custom</bb-code-custom></p>';\n const result1 = formatStringToHtml(input, {\n parseBBCode: true,\n customInlineLevelBBCodeTags: ['custom'],\n });\n expect(result1.html).toEqual(output);\n expect(result1.tables).toEqual([]);\n\n const result2 = formatStringToHtml(input, {\n parseBBCode: true,\n customBlockLevelBBCodeTags: ['custom'],\n });\n expect(result2.html).toEqual(output);\n expect(result2.tables).toEqual([]);\n });\n\n test('should not format unknown custom tags', () => {\n const result = formatStringToHtml('[unknown]unknown[/unknown]', {\n parseBBCode: true,\n });\n expect(result.html).toEqual('<p>[unknown]unknown[/unknown]</p>');\n expect(result.tables).toEqual([]);\n });\n });\n\n describe('Line breaks', () => {\n describe('Between Elements', () => {\n test('should format line breaks between block level elements correctly', () => {\n const result1 = formatStringToHtml('[h1]h1[/h1]\\n[h2]h2[/h2]', {\n parseBBCode: true,\n });\n expect(result1.html).toEqual('<p><h1>h1</h1><h2>h2</h2></p>');\n expect(result1.tables).toEqual([]);\n\n const result2 = formatStringToHtml('[h1]h1[/h1]\\n\\n[h2]h2[/h2]', {\n parseBBCode: true,\n });\n expect(result2.html).toEqual('<p><h1>h1</h1></p>\\n<p><h2>h2</h2></p>');\n expect(result2.tables).toEqual([]);\n });\n\n test('should format line breaks between inline elements correctly', () => {\n const result1 = formatStringToHtml('[b]bold[/b]\\n[i]italic[/i]', {\n parseBBCode: true,\n });\n expect(result1.html).toEqual('<p><b>bold</b>\\n<i>italic</i></p>');\n expect(result1.tables).toEqual([]);\n\n const result2 = formatStringToHtml('[b]bold[/b]\\n\\n[i]italic[/i]', {\n parseBBCode: true,\n });\n expect(result2.html).toEqual('<p><b>bold</b></p>\\n<p><i>italic</i></p>');\n expect(result2.tables).toEqual([]);\n });\n });\n\n describe('Within Elements', () => {\n test('should format line breaks within block level elements correctly', () => {\n const result = formatStringToHtml('[h1]Line 1\\nLine 2[/h1]', {\n parseBBCode: true,\n });\n expect(result.html).toEqual('<p><h1>Line 1\\nLine 2</h1></p>');\n expect(result.tables).toEqual([]);\n });\n\n // This is a test that would fail!\n // test('should format multiple line breaks within block level elements correctly', () => {\n // const result = formatStringToHtml('[h1]Line 1\\n\\nLine 2[/h1]', {\n // parseBBCode: true,\n // });\n // expect(result.html).toEqual('<p><h1>Line 1\\nLine 2</h1></p>');\n // expect(result.tables).toEqual([]);\n // });\n\n test('should remove trailing and leading new lines within block level elements', () => {\n const result = formatStringToHtml('[h1]\\n\\n\\nLine 1\\n\\n\\n[/h1]', {\n parseBBCode: true,\n });\n expect(result.html).toEqual('<p><h1>Line 1</h1></p>');\n expect(result.tables).toEqual([]);\n });\n });\n });\n\n test('should not format url in tag attributes', () => {\n const result = formatStringToHtml(\n '[link url=\"https://www.google.com\"]Google[/link]',\n {\n parseBBCode: true,\n customInlineLevelBBCodeTags: ['link'],\n },\n );\n expect(result.html).toEqual(\n '<p><bb-code-link url=\"https://www.google.com\">Google</bb-code-link></p>',\n );\n expect(result.tables).toEqual([]);\n });\n\n test('should apply style attribute correctly', () => {\n const result = formatStringToHtml('[span style=\"color: red;\"]red text[/span]', {\n parseBBCode: true,\n });\n expect(result.html).toEqual('<p><span style=\"color: red;\">red text</span></p>');\n expect(result.tables).toEqual([]);\n });\n\n test('should format nested elements correctly', () => {\n const result = formatStringToHtml('[b][i]bold italic[/i][/b]', {\n parseBBCode: true,\n });\n expect(result.html).toEqual('<p><b><i>bold italic</i></b></p>');\n expect(result.tables).toEqual([]);\n });\n });\n });\n\n describe('Combined Formatting (Markdown + BB-Code)', () => {\n test('should format bb-code within markdown correctly', () => {\n const result = formatStringToHtml('*[b]bold[/b]*', {\n parseBBCode: true,\n });\n expect(result.html).toEqual('<p><em><b>bold</b></em></p>');\n expect(result.tables).toEqual([]);\n });\n\n test('should format markdown within bb-code correctly', () => {\n const result = formatStringToHtml('[b]*bold*[/b]', {\n parseBBCode: true,\n });\n expect(result.html).toEqual('<p><b><em>bold</em></b></p>');\n expect(result.tables).toEqual([]);\n });\n });\n});\n"],"mappings":"AAAA,SAASA,QAAQ,EAAEC,MAAM,EAAEC,IAAI,QAAQ,QAAQ;AAC/C,SAASC,kBAAkB,QAAQ,gBAAgB;AAEnD,MAAMC,gBAAgB,GAAIC,IAAY,IAAKA,IAAI,CAACC,OAAO,CAAC,KAAK,EAAE,EAAE,CAAC;AAElEN,QAAQ,CAAC,yBAAyB,EAAE,MAAM;EACtCA,QAAQ,CAAC,mBAAmB,EAAE,MAAM;IAChCA,QAAQ,CAAC,aAAa,EAAE,MAAM;MAC1BE,IAAI,CAAC,qCAAqC,EAAE,MAAM;QAC9C,MAAMK,MAAM,GAAGJ,kBAAkB,CAAC,gBAAgB,CAAC;QACnDF,MAAM,CAACM,MAAM,CAACC,IAAI,CAAC,CAACC,OAAO,CAAC,uBAAuB,CAAC;QACpDR,MAAM,CAACM,MAAM,CAACG,MAAM,CAAC,CAACD,OAAO,CAAC,EAAE,CAAC;MACrC,CAAC,CAAC;MAEFP,IAAI,CAAC,8CAA8C,EAAE,MAAM;QACvD,MAAMK,MAAM,GAAGJ,kBAAkB,CAAC,kBAAkB,CAAC;QAC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MAAM,CAACG,MAAM,CAAC,CAACD,OAAO,CAAC,EAAE,CAAC;IACrC,CAAC,CAAC;IAEFP,IAAI,CAAC,iDAAiD,EAAE,MAAM;MAC1D,MAAMK,MAAM,GAAGJ,kBAAkB,CAAC,eAAe,EAAE;QAC/CmC,WAAW,EAAE;MACjB,CAAC,CAAC;MACFrC,MAAM,CAACM,MAAM,CAACC,IAAI,CAAC,CAACC,OAAO,CAAC,6BAA6B,CAAC;MAC1DR,MAAM,CAACM,MAAM,CAACG,MAAM,CAAC,CAACD,OAAO,CAAC,EAAE,CAAC;IACrC,CAAC,CAAC;EACN,CAAC,CAAC;AACN,CAAC,CAAC","ignoreList":[]}
|
|
@@ -31,12 +31,18 @@ const tokenizer = {
|
|
|
31
31
|
}
|
|
32
32
|
return undefined;
|
|
33
33
|
},
|
|
34
|
+
// Disables Markdown formatting for setext headings.
|
|
34
35
|
lheading() {
|
|
35
36
|
return undefined;
|
|
36
37
|
},
|
|
38
|
+
// Disables converting urls to hyperlinks.
|
|
37
39
|
url() {
|
|
38
40
|
return undefined;
|
|
39
41
|
},
|
|
42
|
+
// Disables converting text with 4 leading spaces to code block.
|
|
43
|
+
code() {
|
|
44
|
+
return undefined;
|
|
45
|
+
},
|
|
40
46
|
// inlineText is overwritten to prevent html escaping, specifically since quote characters are escaped, which breaks the attributes of bb-code elements.
|
|
41
47
|
// The function is copied from marked.js and slightly modified: https://github.com/markedjs/marked/blob/42954aaba960b6f815b24ec0d39da464960e4ec9/src/Tokenizer.ts#L854
|
|
42
48
|
inlineText(src) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"formatMarkdown.js","names":["marked","stringify","escapeBBCodeSquareBrackets","inlineCodeRule","inlineTextRule","TABLE_ID_PREFIX","tokenizer","codespan","src","cap","exec","text","replace","hasNonSpaceChars","test","hasSpaceCharsOnBothEnds","substring","length","type","raw","undefined","lheading","url","inlineText","renderer","code","lang","langString","match","checkbox","_ref","checked","postprocess","html","tableIndex","modifiedString","result","use","hooks","parseMarkdown","parseBBCode","parse","walkTokens","token","unescapeHtml","replaceAll","getMarkdownTables","tableTokens","push","tables","forEach","tableToken","index","tableArray","header","rowArray","rows","row","cell","csv","id"],"sources":["../../../../../src/utils/formatString/markdown/formatMarkdown.ts"],"sourcesContent":["import { marked, Tokens } from 'marked';\nimport type { TableObject } from '../../../types/format';\n// eslint-disable-next-line import/extensions,import/no-unresolved\nimport { stringify } from 'csv-stringify/browser/esm/sync';\nimport { escapeBBCodeSquareBrackets } from '../bb-code/formatBBCode';\n\nconst inlineCodeRule = /^(`+)([^`]|[^`][\\s\\S]*?[^`])\\1(?!`)/;\nconst inlineTextRule = /^(`+|[^`])(?:(?= {2,}\\n)|[\\s\\S]*?(?:(?=[\\\\<![`*_]|\\b_|$)|[^ ](?= {2,}\\n)))/;\n\nconst TABLE_ID_PREFIX = 'formatted-table-';\n\n/*\n The marked Pipeline, including tokenizer, renderer and hooks are explained here:\n https://marked.js.org/using_pro\n*/\n\nconst tokenizer = {\n // Codespan Tokenizer is overwritten to prevent html escaping, since html is already escaped.\n // The function is copied from marked.js and slightly modified: https://github.com/markedjs/marked/blob/42954aaba960b6f815b24ec0d39da464960e4ec9/src/Tokenizer.ts#L749\n codespan(src: string): Tokens.Codespan | undefined {\n const cap = inlineCodeRule.exec(src);\n if (cap) {\n let text = (cap[2] as string).replace(/\\n/g, ' ');\n const hasNonSpaceChars = /[^ ]/.test(text);\n const hasSpaceCharsOnBothEnds = /^ /.test(text) && / $/.test(text);\n if (hasNonSpaceChars && hasSpaceCharsOnBothEnds) {\n text = text.substring(1, text.length - 1);\n }\n\n return {\n type: 'codespan',\n raw: cap[0],\n text,\n };\n }\n\n return undefined;\n },\n lheading(): Tokens.Heading | undefined {\n return undefined;\n },\n url() {\n return undefined;\n },\n // inlineText is overwritten to prevent html escaping, specifically since quote characters are escaped, which breaks the attributes of bb-code elements.\n // The function is copied from marked.js and slightly modified: https://github.com/markedjs/marked/blob/42954aaba960b6f815b24ec0d39da464960e4ec9/src/Tokenizer.ts#L854\n inlineText(src: string) {\n const cap = inlineTextRule.exec(src);\n if (cap) {\n return {\n type: 'text',\n raw: cap[0],\n text: cap[0],\n };\n }\n return undefined;\n },\n};\n\nconst renderer = {\n // Code Renderer is overwritten to prevent html escaping, since html is already escaped.\n // The function is copied from marked.js and slightly modified: https://github.com/markedjs/marked/blob/42954aaba960b6f815b24ec0d39da464960e4ec9/src/Renderer.ts#L24\n code(text: string, lang: string): string {\n const langString = (lang || '').match(/^\\S*/)?.[0];\n\n const code = `${text.replace(/\\n$/, '')}`;\n\n if (!langString) {\n return `<pre><code>${code}</code></pre>\\n`;\n }\n\n return `<pre><code class=\"language-${langString}\">${code}</code></pre>\\n`;\n },\n // Replaces the checkbox input elements with markdown checkboxes.\n // This is the easiest way to prevent the formatting of markdown checkboxes in lists.\n // This can modify the input string slightly, since the capitalization of the checkbox can be lost.\n // If a user types '- [X]' it will be replaced with '- [x]' => the capitalization is lost.\n checkbox({ checked }: Tokens.Checkbox) {\n return checked ? '[x]' : '[ ]';\n },\n};\n\nconst postprocess = (html: string): string => {\n let tableIndex = 0;\n // Assigns ids to tables.\n const modifiedString = html.replace(/(<table>)/g, () => {\n const result = `<table id=\"${TABLE_ID_PREFIX}${tableIndex}\">`;\n tableIndex++;\n return result;\n });\n\n return modifiedString;\n};\n\n// eslint-disable-next-line @typescript-eslint/ban-ts-comment\n// @ts-ignore\nmarked.use({ tokenizer, renderer, hooks: { postprocess } });\n\n// Parses markdown following the Github Flavored Markdown specification.\n// The tokenizer and renderer are slightly modified to prevent html escaping in code block and inline code.\nexport const parseMarkdown = (text: string, parseBBCode: boolean) =>\n marked.parse(text, {\n walkTokens: (token) => {\n if (parseBBCode && (token.type === 'codespan' || token.type === 'code')) {\n // eslint-disable-next-line no-param-reassign\n (token as Tokens.Codespan).text = escapeBBCodeSquareBrackets(\n (token as Tokens.Codespan).text,\n );\n }\n },\n }) as string;\n\n// It is important that, & is replaced lastly to prevent double escaping.\nconst unescapeHtml = (text: string) =>\n text.replaceAll('<', '<').replaceAll('>', '>').replaceAll('&', '&');\n\nexport const getMarkdownTables = (text: string): TableObject[] => {\n const tableTokens: Tokens.Table[] = [];\n\n marked.parse(text, {\n walkTokens: (token) => {\n if (token.type === 'table') {\n tableTokens.push(token as Tokens.Table);\n }\n },\n }) as string;\n\n const tables: TableObject[] = [];\n\n tableTokens.forEach((tableToken, index) => {\n const tableArray: string[][] = [];\n\n if (tableToken.header?.length > 0) {\n const rowArray: string[] = [];\n\n tableToken.header.forEach((header) => {\n rowArray.push(unescapeHtml(header.text));\n });\n\n tableArray.push(rowArray);\n }\n if (tableToken.rows?.length > 0) {\n tableToken.rows.forEach((row) => {\n const rowArray: string[] = [];\n\n row.forEach((cell) => {\n rowArray.push(unescapeHtml(cell.text));\n });\n\n tableArray.push(rowArray);\n });\n }\n\n const csv = stringify(tableArray || []);\n\n tables.push({\n raw: unescapeHtml(tableToken.raw),\n csv,\n id: `${TABLE_ID_PREFIX}${index}`,\n });\n });\n\n return tables;\n};\n"],"mappings":"AAAA,SAASA,MAAM,QAAgB,QAAQ;AAEvC;AACA,SAASC,SAAS,QAAQ,gCAAgC;AAC1D,SAASC,0BAA0B,QAAQ,yBAAyB;AAEpE,MAAMC,cAAc,GAAG,qCAAqC;AAC5D,MAAMC,cAAc,GAAG,4EAA4E;AAEnG,MAAMC,eAAe,GAAG,kBAAkB;;AAE1C;AACA;AACA;AACA;;AAEA,MAAMC,SAAS,GAAG;EACd;EACA;EACAC,QAAQA,CAACC,GAAW,EAA+B;IAC/C,MAAMC,GAAG,GAAGN,cAAc,CAACO,IAAI,CAACF,GAAG,CAAC;IACpC,IAAIC,GAAG,EAAE;MACL,IAAIE,IAAI,GAAIF,GAAG,CAAC,CAAC,CAAC,CAAYG,OAAO,CAAC,KAAK,EAAE,GAAG,CAAC;MACjD,MAAMC,gBAAgB,GAAG,MAAM,CAACC,IAAI,CAACH,IAAI,CAAC;MAC1C,MAAMI,uBAAuB,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ACjB,CAAC","ignoreList":[]}
|
|
1
|
+
{"version":3,"file":"formatMarkdown.js","names":["marked","stringify","escapeBBCodeSquareBrackets","inlineCodeRule","inlineTextRule","TABLE_ID_PREFIX","tokenizer","codespan","src","cap","exec","text","replace","hasNonSpaceChars","test","hasSpaceCharsOnBothEnds","substring","length","type","raw","undefined","lheading","url","code","inlineText","renderer","lang","langString","match","checkbox","_ref","checked","postprocess","html","tableIndex","modifiedString","result","use","hooks","parseMarkdown","parseBBCode","parse","walkTokens","token","unescapeHtml","replaceAll","getMarkdownTables","tableTokens","push","tables","forEach","tableToken","index","tableArray","header","rowArray","rows","row","cell","csv","id"],"sources":["../../../../../src/utils/formatString/markdown/formatMarkdown.ts"],"sourcesContent":["import { marked, Tokens } from 'marked';\nimport type { TableObject } from '../../../types/format';\n// eslint-disable-next-line import/extensions,import/no-unresolved\nimport { stringify } from 'csv-stringify/browser/esm/sync';\nimport { escapeBBCodeSquareBrackets } from '../bb-code/formatBBCode';\n\nconst inlineCodeRule = /^(`+)([^`]|[^`][\\s\\S]*?[^`])\\1(?!`)/;\nconst inlineTextRule = /^(`+|[^`])(?:(?= {2,}\\n)|[\\s\\S]*?(?:(?=[\\\\<![`*_]|\\b_|$)|[^ ](?= {2,}\\n)))/;\n\nconst TABLE_ID_PREFIX = 'formatted-table-';\n\n/*\n The marked Pipeline, including tokenizer, renderer and hooks are explained here:\n https://marked.js.org/using_pro\n*/\n\nconst tokenizer = {\n // Codespan Tokenizer is overwritten to prevent html escaping, since html is already escaped.\n // The function is copied from marked.js and slightly modified: https://github.com/markedjs/marked/blob/42954aaba960b6f815b24ec0d39da464960e4ec9/src/Tokenizer.ts#L749\n codespan(src: string): Tokens.Codespan | undefined {\n const cap = inlineCodeRule.exec(src);\n if (cap) {\n let text = (cap[2] as string).replace(/\\n/g, ' ');\n const hasNonSpaceChars = /[^ ]/.test(text);\n const hasSpaceCharsOnBothEnds = /^ /.test(text) && / $/.test(text);\n if (hasNonSpaceChars && hasSpaceCharsOnBothEnds) {\n text = text.substring(1, text.length - 1);\n }\n\n return {\n type: 'codespan',\n raw: cap[0],\n text,\n };\n }\n\n return undefined;\n },\n // Disables Markdown formatting for setext headings.\n lheading(): Tokens.Heading | undefined {\n return undefined;\n },\n // Disables converting urls to hyperlinks.\n url() {\n return undefined;\n },\n // Disables converting text with 4 leading spaces to code block.\n code() {\n return undefined;\n },\n // inlineText is overwritten to prevent html escaping, specifically since quote characters are escaped, which breaks the attributes of bb-code elements.\n // The function is copied from marked.js and slightly modified: https://github.com/markedjs/marked/blob/42954aaba960b6f815b24ec0d39da464960e4ec9/src/Tokenizer.ts#L854\n inlineText(src: string) {\n const cap = inlineTextRule.exec(src);\n if (cap) {\n return {\n type: 'text',\n raw: cap[0],\n text: cap[0],\n };\n }\n return undefined;\n },\n};\n\nconst renderer = {\n // Code Renderer is overwritten to prevent html escaping, since html is already escaped.\n // The function is copied from marked.js and slightly modified: https://github.com/markedjs/marked/blob/42954aaba960b6f815b24ec0d39da464960e4ec9/src/Renderer.ts#L24\n code(text: string, lang: string): string {\n const langString = (lang || '').match(/^\\S*/)?.[0];\n\n const code = `${text.replace(/\\n$/, '')}`;\n\n if (!langString) {\n return `<pre><code>${code}</code></pre>\\n`;\n }\n\n return `<pre><code class=\"language-${langString}\">${code}</code></pre>\\n`;\n },\n // Replaces the checkbox input elements with markdown checkboxes.\n // This is the easiest way to prevent the formatting of markdown checkboxes in lists.\n // This can modify the input string slightly, since the capitalization of the checkbox can be lost.\n // If a user types '- [X]' it will be replaced with '- [x]' => the capitalization is lost.\n checkbox({ checked }: Tokens.Checkbox) {\n return checked ? '[x]' : '[ ]';\n },\n};\n\nconst postprocess = (html: string): string => {\n let tableIndex = 0;\n // Assigns ids to tables.\n const modifiedString = html.replace(/(<table>)/g, () => {\n const result = `<table id=\"${TABLE_ID_PREFIX}${tableIndex}\">`;\n tableIndex++;\n return result;\n });\n\n return modifiedString;\n};\n\n// eslint-disable-next-line @typescript-eslint/ban-ts-comment\n// @ts-ignore\nmarked.use({ tokenizer, renderer, hooks: { postprocess } });\n\n// Parses markdown following the Github Flavored Markdown specification.\n// The tokenizer and renderer are slightly modified to prevent html escaping in code block and inline code.\nexport const parseMarkdown = (text: string, parseBBCode: boolean) =>\n marked.parse(text, {\n walkTokens: (token) => {\n if (parseBBCode && (token.type === 'codespan' || token.type === 'code')) {\n // eslint-disable-next-line no-param-reassign\n (token as Tokens.Codespan).text = escapeBBCodeSquareBrackets(\n (token as Tokens.Codespan).text,\n );\n }\n },\n }) as string;\n\n// It is important that, & is replaced lastly to prevent double escaping.\nconst unescapeHtml = (text: string) =>\n text.replaceAll('<', '<').replaceAll('>', '>').replaceAll('&', '&');\n\nexport const getMarkdownTables = (text: string): TableObject[] => {\n const tableTokens: Tokens.Table[] = [];\n\n marked.parse(text, {\n walkTokens: (token) => {\n if (token.type === 'table') {\n tableTokens.push(token as Tokens.Table);\n }\n },\n }) as string;\n\n const tables: TableObject[] = [];\n\n tableTokens.forEach((tableToken, index) => {\n const tableArray: string[][] = [];\n\n if (tableToken.header?.length > 0) {\n const rowArray: string[] = [];\n\n tableToken.header.forEach((header) => {\n rowArray.push(unescapeHtml(header.text));\n });\n\n tableArray.push(rowArray);\n }\n if (tableToken.rows?.length > 0) {\n tableToken.rows.forEach((row) => {\n const rowArray: string[] = [];\n\n row.forEach((cell) => {\n rowArray.push(unescapeHtml(cell.text));\n });\n\n tableArray.push(rowArray);\n });\n }\n\n const csv = stringify(tableArray || []);\n\n tables.push({\n raw: unescapeHtml(tableToken.raw),\n csv,\n id: `${TABLE_ID_PREFIX}${index}`,\n });\n });\n\n return tables;\n};\n"],"mappings":"AAAA,SAASA,MAAM,QAAgB,QAAQ;AAEvC;AACA,SAASC,SAAS,QAAQ,gCAAgC;AAC1D,SAASC,0BAA0B,QAAQ,yBAAyB;AAEpE,MAAMC,cAAc,GAAG,qCAAqC;AAC5D,MAAMC,cAAc,GAAG,4EAA4E;AAEnG,MAAMC,eAAe,GAAG,kBAAkB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,QAAQ,CAACP,IAAI,CAACJ,YAAY,CAACc,IAAI,CAAC/C,IAAI,CAAC,CAAC;QAC1C,CAAC,CAAC;QAEF0C,UAAU,CAACL,IAAI,CAACO,QAAQ,CAAC;MAC7B,CAAC,CAAC;IACN;IAEA,MAAMI,GAAG,GAAG1D,SAAS,CAACoD,UAAU,IAAI,EAAE,CAAC;IAEvCJ,MAAM,CAACD,IAAI,CAAC;MACR7B,GAAG,EAAEyB,YAAY,CAACO,UAAU,CAAChC,GAAG,CAAC;MACjCwC,GAAG;MACHC,EAAE,EAAE,GAAGvD,eAAe,GAAG+C,KAAK;IAClC,CAAC,CAAC;EACN,CAAC,CAAC;EAEF,OAAOH,MAAM;AACjB,CAAC","ignoreList":[]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const BB_CODE_HTML_TAG_PREFIX = "bb-code-";
|
package/lib/types/index.d.ts
CHANGED
|
@@ -1,8 +1,11 @@
|
|
|
1
1
|
export interface ParseBBCodesOptions {
|
|
2
2
|
customBlockLevelBBCodeTags?: string[];
|
|
3
3
|
customInlineLevelBBCodeTags?: string[];
|
|
4
|
+
}
|
|
5
|
+
interface ParseBBCodePrivateOptions extends ParseBBCodesOptions {
|
|
4
6
|
justEscapeSquareBrackets?: boolean;
|
|
5
7
|
}
|
|
6
|
-
export declare const parseBBCode: (text: string, options?:
|
|
8
|
+
export declare const parseBBCode: (text: string, options?: ParseBBCodePrivateOptions) => string;
|
|
7
9
|
export declare const escapeBBCodeSquareBrackets: (text: string) => string;
|
|
8
10
|
export declare const unescapeBBCodeSquareBrackets: (text: string) => string;
|
|
11
|
+
export {};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@chayns-components/format",
|
|
3
|
-
"version": "5.0.0-beta.
|
|
3
|
+
"version": "5.0.0-beta.683",
|
|
4
4
|
"description": "A set of beautiful React components for developing your own applications with chayns.",
|
|
5
5
|
"sideEffects": false,
|
|
6
6
|
"browserslist": [
|
|
@@ -71,5 +71,5 @@
|
|
|
71
71
|
"publishConfig": {
|
|
72
72
|
"access": "public"
|
|
73
73
|
},
|
|
74
|
-
"gitHead": "
|
|
74
|
+
"gitHead": "9ac78b39832e1830f08d7b1efbbf6239946e090d"
|
|
75
75
|
}
|