teledzik 1.1.0 → 1.1.4
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.
|
@@ -26,7 +26,7 @@ function formatTableToCard(tableHtml) {
|
|
|
26
26
|
const isHeaderRow = hasHeader && rows.length > 1 && (/^(parameter|informasi|metrik|field|key|unit|format|statistik|opsi|nama|item|rincian)$/i.test(rows[0][0].replace(/<[^>]*>/g, '').trim()) ||
|
|
27
27
|
/^(status|keterangan|detail|nilai|value|jumlah|estimasi|tipe|contoh input)$/i.test(rows[0][1].replace(/<[^>]*>/g, '').trim()));
|
|
28
28
|
const dataRows = isHeaderRow ? rows.slice(1) : rows;
|
|
29
|
-
const lines = dataRows.map((r) =>
|
|
29
|
+
const lines = dataRows.map((r) => ` <b>${r[0]}:</b> ${r[1]}`);
|
|
30
30
|
cardText = `<blockquote>\n${lines.join('\n')}\n</blockquote>\n\n`;
|
|
31
31
|
}
|
|
32
32
|
else {
|
|
@@ -74,7 +74,7 @@ function sanitizeRichHtml(html) {
|
|
|
74
74
|
result = result.replace(/<tg-math-block[^>]*>([\s\S]*?)<\/tg-math-block>/gi, (_, c) => `<pre><code>${c.trim()}</code></pre>\n\n`);
|
|
75
75
|
result = result.replace(/<tg-reference[^>]*>([\s\S]*?)<\/tg-reference>/gi, (_, c) => `<i>${c.trim()}</i>`);
|
|
76
76
|
result = result.replace(/<mark[^>]*>([\s\S]*?)<\/mark>/gi, (_, c) => `<b>[${c.trim()}]</b>`);
|
|
77
|
-
result = result.replace(/<figure[^>]*>[\s\S]
|
|
77
|
+
result = result.replace(/<figure[^>]*>([\s\S]*?)<figcaption[^>]*>([\s\S]*?)<\/figcaption><\/figure>/gi, (_, body, cap) => `${body}\n<i>📷 ${cap.trim()}</i>\n`);
|
|
78
78
|
result = result.replace(/<p[^>]*>([\s\S]*?)<\/p>/gi, (_, c) => `${c.trim()}\n\n`);
|
|
79
79
|
result = result.replace(/<footer[^>]*>([\s\S]*?)<\/footer>/gi, (_, c) => `<i>${c.trim()}</i>\n`);
|
|
80
80
|
result = result.replace(/<br\s*\/?>/gi, '\n');
|
|
@@ -83,7 +83,8 @@ function sanitizeRichHtml(html) {
|
|
|
83
83
|
result = result.replace(/<sub[^>]*>([\s\S]*?)<\/sub>/gi, '$1');
|
|
84
84
|
result = result.replace(/<sup[^>]*>([\s\S]*?)<\/sup>/gi, '$1');
|
|
85
85
|
result = result.replace(/<tg-(map|collage|slideshow)[^>]*>([\s\S]*?)<\/tg-\1>/gi, '$2');
|
|
86
|
-
result = result.replace(/<(
|
|
86
|
+
result = result.replace(/<img[^>]*src="([^"]+)"[^>]*\/?>/gi, '<a href="$1">‍</a>');
|
|
87
|
+
result = result.replace(/<(video|audio|tg-map)[^>]*\/?>/gi, '');
|
|
87
88
|
return result.replace(/\n{3,}/g, '\n\n').trim();
|
|
88
89
|
}
|
|
89
90
|
exports.sanitizeRichHtml = sanitizeRichHtml;
|
package/package.json
CHANGED
|
@@ -15,16 +15,16 @@ function formatTableToCard(tableHtml: string): string {
|
|
|
15
15
|
if (rows.length === 0) return ''
|
|
16
16
|
|
|
17
17
|
// Header vs Row handling (Format sebagai Kartu Elegan)
|
|
18
|
-
const isKeyValue = rows.length > 0 && rows.every((r) => r.length === 2)
|
|
19
|
-
let cardText = ''
|
|
18
|
+
const isKeyValue = rows.length > 0 && rows.every((r) => r.length === 2)
|
|
19
|
+
let cardText = ''
|
|
20
20
|
if (isKeyValue) {
|
|
21
21
|
const isHeaderRow = hasHeader && rows.length > 1 && (
|
|
22
22
|
/^(parameter|informasi|metrik|field|key|unit|format|statistik|opsi|nama|item|rincian)$/i.test(rows[0][0].replace(/<[^>]*>/g, '').trim()) ||
|
|
23
23
|
/^(status|keterangan|detail|nilai|value|jumlah|estimasi|tipe|contoh input)$/i.test(rows[0][1].replace(/<[^>]*>/g, '').trim())
|
|
24
|
-
)
|
|
25
|
-
const dataRows = isHeaderRow ? rows.slice(1) : rows
|
|
26
|
-
const lines = dataRows.map((r) =>
|
|
27
|
-
cardText = `<blockquote>\n${lines.join('\n')}\n</blockquote>\n\n
|
|
24
|
+
)
|
|
25
|
+
const dataRows = isHeaderRow ? rows.slice(1) : rows
|
|
26
|
+
const lines = dataRows.map((r) => ` <b>${r[0]}:</b> ${r[1]}`)
|
|
27
|
+
cardText = `<blockquote>\n${lines.join('\n')}\n</blockquote>\n\n`
|
|
28
28
|
} else {
|
|
29
29
|
const lines = rows.map((r, idx) => {
|
|
30
30
|
if (idx === 0 && hasHeader) return `<b>${r.join(' │ ')}</b>`
|
|
@@ -81,7 +81,7 @@ export function sanitizeRichHtml(html: string): string {
|
|
|
81
81
|
result = result.replace(/<tg-reference[^>]*>([\s\S]*?)<\/tg-reference>/gi, (_, c) => `<i>${c.trim()}</i>`)
|
|
82
82
|
result = result.replace(/<mark[^>]*>([\s\S]*?)<\/mark>/gi, (_, c) => `<b>[${c.trim()}]</b>`)
|
|
83
83
|
|
|
84
|
-
result = result.replace(/<figure[^>]*>[\s\S]
|
|
84
|
+
result = result.replace(/<figure[^>]*>([\s\S]*?)<figcaption[^>]*>([\s\S]*?)<\/figcaption><\/figure>/gi, (_, body, cap) => `${body}\n<i>📷 ${cap.trim()}</i>\n`)
|
|
85
85
|
|
|
86
86
|
result = result.replace(/<p[^>]*>([\s\S]*?)<\/p>/gi, (_, c) => `${c.trim()}\n\n`)
|
|
87
87
|
result = result.replace(/<footer[^>]*>([\s\S]*?)<\/footer>/gi, (_, c) => `<i>${c.trim()}</i>\n`)
|
|
@@ -92,7 +92,8 @@ export function sanitizeRichHtml(html: string): string {
|
|
|
92
92
|
result = result.replace(/<sub[^>]*>([\s\S]*?)<\/sub>/gi, '$1')
|
|
93
93
|
result = result.replace(/<sup[^>]*>([\s\S]*?)<\/sup>/gi, '$1')
|
|
94
94
|
result = result.replace(/<tg-(map|collage|slideshow)[^>]*>([\s\S]*?)<\/tg-\1>/gi, '$2')
|
|
95
|
-
result = result.replace(/<(
|
|
95
|
+
result = result.replace(/<img[^>]*src="([^"]+)"[^>]*\/?>/gi, '<a href="$1">‍</a>')
|
|
96
|
+
result = result.replace(/<(video|audio|tg-map)[^>]*\/?>/gi, '')
|
|
96
97
|
|
|
97
98
|
return result.replace(/\n{3,}/g, '\n\n').trim()
|
|
98
99
|
}
|