{"id":20250358,"url":"https://github.com/cmtegner/jsonml-parse","last_synced_at":"2025-03-03T16:23:27.818Z","repository":{"id":19780268,"uuid":"23039001","full_name":"CMTegner/jsonml-parse","owner":"CMTegner","description":"A JavaScript module for converting markup in text form to JSONML, for Node.js and the browser","archived":false,"fork":false,"pushed_at":"2016-07-25T15:20:59.000Z","size":102,"stargazers_count":2,"open_issues_count":0,"forks_count":1,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-02-14T13:50:46.088Z","etag":null,"topics":["cli","javascript","jsonml","parse"],"latest_commit_sha":null,"homepage":"","language":"HTML","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/CMTegner.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":"2014-08-17T11:23:18.000Z","updated_at":"2023-03-08T04:54:53.000Z","dependencies_parsed_at":"2022-08-24T07:40:36.645Z","dependency_job_id":null,"html_url":"https://github.com/CMTegner/jsonml-parse","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/CMTegner%2Fjsonml-parse","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/CMTegner%2Fjsonml-parse/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/CMTegner%2Fjsonml-parse/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/CMTegner%2Fjsonml-parse/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/CMTegner","download_url":"https://codeload.github.com/CMTegner/jsonml-parse/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":241696901,"owners_count":20004906,"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":["cli","javascript","jsonml","parse"],"created_at":"2024-11-14T09:58:03.637Z","updated_at":"2025-03-03T16:23:27.798Z","avatar_url":"https://github.com/CMTegner.png","language":"HTML","funding_links":[],"categories":[],"sub_categories":[],"readme":"#jsonml-parse\n\nConvert markup (HTML) in text form to [JSONML](http://jsonml.org).\n\n[![Travis CI Build Status](https://travis-ci.org/CMTegner/jsonml-parse.svg)](http://travis-ci.org/CMTegner/jsonml-parse) [![Dependency Status](https://david-dm.org/CMTegner/jsonml-parse/status.svg)](https://david-dm.org/CMTegner/jsonml-parse)\n\n[![NPM Module](https://nodei.co/npm/jsonml-parse.png)](http://npm.im/jsonml-parse)\n\n[![Browser support](https://ci.testling.com/CMTegner/jsonml-parse.png)](https://ci.testling.com/CMTegner/jsonml-parse)\n\n##Example\n\n```js\nvar parse = require('jsonml-parse');\nparse('\u003cbutton class=\"btn\"\u003eAwesome\u003c/button\u003e', function(err, data) {\n    console.dir(data);\n    //-\u003e [\"button\", { \"class\": \"btn\" }, \"Awesome\"]\n});\n```\n\n## Install\n\nWith [npm](http://npmjs.org) do:\n```bash\nnpm install jsonml-parse\n```\n\n`jsonml-parse` also works in the browser, both via [browserify](http://browserify.org) and as a [stand-alone script](http://wzrd.in/standalone/jsonml-parse@latest):\n\n```html\n\u003cscript src=\"http://wzrd.in/standalone/jsonml-parse@latest\"\u003e\u003c/script\u003e\n```\n\n## Usage\n\n```javascript\nvar parse = require('jsonml-parse');\n```\n\n`jsonml-parse` exposed two different API styles: callback and stream.\n\n### parse(markup, callback)\n\nParses the `markup` string and invokes `callback` when done. `callback` is treated as a node-style callback, i.e. the first argument will always be the error object (`null` on success), and the second will always be the JSONML result. *Note:* If `markup` contains multiple top-level nodes they will be wrapped in an array before being passed to `callback`. This will also be the case if your markup has leading and/or trailing whitespace/text. For consistent resuls be sure to `String#trim()` the markup before passing it to `parse()`.\n\n### var stream = parse()\n\nReturns a new [transform stream](http://nodejs.org/api/stream.html#stream_class_stream_transform) which you will write the markup to, and read the JSONML from. *Note:* Each top-level node will be emitted as separate 'data' events. Any whitespace/text before, after, or in between top-level nodes will be treated as a separate top-level nodes, so be sure to handle accordingly in your `data` event handlers.\n\n## CLI\n\n`jsonml-parse` also comes with a CLI tool (`jsonmlparse`):\n\n```bash\n$ jsonmlparse --help\n\nUsage: node jsonmlparse [file] [options]\n\nfile     The file containing the markup to convert to JSONML, will read from stdin if not specified\n\nOptions:\n   -o, --output   Output file, will send to stdout if not specified\n   --version      Print version and exit\n```\n\nExample:\n\n```bash\ncurl www.bbc.co.uk | jsonmlparse \u003e bbc.json\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcmtegner%2Fjsonml-parse","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fcmtegner%2Fjsonml-parse","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcmtegner%2Fjsonml-parse/lists"}