{"id":13672879,"url":"https://github.com/vivaxy/WXML","last_synced_at":"2025-04-28T04:30:29.532Z","repository":{"id":57169210,"uuid":"143952530","full_name":"vivaxy/WXML","owner":"vivaxy","description":"See https://github.com/oft/wxml.","archived":true,"fork":false,"pushed_at":"2024-05-24T05:34:18.000Z","size":1435,"stargazers_count":12,"open_issues_count":11,"forks_count":5,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-04-17T17:17:48.165Z","etag":null,"topics":["miniprogram","mp","parse","parse-wxml","parser","serialize","serialize-wxml","serializer","stringify","traverse","traverse-wxml","traverser","weixin","wxml","wxml-parser","wxml-serializer","wxml-traverser","wxmp"],"latest_commit_sha":null,"homepage":"https://github.com/vivaxy/WXML","language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/vivaxy.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":".github/FUNDING.yml","license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":"CITATION.cff","codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null},"funding":{"patreon":"vivaxy","open_collective":"vivaxy_personal","custom":["https://gist.github.com/vivaxy/58eed1803a2eddda05c90aed99430de2"]}},"created_at":"2018-08-08T02:48:36.000Z","updated_at":"2024-05-24T05:34:21.000Z","dependencies_parsed_at":"2024-06-22T21:31:26.966Z","dependency_job_id":null,"html_url":"https://github.com/vivaxy/WXML","commit_stats":null,"previous_names":[],"tags_count":13,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/vivaxy%2FWXML","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/vivaxy%2FWXML/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/vivaxy%2FWXML/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/vivaxy%2FWXML/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/vivaxy","download_url":"https://codeload.github.com/vivaxy/WXML/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":251251763,"owners_count":21559656,"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":["miniprogram","mp","parse","parse-wxml","parser","serialize","serialize-wxml","serializer","stringify","traverse","traverse-wxml","traverser","weixin","wxml","wxml-parser","wxml-serializer","wxml-traverser","wxmp"],"created_at":"2024-08-02T09:01:54.600Z","updated_at":"2025-04-28T04:30:28.862Z","avatar_url":"https://github.com/vivaxy.png","language":"TypeScript","readme":"# WXML\n\n🌇WXML parser and serializer.\n\n[![Build Status][travis-image]][travis-url]\n[![NPM Version][npm-version-image]][npm-url]\n[![NPM Downloads][npm-downloads-image]][npm-url]\n[![MIT License][license-image]][license-url]\n[![Standard Version][standard-version-image]][standard-version-url]\n[![Codecov][codecov-image]][codecov-url]\n[![DOI](https://zenodo.org/badge/143952530.svg)](https://zenodo.org/badge/latestdoi/143952530)\n\n# Install\n\n`yarn add @vivaxy/wxml` or `npm i @vivaxy/wxml --save`\n\n# Usage\n\n```js\nimport * as wxml from '@vivaxy/wxml';\nconst parsed = wxml.parse('\u003cview\u003e\u003c/view\u003e');\nwxml.traverse(parsed, function visitor(node, parent) {\n  const type = node.type;\n  const parentNode = node.parentNode;\n\n  if (type === wxml.NODE_TYPES.ELEMENT) {\n    // handle element node\n    const tagName = node.tagName;\n    const attributes = node.attributes; // an object represents the attributes\n    const childNodes = node.childNodes;\n    const selfClosing = node.selfClosing; // if a node is self closing, like `\u003ctag /\u003e`\n  } else if (type === wxml.NODE_TYPES.TEXT) {\n    // handle text node\n    const textContent = node.textContent;\n  } else if (type === wxml.NODE_TYPES.COMMENT) {\n    // handle comment node\n    const comment = node.comment;\n  }\n});\nconst serialized = wxml.serialize(parsed);\n```\n\n# API\n\n## `parse`\n\n`(input: string) =\u003e AST`\n\n## `traverse`\n\n`(node: Node, visitor: (node: Node, parent: Node) =\u003e void) =\u003e void`\n\n## `serialize`\n\n`(node: Node) =\u003e string`\n\n[travis-image]: https://img.shields.io/travis/vivaxy/WXML.svg?style=flat-square\n[travis-url]: https://travis-ci.org/vivaxy/WXML\n[npm-version-image]: https://img.shields.io/npm/v/@vivaxy/wxml.svg?style=flat-square\n[npm-url]: https://www.npmjs.com/package/@vivaxy/wxml\n[npm-downloads-image]: https://img.shields.io/npm/dt/@vivaxy/wxml.svg?style=flat-square\n[license-image]: https://img.shields.io/npm/l/@vivaxy/wxml.svg?style=flat-square\n[license-url]: LICENSE\n[standard-version-image]: https://img.shields.io/badge/release-standard%20version-brightgreen.svg?style=flat-square\n[standard-version-url]: https://github.com/conventional-changelog/standard-version\n[codecov-image]: https://img.shields.io/codecov/c/github/vivaxy/WXML.svg?style=flat-square\n[codecov-url]: https://codecov.io/gh/vivaxy/WXML\n","funding_links":["https://patreon.com/vivaxy","https://opencollective.com/vivaxy_personal","https://gist.github.com/vivaxy/58eed1803a2eddda05c90aed99430de2"],"categories":["TypeScript"],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fvivaxy%2FWXML","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fvivaxy%2FWXML","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fvivaxy%2FWXML/lists"}