{"id":16223526,"url":"https://github.com/kaisermann/svelte-markup-walker","last_synced_at":"2025-03-19T12:30:29.301Z","repository":{"id":35835785,"uuid":"218896943","full_name":"kaisermann/svelte-markup-walker","owner":"kaisermann","description":"A Svelte preprocessor that allows to walk through the AST generated by the svelte parser and modify the markup with MagicString.","archived":false,"fork":false,"pushed_at":"2023-01-04T12:55:36.000Z","size":340,"stargazers_count":9,"open_issues_count":13,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-02-28T18:37:36.343Z","etag":null,"topics":["ast","markup","preprocess","svelte","walk"],"latest_commit_sha":null,"homepage":"","language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/kaisermann.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2019-11-01T02:18:51.000Z","updated_at":"2023-06-15T07:16:20.000Z","dependencies_parsed_at":"2023-01-16T07:20:24.258Z","dependency_job_id":null,"html_url":"https://github.com/kaisermann/svelte-markup-walker","commit_stats":null,"previous_names":[],"tags_count":1,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kaisermann%2Fsvelte-markup-walker","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kaisermann%2Fsvelte-markup-walker/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kaisermann%2Fsvelte-markup-walker/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kaisermann%2Fsvelte-markup-walker/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/kaisermann","download_url":"https://codeload.github.com/kaisermann/svelte-markup-walker/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":243989419,"owners_count":20379648,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["ast","markup","preprocess","svelte","walk"],"created_at":"2024-10-10T12:19:09.363Z","updated_at":"2025-03-19T12:30:29.029Z","avatar_url":"https://github.com/kaisermann.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Svelte Markup Walker\n\n\u003e A [Svelte](https://svelte.dev) preprocessor that allows to walk through the AST generated by the svelte parser and modify the markup with [MagicString](https://github.com/Rich-Harris/magic-string).\n\nThis library is a simple wrapper of svelte's exported `parse` and `walk` methods. Its default method accepts an option object of AST walker wrappers:\n\n- `html({ content, filename })` for walking through the html AST;\n- `instance({ content, filename })` for walking through the main `script` AST;\n- `module({ content, filename })` for walking through the `context=\"module\"` script AST;\n- `css({ content, filename })` for walking through the `style` AST.\n\nEach wrapper receives as arguments the current `filename` and the file `content` as a [MagicString](https://github.com/Rich-Harris/magic-string), which allows to easily modify/cut/overwrite/replace/etc its text.\n\n```js\nconst markupWalker = require('svelte-markup-walker');\n\n/**\n * `preprocessor` is a svelte preprocessor,\n * just add it to your `preprocess` array\n */\nconst preprocessor = markupWalker({\n  html({ content, filename }) {\n    return {\n      enter(node) { ... },\n      leave(node) { ... },\n    };\n  },\n  instance({ content, filename }) {\n    return {\n      enter(node) { ... },\n      leave(node) { ... },\n    };\n  },\n  module({ content, filename }) {\n    return {\n      enter(node) { ... },\n      leave(node) { ... },\n    };\n  },\n  css({ content, filename }) {\n    return {\n      enter(node) { ... },\n      leave(node) { ... },\n    };\n  },\n});\n```\n\n\n## Example\n\n\u003e TODO\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fkaisermann%2Fsvelte-markup-walker","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fkaisermann%2Fsvelte-markup-walker","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fkaisermann%2Fsvelte-markup-walker/lists"}