@webmate-studio/builder 0.2.96 → 0.2.98
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/package.json +1 -1
- package/src/design-tokens.js +2 -2
- package/src/markdown.js +12 -18
package/package.json
CHANGED
package/src/design-tokens.js
CHANGED
|
@@ -7,7 +7,7 @@ function generateSemanticColorUtilities(tokens) {
|
|
|
7
7
|
if (!tokens.colors) return '';
|
|
8
8
|
|
|
9
9
|
let utilities = '\n/* Color Utilities */';
|
|
10
|
-
utilities += '\n@layer
|
|
10
|
+
utilities += '\n@layer utilities {';
|
|
11
11
|
|
|
12
12
|
// Map of all colors: token name -> utility class base name
|
|
13
13
|
const colorMap = {
|
|
@@ -175,7 +175,7 @@ function generateSemanticColorUtilities(tokens) {
|
|
|
175
175
|
}
|
|
176
176
|
}
|
|
177
177
|
|
|
178
|
-
utilities += '\n}'; // Close @layer
|
|
178
|
+
utilities += '\n}'; // Close @layer utilities
|
|
179
179
|
|
|
180
180
|
return utilities;
|
|
181
181
|
}
|
package/src/markdown.js
CHANGED
|
@@ -20,10 +20,10 @@ marked.setOptions({
|
|
|
20
20
|
});
|
|
21
21
|
|
|
22
22
|
/**
|
|
23
|
-
* Shift heading levels in HTML
|
|
23
|
+
* Shift heading levels in HTML
|
|
24
24
|
* @param {string} html - HTML string
|
|
25
25
|
* @param {number} startLevel - The level that h1 should become (e.g., 2 means h1 → h2)
|
|
26
|
-
* @returns {string} HTML with shifted heading levels
|
|
26
|
+
* @returns {string} HTML with shifted heading levels
|
|
27
27
|
*/
|
|
28
28
|
function shiftHeadingLevels(html, startLevel) {
|
|
29
29
|
if (!startLevel || startLevel === 1) return html;
|
|
@@ -35,24 +35,11 @@ function shiftHeadingLevels(html, startLevel) {
|
|
|
35
35
|
for (let level = 6; level >= 1; level--) {
|
|
36
36
|
const newLevel = Math.min(level + offset, 6);
|
|
37
37
|
if (newLevel !== level) {
|
|
38
|
-
//
|
|
39
|
-
// e.g., H1 becoming H2 gets class="text-heading-1" to keep H1 styles
|
|
40
|
-
const styleClass = `text-heading-${level}`;
|
|
41
|
-
|
|
42
|
-
// Replace opening tag and add class
|
|
38
|
+
// Replace opening and closing tags
|
|
43
39
|
html = html.replace(
|
|
44
40
|
new RegExp(`<h${level}(\\s|>)`, 'gi'),
|
|
45
|
-
|
|
46
|
-
// If there's already a space (attributes exist), add class
|
|
47
|
-
if (afterTag === ' ') {
|
|
48
|
-
return `<h${newLevel} class="${styleClass}"`;
|
|
49
|
-
}
|
|
50
|
-
// Otherwise, add class before closing >
|
|
51
|
-
return `<h${newLevel} class="${styleClass}">`;
|
|
52
|
-
}
|
|
41
|
+
`<h${newLevel}$1`
|
|
53
42
|
);
|
|
54
|
-
|
|
55
|
-
// Replace closing tags
|
|
56
43
|
html = html.replace(
|
|
57
44
|
new RegExp(`</h${level}>`, 'gi'),
|
|
58
45
|
`</h${newLevel}>`
|
|
@@ -70,6 +57,7 @@ function shiftHeadingLevels(html, startLevel) {
|
|
|
70
57
|
* @param {object} options - Optionale Konfiguration
|
|
71
58
|
* @param {boolean} options.sanitize - HTML sanitizen (default: true)
|
|
72
59
|
* @param {number} options.headingStartLevel - Start level for headings (1-6, default: 1)
|
|
60
|
+
* @param {boolean} options.wrapProse - Wrap with .prose class (default: true)
|
|
73
61
|
* @returns {string} - Sicherer HTML-String
|
|
74
62
|
*/
|
|
75
63
|
export function markdownToHtml(markdown, options = {}) {
|
|
@@ -102,7 +90,8 @@ export function markdownToHtml(markdown, options = {}) {
|
|
|
102
90
|
'blockquote', 'pre', 'code',
|
|
103
91
|
'a', 'img',
|
|
104
92
|
'table', 'thead', 'tbody', 'tr', 'th', 'td',
|
|
105
|
-
'hr', 'abbr', 'cite', 'mark', 'small', 'sub', 'sup'
|
|
93
|
+
'hr', 'abbr', 'cite', 'mark', 'small', 'sub', 'sup',
|
|
94
|
+
'div'
|
|
106
95
|
],
|
|
107
96
|
ALLOWED_ATTR: [
|
|
108
97
|
'href', 'title', 'alt', 'src',
|
|
@@ -115,6 +104,11 @@ export function markdownToHtml(markdown, options = {}) {
|
|
|
115
104
|
html = purify.sanitize(html, config);
|
|
116
105
|
}
|
|
117
106
|
|
|
107
|
+
// Wrap with .prose for automatic styling (can be disabled with options.wrapProse = false)
|
|
108
|
+
if (options.wrapProse !== false) {
|
|
109
|
+
html = `<div class="prose">${html}</div>`;
|
|
110
|
+
}
|
|
111
|
+
|
|
118
112
|
return html;
|
|
119
113
|
}
|
|
120
114
|
|