ibs-format 1.4.11 → 1.4.12

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 (2) hide show
  1. package/index.js +20 -0
  2. package/package.json +1 -1
package/index.js CHANGED
@@ -1,4 +1,5 @@
1
1
  function ibsFormat(value, arr, linky, escaping) {
2
+ originalArr = JSON.parse(JSON.stringify(arr));
2
3
  let output = null;
3
4
  escaping = escaping && escaping.allowXssEscaping == false ? false : true;
4
5
  if (value) {
@@ -46,9 +47,28 @@ function ibsFormat(value, arr, linky, escaping) {
46
47
  if (output) {
47
48
  output = output.replace(/ <br> /g, "<br>");
48
49
  }
50
+ output = transformContentInsideEm(output);
49
51
  return output ? output.trim() : "";
50
52
  }
51
53
 
54
+ function transformContentInsideEm(inputString) {
55
+ // Define the tag-to-replacement mapping as an array with 3 elements: [tag, symbol, priority]
56
+
57
+ // Match the <em> tag and its content
58
+ return inputString.replace(/<em>(.*?)<\/em>/gs, function(match, content) {
59
+ // Perform tag-to-symbol replacement inside the <em> content
60
+ originalArr.forEach(([tag, replacement]) => {
61
+ // Replace opening and closing tags of each mapped tag with the symbol
62
+ const openTag = new RegExp(`<${tag}>`, 'g');
63
+ const closeTag = new RegExp(`</${tag}>`, 'g');
64
+ content = content.replace(openTag, replacement).replace(closeTag, replacement);
65
+ });
66
+
67
+ // Return the modified <em> tag with converted content
68
+ return `<em>${content}</em>`;
69
+ });
70
+ }
71
+
52
72
  function doubleAstericHandler(text, tag, iden, trim, space) {
53
73
  let box = [];
54
74
  let arr = [];
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "ibs-format",
3
- "version": "1.4.11",
3
+ "version": "1.4.12",
4
4
  "description": "Detect the user-defined identifiers in the text and convert them into HTML tags like bold, italic, strike, and many more having XSS (Cross-site scripting) security with escaping functionality, also detect the links like URLs, email, and IP addresses and wrap them into Anchor tag `<a>`.",
5
5
  "main": "index.js",
6
6
  "scripts": {