@mralfarrakhan/svork 0.6.4 → 0.6.5

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/dist/index.mjs +3 -8
  2. package/package.json +1 -1
package/dist/index.mjs CHANGED
@@ -2245,8 +2245,7 @@ const getPlaceholderReplacement = (token, type, original) => {
2245
2245
  return `<svork-placeholder data-svork-id="${escapeHtmlAttribute(token)}">${escapeHtmlText(surrogate)}</svork-placeholder>`;
2246
2246
  };
2247
2247
  const isSvelteAttribute = (attr) => {
2248
- if (!attr) return false;
2249
- if (attr.type !== "Attribute") return true;
2248
+ if (!attr || attr.type !== "Attribute") return true;
2250
2249
  if (Array.isArray(attr.value)) return attr.value.some((valueNode) => valueNode?.type !== "Text");
2251
2250
  return attr.value?.type === "ExpressionTag";
2252
2251
  };
@@ -2313,7 +2312,7 @@ const maskMarkdownCodeForSvelteParse = (source) => {
2313
2312
  };
2314
2313
  const escapeSvelteTextBraces = (value) => value.replace(/\{/g, "&#123;").replace(/\}/g, "&#125;");
2315
2314
  const escapeRawNodeBraces = (html) => {
2316
- return html.replace(/"([^"]*)"/g, (match, val) => val.includes("<") ? `"${val.replace(/</g, "&lt;").replace(/>/g, "&gt;")}"` : match).replace(/'([^']*)'/g, (match, val) => val.includes("<") ? `'${val.replace(/</g, "&lt;").replace(/>/g, "&gt;")}'` : match).split(/(<(?:script|style)\b[\s\S]*?<\/(?:script|style)\s*>)/gi).map((part, i) => i % 2 === 1 ? part : escapeSvelteTextBraces(part)).join("");
2315
+ return html.replace(/"([^"]*)"/g, (match, val) => val.includes("<") ? `"${val.replace(/</g, "&lt;").replace(/>/g, "&gt;")}"` : match).split(/(<(?:script|style)\b[\s\S]*?<\/(?:script|style)\s*>)/gi).map((part, i) => i % 2 === 1 ? part : escapeSvelteTextBraces(part)).join("");
2317
2316
  };
2318
2317
  function escapeBracesPlugin() {
2319
2318
  return (tree) => {
@@ -2365,13 +2364,9 @@ const svelteMarkdown = (options) => {
2365
2364
  const vfile = await mdCompiler.process(markdownSource);
2366
2365
  let compiled = String(vfile);
2367
2366
  compiled = compiled.replace(/(&amp;#123;|&#x26;#123;)/g, "&#123;").replace(/(&amp;#125;|&#x26;#125;)/g, "&#125;");
2368
- const escapeAttrVal = (val) => val.replace(/</g, "&lt;").replace(/>/g, "&gt;").replace(/\{/g, "&#123;").replace(/\}/g, "&#125;");
2369
2367
  compiled = compiled.replace(/"([^"]*)"/g, (match, val) => {
2370
2368
  if (!val.includes("<") && !val.includes("{") && !val.includes("}")) return match;
2371
- return `"${escapeAttrVal(val)}"`;
2372
- }).replace(/'([^']*)'/g, (match, val) => {
2373
- if (!val.includes("<") && !val.includes("{") && !val.includes("}")) return match;
2374
- return `'${escapeAttrVal(val)}'`;
2369
+ return `"${val.replace(/</g, "&lt;").replace(/>/g, "&gt;").replace(/\{/g, "&#123;").replace(/\}/g, "&#125;")}"`;
2375
2370
  });
2376
2371
  let restored = compiled;
2377
2372
  if (vfile.data?.fm && typeof vfile.data.fm === "object") metadata = {
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@mralfarrakhan/svork",
3
3
  "type": "module",
4
- "version": "0.6.4",
4
+ "version": "0.6.5",
5
5
  "description": "Svelte utilities for writing blog",
6
6
  "author": "mralfarrakhan <alfarrakhan@gmail.com",
7
7
  "license": "AGPL-3.0-or-later",