Skip to content

Commit

Permalink
fix(preprocess-inline-svg): unscape & during preprocessing
Browse files Browse the repository at this point in the history
  • Loading branch information
vnphanquang committed Oct 4, 2024
1 parent fd22b57 commit 15de2df
Show file tree
Hide file tree
Showing 4 changed files with 42 additions and 12 deletions.
6 changes: 6 additions & 0 deletions .changeset/small-oranges-joke.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---
"@svelte-put/preprocess-inline-svg": patch
---

unescape & to & during preprocessing (fixes #322)

5 changes: 3 additions & 2 deletions packages/preprocess-inline-svg/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -68,8 +68,9 @@
"dependencies": {
"hast-util-to-html": "^9.0.1",
"lodash.debounce": "^4.0.8",
"magic-string": "^0.30.9",
"svelte-parse-markup": "^0.1.2",
"magic-string": "^0.30.10",
"svelte-parse-markup": "^0.1.5",
"svg-parser": "^2.0.4"
}
}

Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,8 @@ export function transform(
);
}

const hast = parseSvg(fs.readFileSync(svgSource, 'utf8'));
const svgStr = fs.readFileSync(svgSource, 'utf8').replace(/&/g, '&');
const hast = parseSvg(svgStr);
const svg = hast.children[0] as ElementNode;

const attributes = {
Expand Down Expand Up @@ -199,3 +200,4 @@ export function transform(
map: s.generateMap(),
};
}

39 changes: 30 additions & 9 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 15de2df

Please sign in to comment.