@chayns-components/format 5.0.0-beta.651 → 5.0.0-beta.682

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.
Files changed (56) hide show
  1. package/lib/cjs/constants/format.js +8 -0
  2. package/lib/cjs/constants/format.js.map +1 -0
  3. package/lib/cjs/index.js +7 -0
  4. package/lib/cjs/index.js.map +1 -1
  5. package/lib/cjs/types/format.js +2 -0
  6. package/lib/cjs/types/format.js.map +1 -0
  7. package/lib/cjs/utils/escape.js +1 -5
  8. package/lib/cjs/utils/escape.js.map +1 -1
  9. package/lib/cjs/utils/formatString/bb-code/findBBCode.js +6 -4
  10. package/lib/cjs/utils/formatString/bb-code/findBBCode.js.map +1 -1
  11. package/lib/cjs/utils/formatString/bb-code/formatBBCode.js +38 -38
  12. package/lib/cjs/utils/formatString/bb-code/formatBBCode.js.map +1 -1
  13. package/lib/cjs/utils/formatString/formatString.js +30 -42
  14. package/lib/cjs/utils/formatString/formatString.js.map +1 -1
  15. package/lib/cjs/utils/formatString/formatString.test.js +549 -0
  16. package/lib/cjs/utils/formatString/formatString.test.js.map +1 -0
  17. package/lib/cjs/utils/formatString/markdown/formatMarkdown.js +145 -30
  18. package/lib/cjs/utils/formatString/markdown/formatMarkdown.js.map +1 -1
  19. package/lib/esm/constants/format.js +2 -0
  20. package/lib/esm/constants/format.js.map +1 -0
  21. package/lib/esm/index.js +1 -0
  22. package/lib/esm/index.js.map +1 -1
  23. package/lib/esm/types/format.js +2 -0
  24. package/lib/esm/types/format.js.map +1 -0
  25. package/lib/esm/utils/escape.js +0 -3
  26. package/lib/esm/utils/escape.js.map +1 -1
  27. package/lib/esm/utils/formatString/bb-code/findBBCode.js +6 -4
  28. package/lib/esm/utils/formatString/bb-code/findBBCode.js.map +1 -1
  29. package/lib/esm/utils/formatString/bb-code/formatBBCode.js +38 -40
  30. package/lib/esm/utils/formatString/bb-code/formatBBCode.js.map +1 -1
  31. package/lib/esm/utils/formatString/formatString.js +33 -45
  32. package/lib/esm/utils/formatString/formatString.js.map +1 -1
  33. package/lib/esm/utils/formatString/formatString.test.js +547 -0
  34. package/lib/esm/utils/formatString/formatString.test.js.map +1 -0
  35. package/lib/esm/utils/formatString/markdown/formatMarkdown.js +141 -27
  36. package/lib/esm/utils/formatString/markdown/formatMarkdown.js.map +1 -1
  37. package/lib/types/constants/format.d.ts +1 -0
  38. package/lib/types/index.d.ts +2 -0
  39. package/lib/types/types/format.d.ts +5 -0
  40. package/lib/types/utils/escape.d.ts +0 -3
  41. package/lib/types/utils/formatString/bb-code/findBBCode.d.ts +2 -0
  42. package/lib/types/utils/formatString/bb-code/formatBBCode.d.ts +4 -2
  43. package/lib/types/utils/formatString/formatString.d.ts +1 -3
  44. package/lib/types/utils/formatString/formatString.test.d.ts +1 -0
  45. package/lib/types/utils/formatString/markdown/formatMarkdown.d.ts +3 -1
  46. package/package.json +6 -4
  47. package/lib/cjs/utils/formatString/markdown/InternalHTMLRenderer.js +0 -287
  48. package/lib/cjs/utils/formatString/markdown/InternalHTMLRenderer.js.map +0 -1
  49. package/lib/cjs/utils/formatString/markdown/formatMarkdownTable.js +0 -86
  50. package/lib/cjs/utils/formatString/markdown/formatMarkdownTable.js.map +0 -1
  51. package/lib/esm/utils/formatString/markdown/InternalHTMLRenderer.js +0 -278
  52. package/lib/esm/utils/formatString/markdown/InternalHTMLRenderer.js.map +0 -1
  53. package/lib/esm/utils/formatString/markdown/formatMarkdownTable.js +0 -78
  54. package/lib/esm/utils/formatString/markdown/formatMarkdownTable.js.map +0 -1
  55. package/lib/types/utils/formatString/markdown/InternalHTMLRenderer.d.ts +0 -5
  56. package/lib/types/utils/formatString/markdown/formatMarkdownTable.d.ts +0 -9
@@ -0,0 +1,8 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.BB_CODE_HTML_TAG_PREFIX = void 0;
7
+ const BB_CODE_HTML_TAG_PREFIX = exports.BB_CODE_HTML_TAG_PREFIX = 'bb-code-';
8
+ //# sourceMappingURL=format.js.map
@@ -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
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","names":["_formatString","require"],"sources":["../../src/index.ts"],"sourcesContent":["export { formatStringToHtml } from './utils/formatString/formatString';\n"],"mappings":";;;;;;;;;;;AAAA,IAAAA,aAAA,GAAAC,OAAA","ignoreList":[]}
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":[]}
@@ -0,0 +1,2 @@
1
+
2
+ //# sourceMappingURL=format.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"format.js","names":[],"sources":["../../../src/types/format.ts"],"sourcesContent":["export type TableObject = {\n raw: string;\n csv: string;\n id: string;\n};\n"],"mappings":"","ignoreList":[]}
@@ -3,11 +3,7 @@
3
3
  Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
- exports.unescapeSquareBrackets = exports.escapeHtmlInText = exports.MESSAGE_CONVERSION_LINE_BREAK_ESCAPED = exports.MESSAGE_CONVERSION_LINE_BREAK = void 0;
6
+ exports.escapeHtmlInText = void 0;
7
7
  const escapeHtmlInText = text => text.replace(/</g, '&lt;').replace(/>/g, '&gt;');
8
8
  exports.escapeHtmlInText = escapeHtmlInText;
