@skalfa/skalfa-component 1.0.32 → 1.0.33

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.
@@ -40,7 +40,7 @@ function parseInlineFormats(text) {
40
40
  function parseContentToHtml(content) {
41
41
  if (!content)
42
42
  return "";
43
- const lines = content.split("\n");
43
+ const lines = content.replace(/\r/g, "").split("\n");
44
44
  const htmlParts = [];
45
45
  let i = 0;
46
46
  while (i < lines.length) {
@@ -58,27 +58,35 @@ function parseContentToHtml(content) {
58
58
  }
59
59
  if (line.match(/^\[list:bullet\]/)) {
60
60
  const items = [];
61
+ let matchedAny = false;
61
62
  while (i < lines.length) {
62
63
  const bm = lines[i].match(/^\[list:bullet\](.*?)\[list\]$/);
63
64
  if (!bm)
64
65
  break;
66
+ matchedAny = true;
65
67
  items.push(`<li>${parseInlineFormats(bm[1])}</li>`);
66
68
  i++;
67
69
  }
68
- htmlParts.push(`<ul>${items.join("")}</ul>`);
69
- continue;
70
+ if (matchedAny) {
71
+ htmlParts.push(`<ul>${items.join("")}</ul>`);
72
+ continue;
73
+ }
70
74
  }
71
75
  if (line.match(/^\[list:number\]/)) {
72
76
  const items = [];
77
+ let matchedAny = false;
73
78
  while (i < lines.length) {
74
79
  const nm = lines[i].match(/^\[list:number\](.*?)\[list\]$/);
75
80
  if (!nm)
76
81
  break;
82
+ matchedAny = true;
77
83
  items.push(`<li>${parseInlineFormats(nm[1])}</li>`);
78
84
  i++;
79
85
  }
80
- htmlParts.push(`<ol>${items.join("")}</ol>`);
81
- continue;
86
+ if (matchedAny) {
87
+ htmlParts.push(`<ol>${items.join("")}</ol>`);
88
+ continue;
89
+ }
82
90
  }
83
91
  const alignMatch = line.match(/^\[align:(left|center|right|justify)\](.*?)\[align\]$/);
84
92
  if (alignMatch) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@skalfa/skalfa-component",
3
- "version": "1.0.32",
3
+ "version": "1.0.33",
4
4
  "description": "Reusable UI components for Skalfa App.",
5
5
  "license": "MIT",
6
6
  "keywords": [
@@ -44,7 +44,7 @@ export function parseInlineFormats(text: string): string {
44
44
  export function parseContentToHtml(content: string): string {
45
45
  if (!content) return "";
46
46
 
47
- const lines = content.split("\n");
47
+ const lines = content.replace(/\r/g, "").split("\n");
48
48
  const htmlParts: string[] = [];
49
49
  let i = 0;
50
50
 
@@ -66,26 +66,34 @@ export function parseContentToHtml(content: string): string {
66
66
 
67
67
  if (line.match(/^\[list:bullet\]/)) {
68
68
  const items: string[] = [];
69
+ let matchedAny = false;
69
70
  while (i < lines.length) {
70
71
  const bm = lines[i].match(/^\[list:bullet\](.*?)\[list\]$/);
71
72
  if (!bm) break;
73
+ matchedAny = true;
72
74
  items.push(`<li>${parseInlineFormats(bm[1])}</li>`);
73
75
  i++;
74
76
  }
75
- htmlParts.push(`<ul>${items.join("")}</ul>`);
76
- continue;
77
+ if (matchedAny) {
78
+ htmlParts.push(`<ul>${items.join("")}</ul>`);
79
+ continue;
80
+ }
77
81
  }
78
82
 
79
83
  if (line.match(/^\[list:number\]/)) {
80
84
  const items: string[] = [];
85
+ let matchedAny = false;
81
86
  while (i < lines.length) {
82
87
  const nm = lines[i].match(/^\[list:number\](.*?)\[list\]$/);
83
88
  if (!nm) break;
89
+ matchedAny = true;
84
90
  items.push(`<li>${parseInlineFormats(nm[1])}</li>`);
85
91
  i++;
86
92
  }
87
- htmlParts.push(`<ol>${items.join("")}</ol>`);
88
- continue;
93
+ if (matchedAny) {
94
+ htmlParts.push(`<ol>${items.join("")}</ol>`);
95
+ continue;
96
+ }
89
97
  }
90
98
 
91
99
  const alignMatch = line.match(/^\[align:(left|center|right|justify)\](.*?)\[align\]$/);