@farming-labs/svelte 0.0.9 → 0.0.10
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/dist/markdown.js +6 -5
- package/package.json +2 -2
package/dist/markdown.js
CHANGED
|
@@ -86,17 +86,18 @@ function parseMeta(meta) {
|
|
|
86
86
|
const titleMatch = meta.match(/title=["']([^"']+)["']/);
|
|
87
87
|
return { lang, title: titleMatch ? titleMatch[1] : null };
|
|
88
88
|
}
|
|
89
|
-
function wrapCodeWithCopy(html, rawCode, title) {
|
|
89
|
+
function wrapCodeWithCopy(html, rawCode, title, language) {
|
|
90
90
|
const escapedRaw = rawCode
|
|
91
91
|
.replace(/&/g, "&")
|
|
92
92
|
.replace(/"/g, """)
|
|
93
93
|
.replace(/</g, "<")
|
|
94
94
|
.replace(/>/g, ">");
|
|
95
|
+
const dataLang = language ? ` data-language="${String(language).replace(/"/g, """)}"` : "";
|
|
95
96
|
const copyBtn = `<button class="fd-copy-btn" data-code="${escapedRaw}" title="Copy code"><svg width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><rect x="9" y="9" width="13" height="13" rx="2" ry="2"/><path d="M5 15H4a2 2 0 01-2-2V4a2 2 0 012-2h9a2 2 0 012 2v1"/></svg></button>`;
|
|
96
97
|
if (title) {
|
|
97
|
-
return `<div class="fd-codeblock fd-codeblock--titled"><div class="fd-codeblock-title"><svg width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M15 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V7Z"/><path d="M14 2v4a2 2 0 0 0 2 2h4"/></svg><span class="fd-codeblock-title-text">${title}</span>${copyBtn}</div><div class="fd-codeblock-content">${html}</div></div>`;
|
|
98
|
+
return `<div class="fd-codeblock fd-codeblock--titled"${dataLang}><div class="fd-codeblock-title"><svg width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M15 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V7Z"/><path d="M14 2v4a2 2 0 0 0 2 2h4"/></svg><span class="fd-codeblock-title-text">${title}</span>${copyBtn}</div><div class="fd-codeblock-content">${html}</div></div>`;
|
|
98
99
|
}
|
|
99
|
-
return `<div class="fd-codeblock">${copyBtn}<div class="fd-codeblock-content">${html}</div></div>`;
|
|
100
|
+
return `<div class="fd-codeblock"${dataLang}>${copyBtn}<div class="fd-codeblock-content">${html}</div></div>`;
|
|
100
101
|
}
|
|
101
102
|
function dedentCode(raw) {
|
|
102
103
|
const lines = raw.replace(/\n$/, "").split("\n");
|
|
@@ -137,7 +138,7 @@ export async function renderMarkdown(content) {
|
|
|
137
138
|
const { lang, title } = parseMeta(codeMatch[1]);
|
|
138
139
|
const dedented = dedentCode(codeMatch[2]);
|
|
139
140
|
const { html, raw } = highlightCode(hl, dedented, lang);
|
|
140
|
-
panels.push({ value: tabValue, html: wrapCodeWithCopy(html, raw, title) });
|
|
141
|
+
panels.push({ value: tabValue, html: wrapCodeWithCopy(html, raw, title, lang) });
|
|
141
142
|
}
|
|
142
143
|
else {
|
|
143
144
|
panels.push({ value: tabValue, html: `<p>${tabContent}</p>` });
|
|
@@ -163,7 +164,7 @@ export async function renderMarkdown(content) {
|
|
|
163
164
|
const { lang, title } = parseMeta(meta);
|
|
164
165
|
const { html, raw } = highlightCode(hl, code, lang);
|
|
165
166
|
const placeholder = `%%CODEBLOCK_${codeBlocks.length}%%`;
|
|
166
|
-
codeBlocks.push(wrapCodeWithCopy(html, raw, title));
|
|
167
|
+
codeBlocks.push(wrapCodeWithCopy(html, raw, title, lang));
|
|
167
168
|
return placeholder;
|
|
168
169
|
});
|
|
169
170
|
// Inline code
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@farming-labs/svelte",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.10",
|
|
4
4
|
"description": "SvelteKit adapter for @farming-labs/docs — content loading and navigation utilities",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"docs",
|
|
@@ -50,7 +50,7 @@
|
|
|
50
50
|
"devDependencies": {
|
|
51
51
|
"@types/node": "^22.10.0",
|
|
52
52
|
"typescript": "^5.9.3",
|
|
53
|
-
"@farming-labs/docs": "0.0.
|
|
53
|
+
"@farming-labs/docs": "0.0.10"
|
|
54
54
|
},
|
|
55
55
|
"peerDependencies": {
|
|
56
56
|
"@farming-labs/docs": "*"
|