9
- const unescapeSquareBrackets = text => text.replaceAll('&#91;', '[').replaceAll('&#93;', ']');
10
- exports.unescapeSquareBrackets = unescapeSquareBrackets;
11
- const MESSAGE_CONVERSION_LINE_BREAK = exports.MESSAGE_CONVERSION_LINE_BREAK = '<br is-replaced-linebreak>';
12
- const MESSAGE_CONVERSION_LINE_BREAK_ESCAPED = exports.MESSAGE_CONVERSION_LINE_BREAK_ESCAPED = escapeHtmlInText(MESSAGE_CONVERSION_LINE_BREAK);
13
9
  //# sourceMappingURL=escape.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"escape.js","names":["escapeHtmlInText","text","replace","exports","unescapeSquareBrackets","replaceAll","MESSAGE_CONVERSION_LINE_BREAK","MESSAGE_CONVERSION_LINE_BREAK_ESCAPED"],"sources":["../../../src/utils/escape.ts"],"sourcesContent":["export const escapeHtmlInText = (text: string): string =>\n text.replace(/</g, '&lt;').replace(/>/g, '&gt;');\n\nexport const unescapeSquareBrackets = (text: string): string =>\n text.replaceAll('&#91;', '[').replaceAll('&#93;', ']');\n\nexport const MESSAGE_CONVERSION_LINE_BREAK = '<br is-replaced-linebreak>';\nexport const MESSAGE_CONVERSION_LINE_BREAK_ESCAPED = escapeHtmlInText(\n MESSAGE_CONVERSION_LINE_BREAK,\n);\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;AAE9C,MAAMI,sBAAsB,GAAIH,IAAY,IAC/CA,IAAI,CAACI,UAAU,CAAC,OAAO,EAAE,GAAG,CAAC,CAACA,UAAU,CAAC,OAAO,EAAE,GAAG,CAAC;AAACF,OAAA,CAAAC,sBAAA,GAAAA,sBAAA;AAEpD,MAAME,6BAA6B,GAAAH,OAAA,CAAAG,6BAAA,GAAG,4BAA4B;AAClE,MAAMC,qCAAqC,GAAAJ,OAAA,CAAAI,qCAAA,GAAGP,gBAAgB,CACjEM,6BACJ,CAAC","ignoreList":[]}
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, '&lt;').replace(/>/g, '&gt;');\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,7 +4,7 @@ Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
6
  exports.findFirstBBCode = findFirstBBCode;
7
- const BB_REGEX = /\[([a-zA-Z0-9_]*)(.*?)\](.*?)\[\/\1\]/s;
7
+ const BB_REGEX = /(\[([a-zA-Z0-9_]*)(.*?)\])(.*?)(\[\/\2\])/s;
8
8
  // Also matches "\" before quote to fix button for voucher messages
9
9
  const PARAMETER_REGEX = /([\w]*?)=\\?["„](.*?)["“]/g;
10
10
  // TODO Use external package instead of RegExp to parse BBCode.
