🎉 initiate project *astro_rewrite*
This commit is contained in:
parent
ffd4d5e86c
commit
2ba37bfbe3
8658 changed files with 2268794 additions and 2538 deletions
25
node_modules/astro/dist/vite-plugin-html/transform/escape.js
generated
vendored
Normal file
25
node_modules/astro/dist/vite-plugin-html/transform/escape.js
generated
vendored
Normal file
|
|
@ -0,0 +1,25 @@
|
|||
import { visit } from "unist-util-visit";
|
||||
import { escape, needsEscape, replaceAttribute } from "./utils.js";
|
||||
const rehypeEscape = ({ s }) => {
|
||||
return (tree) => {
|
||||
visit(tree, (node) => {
|
||||
if (node.type === "text" || node.type === "comment") {
|
||||
if (needsEscape(node.value)) {
|
||||
s.overwrite(node.position.start.offset, node.position.end.offset, escape(node.value));
|
||||
}
|
||||
} else if (node.type === "element") {
|
||||
for (const [key, value] of Object.entries(node.properties ?? {})) {
|
||||
const newKey = needsEscape(key) ? escape(key) : key;
|
||||
const newValue = needsEscape(value) ? escape(value) : value;
|
||||
if (newKey === key && newValue === value)
|
||||
continue;
|
||||
replaceAttribute(s, node, key, value === "" ? newKey : `${newKey}="${newValue}"`);
|
||||
}
|
||||
}
|
||||
});
|
||||
};
|
||||
};
|
||||
var escape_default = rehypeEscape;
|
||||
export {
|
||||
escape_default as default
|
||||
};
|
||||
Loading…
Add table
Add a link
Reference in a new issue