@@ -14,11 +14,11 @@ const PARAMETER_REGEX = /([\w]*?)=\\?["„](.*?)["“]/g;
14
14
  function findFirstBBCode(inputString) {
15
15
  const matches = BB_REGEX.exec(inputString);
16
16
  if (matches !== null) {
17
- const [fullMatch, tag, params, content] = matches;
17
+ const [fullMatch, openingTag, tag, params, content, closingTag] = matches;
18
18
  const {
19
19
  index
20
20
  } = matches;
21
- if (fullMatch === undefined || tag === undefined || params === undefined || content === undefined) return null;
21
+ if (fullMatch === undefined || tag === undefined || params === undefined || content === undefined || openingTag === undefined || closingTag === undefined) return null;
22
22
  const parameters = {};
23
23
  let match = null;
24
24
  // eslint-disable-next-line no-cond-assign
@@ -33,7 +33,9 @@ function findFirstBBCode(inputString) {
33
33
  tag,
34
34
  parameters,
35
35
  content,
36
- index
36
+ index,
37
+ openingTag,
38
+ closingTag
37
39
  };
38
40
  }
39
41
  return null;
@@ -1 +1 @@
1
- {"version":3,"file":"findBBCode.js","names":["BB_REGEX","PARAMETER_REGEX","findFirstBBCode","inputString","matches","exec","fullMatch","tag","params","content","index","undefined","parameters","match","key","value"],"sources":["../../../../../src/utils/formatString/bb-code/findBBCode.ts"],"sourcesContent":["const BB_REGEX = /\\[([a-zA-Z0-9_]*)(.*?)\\](.*?)\\[\\/\\1\\]/s;\n// Also matches \"\\\" before quote to fix button for voucher messages\nconst PARAMETER_REGEX = /([\\w]*?)=\\\\?[\"„](.*?)[\"“]/g;\n\nexport interface BBCodeMatch {\n fullMatch: string;\n tag: string;\n parameters: Record<string, string>;\n content: string;\n index: number;\n}\n\n// TODO Use external package instead of RegExp to parse BBCode.\n// It is not recommended to use RegExp to parse markup languages like BBCode, because it is not possible to parse nested tags with it.\n\n// Finds and returns the first BBCode tag in the input string.\nexport function findFirstBBCode(inputString: string): BBCodeMatch | null {\n const matches = BB_REGEX.exec(inputString);\n\n if (matches !== null) {\n const [fullMatch, tag, params, content] = matches;\n const { index } = matches;\n\n if (\n fullMatch === undefined ||\n tag === undefined ||\n params === undefined ||\n content === undefined\n )\n return null;\n\n const parameters: Record<string, string> = {};\n\n let match: RegExpExecArray | null = null;\n // eslint-disable-next-line no-cond-assign\n while ((match = PARAMETER_REGEX.exec(params))) {\n const [, key, value] = match;\n\n if (value) {\n parameters[key || 'url'] = value;\n }\n }\n\n return {\n fullMatch,\n tag,\n parameters,\n content,\n index,\n };\n }\n\n return null;\n}\n"],"mappings":";;;;;;AAAA,MAAMA,QAAQ,GAAG,wCAAwC;AACzD;AACA,MAAMC,eAAe,GAAG,4BAA4B;AAUpD;AACA;;AAEA;AACO,SAASC,eAAeA,CAACC,WAAmB,EAAsB;EACrE,MAAMC,OAAO,GAAGJ,QAAQ,CAACK,IAAI,CAACF,WAAW,CAAC;EAE1C,IAAIC,OAAO,KAAK,IAAI,EAAE;IAClB,MAAM,CAACE,SAAS,EAAEC,GAAG,EAAEC,MAAM,EAAEC,OAAO,CAAC,GAAGL,OAAO;IACjD,MAAM;MAAEM;IAAM,CAAC,GAAGN,OAAO;IAEzB,IACIE,SAAS,KAAKK,SAAS,IACvBJ,GAAG,KAAKI,SAAS,IACjBH,MAAM,KAAKG,SAAS,IACpBF,OAAO,KAAKE,SAAS,EAErB,OAAO,IAAI;IAEf,MAAMC,UAAkC,GAAG,CAAC,CAAC;IAE7C,IAAIC,KAA6B,GAAG,IAAI;IACxC;IACA,OAAQA,KAAK,GAAGZ,eAAe,CAACI,IAAI,CAACG,MAAM,CAAC,EAAG;MAC3C,MAAM,GAAGM,GAAG,EAAEC,KAAK,CAAC,GAAGF,KAAK;MAE5B,IAAIE,KAAK,EAAE;QACPH,UAAU,CAACE,GAAG,IAAI,KAAK,CAAC,GAAGC,KAAK;MACpC;IACJ;IAEA,OAAO;MACHT,SAAS;MACTC,GAAG;MACHK,UAAU;MACVH,OAAO;MACPC;IACJ,CAAC;EACL;EAEA,OAAO,IAAI;AACf","ignoreList":[]}
1
+ {"version":3,"file":"findBBCode.js","names":["BB_REGEX","PARAMETER_REGEX","findFirstBBCode","inputString","matches","exec","fullMatch","openingTag","tag","params","content","closingTag","index","undefined","parameters","match","key","value"],"sources":["../../../../../src/utils/formatString/bb-code/findBBCode.ts"],"sourcesContent":["const BB_REGEX = /(\\[([a-zA-Z0-9_]*)(.*?)\\])(.*?)(\\[\\/\\2\\])/s;\n// Also matches \"\\\" before quote to fix button for voucher messages\nconst PARAMETER_REGEX = /([\\w]*?)=\\\\?[\"„](.*?)[\"“]/g;\n\nexport interface BBCodeMatch {\n fullMatch: string;\n tag: string;\n parameters: Record<string, string>;\n content: string;\n index: number;\n openingTag: string;\n closingTag: string;\n}\n\n// TODO Use external package instead of RegExp to parse BBCode.\n// It is not recommended to use RegExp to parse markup languages like BBCode, because it is not possible to parse nested tags with it.\n\n// Finds and returns the first BBCode tag in the input string.\nexport function findFirstBBCode(inputString: string): BBCodeMatch | null {\n const matches = BB_REGEX.exec(inputString);\n\n if (matches !== null) {\n const [fullMatch, openingTag, tag, params, content, closingTag] = matches;\n const { index } = matches;\n\n if (\n fullMatch === undefined ||\n tag === undefined ||\n params === undefined ||\n content === undefined ||\n openingTag === undefined ||\n closingTag === undefined\n )\n return null;\n\n const parameters: Record<string, string> = {};\n\n let match: RegExpExecArray | null = null;\n // eslint-disable-next-line no-cond-assign\n while ((match = PARAMETER_REGEX.exec(params))) {\n const [, key, value] = match;\n\n if (value) {\n parameters[key || 'url'] = value;\n }\n }\n\n return {\n fullMatch,\n tag,\n parameters,\n content,\n index,\n openingTag,\n closingTag,\n };\n }\n\n return null;\n}\n"],"mappings":";;;;;;AAAA,MAAMA,QAAQ,GAAG,4CAA4C;AAC7D;AACA,MAAMC,eAAe,GAAG,4BAA4B;AAYpD;AACA;;AAEA;AACO,SAASC,eAAeA,CAACC,WAAmB,EAAsB;EACrE,MAAMC,OAAO,GAAGJ,QAAQ,CAACK,IAAI,CAACF,WAAW,CAAC;EAE1C,IAAIC,OAAO,KAAK,IAAI,EAAE;IAClB,MAAM,CAACE,SAAS,EAAEC,UAAU,EAAEC,GAAG,EAAEC,MAAM,EAAEC,OAAO,EAAEC,UAAU,CAAC,GAAGP,OAAO;IACzE,MAAM;MAAEQ;IAAM,CAAC,GAAGR,OAAO;IAEzB,IACIE,SAAS,KAAKO,SAAS,IACvBL,GAAG,KAAKK,SAAS,IACjBJ,MAAM,KAAKI,SAAS,IACpBH,OAAO,KAAKG,SAAS,IACrBN,UAAU,KAAKM,SAAS,IACxBF,UAAU,KAAKE,SAAS,EAExB,OAAO,IAAI;IAEf,MAAMC,UAAkC,GAAG,CAAC,CAAC;IAE7C,IAAIC,KAA6B,GAAG,IAAI;IACxC;IACA,OAAQA,KAAK,GAAGd,eAAe,CAACI,IAAI,CAACI,MAAM,CAAC,EAAG;MAC3C,MAAM,GAAGO,GAAG,EAAEC,KAAK,CAAC,GAAGF,KAAK;MAE5B,IAAIE,KAAK,EAAE;QACPH,UAAU,CAACE,GAAG,IAAI,KAAK,CAAC,GAAGC,KAAK;MACpC;IACJ;IAEA,OAAO;MACHX,SAAS;MACTE,GAAG;MACHM,UAAU;MACVJ,OAAO;MACPE,KAAK;MACLL,UAAU;MACVI;IACJ,CAAC;EACL;EAEA,OAAO,IAAI;AACf","ignoreList":[]}
@@ -3,20 +3,19 @@
3
3
  Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
- exports.parseBBCode = void 0;
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
- const HTML_CODE_PATTERN = /(?:<code>|<code class="inline-code">)[\s\S]*?<\/code>/;
12
11
  // Parses BB-Code to HTML recursively.
13
12
  // When justEscapeSquareBrackets is true, square brackets are escaped to prevent conflicts between markdown and BB Code.
14
13
  // In that case the function only escapes square brackets and doesn't remove line breaks.
15
14
  const parseBBCode = (text, options) => {
16
15
  const {
17
- justEscapeSquareBrackets = false,
18
16
  customBlockLevelBBCodeTags: customBlockLevelTags = [],
19
- customInlineLevelBBCodeTags: customInlineLevelTags = []
17
+ customInlineLevelBBCodeTags: customInlineLevelTags = [],
18
+ justEscapeSquareBrackets = false
20
19
  } = options || {};
21
20
  let html = text;
22
21
 
@@ -24,26 +23,19 @@ const parseBBCode = (text, options) => {
24
23
  let parseBehindIndex = 0;
25
24
  while (parseBehindIndex < html.length) {
26
25
  const htmlToParse = html.slice(parseBehindIndex);
27
- const firstCodeElementMatch = HTML_CODE_PATTERN.exec(htmlToParse);
28
26
  const firstBBCodeMatch = (0, _findBBCode.findFirstBBCode)(htmlToParse);
29
27
 
30
28
  // Stops parsing if no BB-Code is found.
31
29
  if (!firstBBCodeMatch) {
32
30
  return html;
33
31
  }
34
-
35
- // Prevents bb-code parsing within code block.
36
- if (firstCodeElementMatch && firstBBCodeMatch && firstCodeElementMatch.index < firstBBCodeMatch.index) {
37
- // If a code block is found before a BB-Code tag, BB-Code parsing continues behind the code block.
38
- parseBehindIndex += firstCodeElementMatch.index + firstCodeElementMatch[0].length;
39
- // eslint-disable-next-line no-continue
40
- continue;
41
- }
42
32
  const {
43
33
  content,
44
34
  fullMatch,
45
35
  parameters,
46
- index
36
+ index,
37
+ openingTag,
38
+ closingTag
47
39
  } = firstBBCodeMatch;
48
40
  const Tag = firstBBCodeMatch.tag.toLowerCase();
49
41
  const isValidTag = [...BLOCK_LEVEL_TAGS, ...customBlockLevelTags, ...INLINE_LEVEL_TAGS, ...customInlineLevelTags].includes(Tag);
@@ -58,37 +50,45 @@ const parseBBCode = (text, options) => {
58
50
  }
59
51
 
60
52
  // Converts BB-Code tag's content before converting itself, because it may contain other BB-Codes.
61
- let parsedContent = parseBBCode(content);
53
+ let parsedContent = parseBBCode(content, options);
54
+ if (justEscapeSquareBrackets) {
55
+ const indexOfFullMatch = html.indexOf(fullMatch);
56
+ const escapedOpeningTag = escapeBBCodeSquareBrackets(openingTag);
57
+ const escapedClosingTag = escapeBBCodeSquareBrackets(closingTag);
62
58
 
63
- // Removes leading and trailing line-breaks from within bb code elements, to prevent unwanted spacing.
64
- if (!justEscapeSquareBrackets) {
59
+ // Removes leading and trailing line-breaks from within bb code elements, to prevent unwanted spacing.
60
+ // This needs to be done before formatting Markdown, so the Markdown formatting doesn't interpret line breaks unexpectedly.
65
61
  parsedContent = parsedContent.replace(/^\n+|\n+$/g, '');
66
- }
67
- const indexOfFullMatch = html.indexOf(fullMatch);
68
- let htmlAfterTag = html.slice(indexOfFullMatch + fullMatch.length);
69
-
70
- // Removes leading line-break (ONE, NOT ALL) after block level elements, to prevent unwanted spacing.
71
- if (!justEscapeSquareBrackets && isBlockLevelTag) {
72
- htmlAfterTag = htmlAfterTag.replace(/^\n/, '');
73
- }
74
62
 
75
- // Use escaped square brackets to prevent conflicts between markdown and BB Code.
76
- const openTag = justEscapeSquareBrackets ? '&#91;' : '<';
77
- const closeTag = justEscapeSquareBrackets ? '&#93;' : '>';
63
+ // Simply escapes the square brackets of the BB-Code opening and closing tag.
64
+ html = html.slice(0, indexOfFullMatch) + escapedOpeningTag + parsedContent + escapedClosingTag + html.slice(indexOfFullMatch + fullMatch.length);
78
65
 
79
- // TODO Don't alter content of bb-code tags when justEscapeSquareBrackets is true.
80
- // This is necessary to preserve whitespaces in bb-code tags within code blocks.
66
+ // Continues parsing behind the parsed bb-code.
67
+ parseBehindIndex = indexOfFullMatch + escapedOpeningTag.length + parsedContent.length + escapedClosingTag.length;
68
+ } else {
69
+ const indexOfFullMatch = html.indexOf(fullMatch);
70
+ let htmlAfterTag = html.slice(indexOfFullMatch + fullMatch.length);
81
71
 
82
- const isCustomTag = [...customBlockLevelTags, ...customInlineLevelTags].includes(Tag);
83
- const htmlTag = !justEscapeSquareBrackets && isCustomTag ? `${BB_CODE_HTML_TAG_PREFIX}${Tag}` : Tag;
84
- const openingTag = `${openTag}${htmlTag}${Object.entries(parameters).length > 0 ? ' ' : ''}${Object.entries(parameters).map(([key, value]) => `${key}="${value}"`).join(' ')}${closeTag}`;
85
- const closingTag = `${openTag}/${htmlTag}${closeTag}`;
86
- html = html.slice(0, indexOfFullMatch) + openingTag + parsedContent + closingTag + htmlAfterTag;
72
+ // Removes leading line-break (ONE, NOT ALL) after block level elements, to prevent unwanted spacing.
73
+ if (isBlockLevelTag) {
74
+ htmlAfterTag = htmlAfterTag.replace(/^\n/, '');
75
+ }
76
+ const isCustomTag = [...customBlockLevelTags, ...customInlineLevelTags].includes(Tag);
77
+ const htmlTag = isCustomTag ? `${_format.BB_CODE_HTML_TAG_PREFIX}${Tag}` : Tag;
78
+ const openingHtmlTag = `<${htmlTag}${Object.entries(parameters).length > 0 ? ' ' : ''}${Object.entries(parameters).map(([key, value]) => `${key}="${value}"`).join(' ')}>`;
79
+ const closingHtmlTag = `</${htmlTag}>`;
80
+ const element = Tag === 'img' ? openingHtmlTag : openingHtmlTag + parsedContent + closingHtmlTag;
81
+ html = `${html.slice(0, indexOfFullMatch)}${element}${htmlAfterTag}`;
87
82
 
88
- // Continues parsing behind the parsed bb-code.
89
- parseBehindIndex = indexOfFullMatch + openingTag.length + parsedContent.length + closingTag.length;
83
+ // Continues parsing behind the parsed bb-code.
84
+ parseBehindIndex = indexOfFullMatch + element.length;
85
+ }
90
86
  }
91
87
  return html;
92
88
  };
93
89
  exports.parseBBCode = parseBBCode;
90
+ const escapeBBCodeSquareBrackets = text => text.replaceAll('[', '&zwj;[&zwj;').replaceAll(']', '&zwj;]&zwj;');
91
+ exports.escapeBBCodeSquareBrackets = escapeBBCodeSquareBrackets;
92
+ const unescapeBBCodeSquareBrackets = text => text.replaceAll('&zwj;[&zwj;', '[').replaceAll('&zwj;]&zwj;', ']');
93
+ exports.unescapeBBCodeSquareBrackets = unescapeBBCodeSquareBrackets;
94
94
  //# sourceMappingURL=formatBBCode.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"formatBBCode.js","names":["_findBBCode","require","BB_CODE_HTML_TAG_PREFIX","BLOCK_LEVEL_TAGS","INLINE_LEVEL_TAGS","HTML_CODE_PATTERN","parseBBCode","text","options","justEscapeSquareBrackets","customBlockLevelBBCodeTags","customBlockLevelTags","customInlineLevelBBCodeTags","customInlineLevelTags","html","parseBehindIndex","length","htmlToParse","slice","firstCodeElementMatch","exec","firstBBCodeMatch","findFirstBBCode","index","content","fullMatch","parameters","Tag","tag","toLowerCase","isValidTag","includes","isBlockLevelTag","parsedContent","replace","indexOfFullMatch","indexOf","htmlAfterTag","openTag","closeTag","isCustomTag","htmlTag","openingTag","Object","entries","map","key","value","join","closingTag","exports"],"sources":["../../../../../src/utils/formatString/bb-code/formatBBCode.ts"],"sourcesContent":["import { findFirstBBCode } from './findBBCode';\n\nconst BB_CODE_HTML_TAG_PREFIX = 'bb-code-';\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\nconst HTML_CODE_PATTERN = /(?:<code>|<code class=\"inline-code\">)[\\s\\S]*?<\\/code>/;\n\nexport interface ParseBBCodesOptions {\n customBlockLevelBBCodeTags?: string[];\n customInlineLevelBBCodeTags?: string[];\n}\n\ninterface PrivateParseBBCodesOptions extends ParseBBCodesOptions {\n // When justEscapeSquareBrackets is true, this function is simply used to escape square brackets of bb-code tags and nothing else!\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?: PrivateParseBBCodesOptions) => {\n const {\n justEscapeSquareBrackets = false,\n customBlockLevelBBCodeTags: customBlockLevelTags = [],\n customInlineLevelBBCodeTags: customInlineLevelTags = [],\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 firstCodeElementMatch = HTML_CODE_PATTERN.exec(htmlToParse);\n const firstBBCodeMatch = findFirstBBCode(htmlToParse);\n\n // Stops parsing if no BB-Code is found.\n if (!firstBBCodeMatch) {\n return html;\n }\n\n // Prevents bb-code parsing within code block.\n if (\n firstCodeElementMatch &&\n firstBBCodeMatch &&\n firstCodeElementMatch.index < firstBBCodeMatch.index\n ) {\n // If a code block is found before a BB-Code tag, BB-Code parsing continues behind the code block.\n parseBehindIndex += firstCodeElementMatch.index + firstCodeElementMatch[0].length;\n // eslint-disable-next-line no-continue\n continue;\n }\n\n const { content, fullMatch, parameters, index } = 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);\n\n // Removes leading and trailing line-breaks from within bb code elements, to prevent unwanted spacing.\n if (!justEscapeSquareBrackets) {\n parsedContent = parsedContent.replace(/^\\n+|\\n+$/g, '');\n }\n\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 (!justEscapeSquareBrackets && isBlockLevelTag) {\n htmlAfterTag = htmlAfterTag.replace(/^\\n/, '');\n }\n\n // Use escaped square brackets to prevent conflicts between markdown and BB Code.\n const openTag = justEscapeSquareBrackets ? '&#91;' : '<';\n const closeTag = justEscapeSquareBrackets ? '&#93;' : '>';\n\n // TODO Don't alter content of bb-code tags when justEscapeSquareBrackets is true.\n // This is necessary to preserve whitespaces in bb-code tags within code blocks.\n\n const isCustomTag = [...customBlockLevelTags, ...customInlineLevelTags].includes(Tag);\n const htmlTag =\n !justEscapeSquareBrackets && isCustomTag ? `${BB_CODE_HTML_TAG_PREFIX}${Tag}` : Tag;\n const openingTag = `${openTag}${htmlTag}${Object.entries(parameters).length > 0 ? ' ' : ''}${Object.entries(\n parameters,\n )\n .map(([key, value]) => `${key}=\"${value}\"`)\n .join(' ')}${closeTag}`;\n const closingTag = `${openTag}/${htmlTag}${closeTag}`;\n html =\n html.slice(0, indexOfFullMatch) +\n openingTag +\n parsedContent +\n closingTag +\n htmlAfterTag;\n\n // Continues parsing behind the parsed bb-code.\n parseBehindIndex =\n indexOfFullMatch + openingTag.length + parsedContent.length + closingTag.length;\n }\n\n return html;\n};\n"],"mappings":";;;;;;AAAA,IAAAA,WAAA,GAAAC,OAAA;AAEA,MAAMC,uBAAuB,GAAG,UAAU;AAE1C,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;AAE7E,MAAMC,iBAAiB,GAAG,uDAAuD;AAYjF;AACA;AACA;AACO,MAAMC,WAAW,GAAGA,CAACC,IAAY,EAAEC,OAAoC,KAAK;EAC/E,MAAM;IACFC,wBAAwB,GAAG,KAAK;IAChCC,0BAA0B,EAAEC,oBAAoB,GAAG,EAAE;IACrDC,2BAA2B,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ACI,KAAK,CAAC,CAAC,EAAEiB,gBAAgB,CAAC,GAC/BO,UAAU,GACVT,aAAa,GACbgB,UAAU,GACVZ,YAAY;;IAEhB;IACAtB,gBAAgB,GACZoB,gBAAgB,GAAGO,UAAU,CAAC1B,MAAM,GAAGiB,aAAa,CAACjB,MAAM,GAAGiC,UAAU,CAACjC,MAAM;EACvF;EAEA,OAAOF,IAAI;AACf,CAAC;AAACoC,OAAA,CAAA5C,WAAA,GAAAA,WAAA","ignoreList":[]}
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('[', '&zwj;[&zwj;').replaceAll(']', '&zwj;]&zwj;');\n\nexport const unescapeBBCodeSquareBrackets = (text: string) =>\n text.replaceAll('&zwj;[&zwj;', '[').replaceAll('&zwj;]&zwj;', ']');\n"],"mappings":";;;;;;AAAA,IAAAA,OAAA,GAAAC,OAAA;AACA,IAAAC,WAAA,GAAAD,OAAA;AAEA,MAAME,gBAAgB,GAAG,CAAC,QAAQ,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,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IF,OAAO,GAAGG,MAAM,CAACC,OAAO,CAACvB,UAAU,CAAC,CAACP,MAAM,GAAG,CAAC,GAAG,GAAG,GAAG,EAAE,GAAG6B,MAAM,CAACC,OAAO,CAClGvB,UACJ,CAAC,CACIwB,GAAG,CAAC,CAAC,CAACC,GAAG,EAAEC,KAAK,CAAC,KAAK,GAAGD,GAAG,KAAKC,KAAK,GAAG,CAAC,CAC1CC,IAAI,CAAC,GAAG,CAAC,GAAG;MACjB,MAAMC,cAAc,GAAG,KAAKT,OAAO,GAAG;MAEtC,MAAMU,OAAO,GACTzB,GAAG,KAAK,KAAK,GAAGiB,cAAc,GAAGA,cAAc,GAAGX,aAAa,GAAGkB,cAAc;MAEpFrC,IAAI,GAAG,GAAGA,IAAI,CAACI,KAAK,CAAC,CAAC,EAAEgB,gBAAgB,CAAC,GAAGkB,OAAO,GAAGZ,YAAY,EAAE;;MAEpE;MACAzB,gBAAgB,GAAGmB,gBAAgB,GAAGkB,OAAO,CAACpC,MAAM;IACxD;EACJ;EAEA,OAAOF,IAAI;AACf,CAAC;AAACuC,OAAA,CAAA/C,WAAA,GAAAA,WAAA;AAEK,MAAM+B,0BAA0B,GAAI9B,IAAY,IACnDA,IAAI,CAAC+C,UAAU,CAAC,GAAG,EAAE,aAAa,CAAC,CAACA,UAAU,CAAC,GAAG,EAAE,aAAa,CAAC;AAACD,OAAA,CAAAhB,0BAAA,GAAAA,0BAAA;AAEhE,MAAMkB,4BAA4B,GAAIhD,IAAY,IACrDA,IAAI,CAAC+C,UAAU,CAAC,aAAa,EAAE,GAAG,CAAC,CAACA,UAAU,CAAC,aAAa,EAAE,GAAG,CAAC;AAACD,OAAA,CAAAE,4BAAA,GAAAA,4BAAA","ignoreList":[]}
@@ -7,7 +7,6 @@ exports.formatStringToHtml = void 0;
7
7
  var _escape = require("../escape");
8
8
  var _formatBBCode = require("./bb-code/formatBBCode");
9
9
  var _formatMarkdown = require("./markdown/formatMarkdown");
10
- var _formatMarkdownTable = require("./markdown/formatMarkdownTable");
11
10
  // This function takes a string and returns formatted html as a string.
12
11
  const formatStringToHtml = (string, options) => {
13
12
  if (!string) {
@@ -17,71 +16,60 @@ const formatStringToHtml = (string, options) => {
17
16
  };
18
17
  }
19
18
  const {
20
- escapeHtml: escapeHtmlOption = false,
21
19
  parseMarkdown: parseMarkdownOption = true,
22
- parseMarkdownTables: parseMarkdownTablesOption = false,
23
20
  parseBBCode: parseBBCodeOption = false,
24
21
  customInlineLevelBBCodeTags = [],
25
22
  customBlockLevelBBCodeTags = []
26
23
  } = options || {};
27
24
  let formattedString = string;
28
25
 
29
- // Escapes HTML.
30
- if (escapeHtmlOption) {
31
- formattedString = (0, _escape.escapeHtmlInText)(formattedString);
32
- }
33
-
34
- // Escape BB-Code square brackets, to prevent conflicts between markdown and BB Code.
35
- /* Conflict example:
36
- When Sidekick detects a function call as an entity through NER, then the following text is returned.
37
- '[nerReplace <params>]function[/nerReplace](<params>)'
38
- Because '[/nerReplace](<params>)' is a valid Markdown link, the Markdown parser would interpret it as a link
39
- and thus prevent the BB-Code parser from recognizing the BB-Code. Parsing the BB-Code first would prevent this
40
- issue. Unfortunately the Markdown parser doesn't support this.
41
- */
42
- const shouldTemporarilyEscapeBBCodeBrackets = parseMarkdownOption && parseBBCodeOption;
43
- if (shouldTemporarilyEscapeBBCodeBrackets) {
26
+ // Needs to get the tables before escaping html and parsing bb-code, so the original content can be extracted.
27
+ const tables = [];
28
+ if (parseMarkdownOption) {
44
29
  try {
45
- formattedString = (0, _formatBBCode.parseBBCode)(formattedString, {
46
- justEscapeSquareBrackets: true
47
- });
30
+ tables.push(...(0, _formatMarkdown.getMarkdownTables)(formattedString));
48
31
  } catch (error) {
49
- console.warn('[@chayns-components/format] Warning: Failed to escape bb-code brackets', error);
32
+ console.warn('[@chayns-components/format] Warning: Failed to get markdown tables', error);
50
33
  }
51
34
  }
52
35
 
53
- // Parses markdown to HTML. Markdown tables are parsed separately.
36
+ // Escape HTML entities.
37
+ formattedString = (0, _escape.escapeHtmlInText)(formattedString);
38
+
39
+ // Escape BB-Code, to prevent conflicts between markdown and bb-code. Specifically [b]test[/b]() would be a problem, since markdown interprets parts of this as a link.
40
+
41
+ // Parses markdown to HTML.
54
42
  if (parseMarkdownOption) {
55
43
  try {
56
- formattedString = (0, _formatMarkdown.parseMarkdown)(formattedString);
57
- } catch (error) {
58
- console.warn('[@chayns-components/format] Warning: Failed to parse markdown', error);
59
- }
60
- }
61
- const tables = [];
44
+ if (parseBBCodeOption) {
45
+ // Escapes BB-Code brackets.
46
+ formattedString = (0, _formatBBCode.parseBBCode)(formattedString, {
47
+ customInlineLevelBBCodeTags,
48
+ customBlockLevelBBCodeTags,
49
+ justEscapeSquareBrackets: true
50
+ });
51
+ }
52
+ formattedString = (0, _formatMarkdown.parseMarkdown)(formattedString, parseBBCodeOption);
62
53
 
63
- // Parses markdown tables to HTML. Also returns the tables content as an array, to allow further processing.
64
- if (parseMarkdownTablesOption) {
65
- try {
66
- const result = (0, _formatMarkdownTable.parseMarkdownTables)(formattedString);
67
- formattedString = result.html;
68
- tables.push(...result.tables);
54
+ // Remove trailing \n
55
+ formattedString = formattedString.replace(/\n$/, '');
56
+ if (parseBBCodeOption) {
57
+ // Unescapes BB-Code brackets.
58
+ formattedString = (0, _formatBBCode.unescapeBBCodeSquareBrackets)(formattedString);
59
+ }
69
60
  } catch (error) {
70
- console.warn('[@chayns-components/format] Warning: Failed to parse markdown tables', error);
61
+ console.warn('[@chayns-components/format] Warning: Failed to parse markdown', error);
71
62
  }
72
63
  }
73
64
 
74
- // Unescapes BB-Code square brackets, to allow parsing of BB-Code.
75
- if (shouldTemporarilyEscapeBBCodeBrackets) {
76
- formattedString = (0, _escape.unescapeSquareBrackets)(formattedString);
77
- }
65
+ // Parses BB-Code to HTML.
78
66
  if (parseBBCodeOption) {
79
67
  try {
80
68
  formattedString = (0, _formatBBCode.parseBBCode)(formattedString, {
81
69
  customInlineLevelBBCodeTags,
82
- customBlockLevelBBCodeTags,
83
- justEscapeSquareBrackets: false
70
+ customBlockLevelBBCodeTags
84
71
  });
72
+ formattedString = (0, _formatBBCode.unescapeBBCodeSquareBrackets)(formattedString);
85
73
  } catch (error) {
86
74
  console.warn('[@chayns-components/format] Warning: Failed to parse bb-code', error);
87
75
  }
@@ -1 +1 @@
1
- {"version":3,"file":"formatString.js","names":["_escape","require","_formatBBCode","_formatMarkdown","_formatMarkdownTable","formatStringToHtml","string","options","html","tables","escapeHtml","escapeHtmlOption","parseMarkdown","parseMarkdownOption","parseMarkdownTables","parseMarkdownTablesOption","parseBBCode","parseBBCodeOption","customInlineLevelBBCodeTags","customBlockLevelBBCodeTags","formattedString","escapeHtmlInText","shouldTemporarilyEscapeBBCodeBrackets","justEscapeSquareBrackets","error","console","warn","result","push","unescapeSquareBrackets","exports"],"sources":["../../../../src/utils/formatString/formatString.ts"],"sourcesContent":["import { escapeHtmlInText, unescapeSquareBrackets } from '../escape';\nimport { parseBBCode, ParseBBCodesOptions } from './bb-code/formatBBCode';\nimport { parseMarkdown } from './markdown/formatMarkdown';\nimport { parseMarkdownTables, TableObject } from './markdown/formatMarkdownTable';\n\ninterface FormatStringOptions extends ParseBBCodesOptions {\n escapeHtml?: boolean;\n parseMarkdown?: boolean;\n parseMarkdownTables?: boolean;\n parseBBCode?: boolean;\n}\n\ninterface FormatStringResult {\n html: string;\n tables: TableObject[];\n}\n\n// This function takes a string and returns formatted html as a string.\nexport const formatStringToHtml = (\n string: string,\n options?: FormatStringOptions,\n): FormatStringResult => {\n if (!string) {\n return {\n html: '',\n tables: [],\n };\n }\n\n const {\n escapeHtml: escapeHtmlOption = false,\n parseMarkdown: parseMarkdownOption = true,\n parseMarkdownTables: parseMarkdownTablesOption = false,\n parseBBCode: parseBBCodeOption = false,\n customInlineLevelBBCodeTags = [],\n customBlockLevelBBCodeTags = [],\n } = options || {};\n\n let formattedString = string;\n\n // Escapes HTML.\n if (escapeHtmlOption) {\n formattedString = escapeHtmlInText(formattedString);\n }\n\n // Escape BB-Code square brackets, to prevent conflicts between markdown and BB Code.\n /* Conflict example:\n When Sidekick detects a function call as an entity through NER, then the following text is returned.\n '[nerReplace <params>]function[/nerReplace](<params>)'\n Because '[/nerReplace](<params>)' is a valid Markdown link, the Markdown parser would interpret it as a link\n and thus prevent the BB-Code parser from recognizing the BB-Code. Parsing the BB-Code first would prevent this\n issue. Unfortunately the Markdown parser doesn't support this.\n */\n const shouldTemporarilyEscapeBBCodeBrackets = parseMarkdownOption && parseBBCodeOption;\n if (shouldTemporarilyEscapeBBCodeBrackets) {\n try {\n formattedString = parseBBCode(formattedString, {\n justEscapeSquareBrackets: true,\n });\n } catch (error) {\n console.warn(\n '[@chayns-components/format] Warning: Failed to escape bb-code brackets',\n error,\n );\n }\n }\n\n // Parses markdown to HTML. Markdown tables are parsed separately.\n if (parseMarkdownOption) {\n try {\n formattedString = parseMarkdown(formattedString);\n } catch (error) {\n console.warn('[@chayns-components/format] Warning: Failed to parse markdown', error);\n }\n }\n\n const tables: TableObject[] = [];\n\n // Parses markdown tables to HTML. Also returns the tables content as an array, to allow further processing.\n if (parseMarkdownTablesOption) {\n try {\n const result = parseMarkdownTables(formattedString);\n formattedString = result.html;\n tables.push(...result.tables);\n } catch (error) {\n console.warn(\n '[@chayns-components/format] Warning: Failed to parse markdown tables',\n error,\n );\n }\n }\n\n // Unescapes BB-Code square brackets, to allow parsing of BB-Code.\n if (shouldTemporarilyEscapeBBCodeBrackets) {\n formattedString = unescapeSquareBrackets(formattedString);\n }\n\n if (parseBBCodeOption) {\n try {\n formattedString = parseBBCode(formattedString, {\n customInlineLevelBBCodeTags,\n customBlockLevelBBCodeTags,\n justEscapeSquareBrackets: false,\n });\n } catch (error) {\n console.warn('[@chayns-components/format] Warning: Failed to parse bb-code', error);\n }\n }\n\n return {\n html: formattedString,\n tables,\n };\n};\n"],"mappings":";;;;;;AAAA,IAAAA,OAAA,GAAAC,OAAA;AACA,IAAAC,aAAA,GAAAD,OAAA;AACA,IAAAE,eAAA,GAAAF,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M,GAAG,IAAAb,wCAAmB,EAACM,eAAe,CAAC;MACnDA,eAAe,GAAGO,MAAM,CAACnB,IAAI;MAC7BC,MAAM,CAACmB,IAAI,CAAC,GAAGD,MAAM,CAAClB,MAAM,CAAC;IACjC,CAAC,CAAC,OAAOe,KAAK,EAAE;MACZC,OAAO,CAACC,IAAI,CACR,sEAAsE,EACtEF,KACJ,CAAC;IACL;EACJ;;EAEA;EACA,IAAIF,qCAAqC,EAAE;IACvCF,eAAe,GAAG,IAAAS,8BAAsB,EAACT,eAAe,CAAC;EAC7D;EAEA,IAAIH,iBAAiB,EAAE;IACnB,IAAI;MACAG,eAAe,GAAG,IAAAJ,yBAAW,EAACI,eAAe,EAAE;QAC3CF,2BAA2B;QAC3BC,0BAA0B;QAC1BI,wBAAwB,EAAE;MAC9B,CAAC,CAAC;IACN,CAAC,CAAC,OAAOC,KAAK,EAAE;MACZC,OAAO,CAACC,IAAI,CAAC,8DAA8D,EAAEF,KAAK,CAAC;IACvF;EACJ;EAEA,OAAO;IACHhB,IAAI,EAAEY,eAAe;IACrBX;EACJ,CAAC;AACL,CAAC;AAACqB,OAAA,CAAAzB,kBAAA,GAAAA,kBAAA","ignoreList":[]}
1
+ {"version":3,"file":"formatString.js","names":["_escape","require","_formatBBCode","_formatMarkdown","formatStringToHtml","string","options","html","tables","parseMarkdown","parseMarkdownOption","parseBBCode","parseBBCodeOption","customInlineLevelBBCodeTags","customBlockLevelBBCodeTags","formattedString","push","getMarkdownTables","error","console","warn","escapeHtmlInText","justEscapeSquareBrackets","replace","unescapeBBCodeSquareBrackets","exports"],"sources":["../../../../src/utils/formatString/formatString.ts"],"sourcesContent":["import type { TableObject } from '../../types/format';\nimport { escapeHtmlInText } from '../escape';\nimport {\n parseBBCode,\n ParseBBCodesOptions,\n unescapeBBCodeSquareBrackets,\n} from './bb-code/formatBBCode';\nimport { getMarkdownTables, parseMarkdown } from './markdown/formatMarkdown';\n\ninterface FormatStringOptions extends ParseBBCodesOptions {\n parseMarkdown?: boolean;\n parseBBCode?: boolean;\n}\n\ninterface FormatStringResult {\n html: string;\n tables: TableObject[];\n}\n\n// This function takes a string and returns formatted html as a string.\nexport const formatStringToHtml = (\n string: string,\n options?: FormatStringOptions,\n): FormatStringResult => {\n if (!string) {\n return {\n html: '',\n tables: [],\n };\n }\n\n const {\n parseMarkdown: parseMarkdownOption = true,\n parseBBCode: parseBBCodeOption = false,\n customInlineLevelBBCodeTags = [],\n customBlockLevelBBCodeTags = [],\n } = options || {};\n\n let formattedString = string;\n\n // Needs to get the tables before escaping html and parsing bb-code, so the original content can be extracted.\n const tables: TableObject[] = [];\n if (parseMarkdownOption) {\n try {\n tables.push(...getMarkdownTables(formattedString));\n } catch (error) {\n console.warn(\n '[@chayns-components/format] Warning: Failed to get markdown tables',\n error,\n );\n }\n }\n\n // Escape HTML entities.\n formattedString = escapeHtmlInText(formattedString);\n\n // Escape BB-Code, to prevent conflicts between markdown and bb-code. Specifically [b]test[/b]() would be a problem, since markdown interprets parts of this as a link.\n\n // Parses markdown to HTML.\n if (parseMarkdownOption) {\n try {\n if (parseBBCodeOption) {\n // Escapes BB-Code brackets.\n formattedString = parseBBCode(formattedString, {\n customInlineLevelBBCodeTags,\n customBlockLevelBBCodeTags,\n justEscapeSquareBrackets: true,\n });\n }\n\n formattedString = parseMarkdown(formattedString, parseBBCodeOption);\n\n // Remove trailing \\n\n formattedString = formattedString.replace(/\\n$/, '');\n\n if (parseBBCodeOption) {\n // Unescapes BB-Code brackets.\n formattedString = unescapeBBCodeSquareBrackets(formattedString);\n }\n } catch (error) {\n console.warn('[@chayns-components/format] Warning: Failed to parse markdown', error);\n }\n }\n\n // Parses BB-Code to HTML.\n if (parseBBCodeOption) {\n try {\n formattedString = parseBBCode(formattedString, {\n customInlineLevelBBCodeTags,\n customBlockLevelBBCodeTags,\n });\n formattedString = unescapeBBCodeSquareBrackets(formattedString);\n } catch (error) {\n console.warn('[@chayns-components/format] Warning: Failed to parse bb-code', error);\n }\n }\n\n return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