{"id":30180967,"url":"https://github.com/streamich/very-small-parser","last_synced_at":"2025-08-12T08:06:39.682Z","repository":{"id":264494176,"uuid":"893407704","full_name":"streamich/very-small-parser","owner":"streamich","description":"Small, no dependencies, Markdown, HTML, and inline CSS parser. Just 4KB, available as ESM module from CDN.","archived":false,"fork":false,"pushed_at":"2025-08-07T18:33:20.000Z","size":6658,"stargazers_count":22,"open_issues_count":13,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-08-07T20:37:40.098Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/streamich.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":".github/FUNDING.yml","license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null},"funding":{"github":"streamich"}},"created_at":"2024-11-24T11:22:19.000Z","updated_at":"2025-07-27T19:56:10.000Z","dependencies_parsed_at":"2024-12-09T10:24:05.332Z","dependency_job_id":"9ca589f9-cd1d-4cc0-b81c-50a922699d70","html_url":"https://github.com/streamich/very-small-parser","commit_stats":null,"previous_names":["streamich/very-small-parser"],"tags_count":15,"template":false,"template_full_name":null,"purl":"pkg:github/streamich/very-small-parser","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/streamich%2Fvery-small-parser","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/streamich%2Fvery-small-parser/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/streamich%2Fvery-small-parser/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/streamich%2Fvery-small-parser/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/streamich","download_url":"https://codeload.github.com/streamich/very-small-parser/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/streamich%2Fvery-small-parser/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":270024697,"owners_count":24514054,"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","status":"online","status_checked_at":"2025-08-12T02:00:09.011Z","response_time":80,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"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":[],"created_at":"2025-08-12T08:06:19.668Z","updated_at":"2025-08-12T08:06:39.670Z","avatar_url":"https://github.com/streamich.png","language":"TypeScript","funding_links":["https://github.com/sponsors/streamich"],"categories":[],"sub_categories":[],"readme":"# `very-small-parser`\n\n- JavaScript parser for Markdown, HTML, and inline CSS.\n- [Tiny](https://cdn.jsdelivr.net/npm/very-small-parser/dist/module.js), just over 4KB.\n- Runs in browser and Node.js.\n- No dependencies.\n- Markdown is parsed into [MDAST (Markdown Abstract Syntax Tree)](https://github.com/syntax-tree/mdast).\n- HTML is parsed into [HAST (Hypertext Abstract Syntax Tree)](https://github.com/syntax-tree/hast).\n\n\n## Usage\n\n[__Live demo__](https://jsfiddle.net/yd5eL1cb/)\n\nOn the web you can simply import the module using a script tag.\n\nUsing ESM.sh:\n\n```html\n\u003cscript type=\"module\"\u003e\n  import { markdown } from '//esm.sh/very-small-parser';\n\n  const ast = markdown.block.parsef('Hello __world__!');\n  console.log(ast);\n\u003c/script\u003e\n```\n\nUsing jsDelivr:\n\n```html\n\u003cscript type=\"module\"\u003e\n  import { markdown } from '//esm.run/very-small-parser';\n\n  const ast = markdown.block.parsef('Hello __world__!');\n  console.log(ast);\n\u003c/script\u003e\n```\n\nTo use TypeScript types or import into a Node.js project, you can install the package from npm:\n\n```sh\nnpm install very-small-parser\n```\n\n\n## Reference\n\n### Markdown\n\nParse Markdown document (block elements):\n\n```js\nimport { markdown } from 'very-small-parser';\n\nconst ast = markdown.block.parsef('Hello __world__!');\n```\n\nParse Markdown inline markup only:\n\n```js\nconst ast = markdown.inline.parse('Hello __world__!');\n```\n\nDetect if text is likely to be a Markdown document:\n\n```js\nimport { is } from 'very-small-parser/lib/markdown/is';\n\nis('Hello __world__!');     // true\nis('\u003cb\u003eHello\u003c/b\u003e!');        // false\n```\n\nPretty-print MDAST back to text:\n\n```js\nimport { markdown } from 'very-small-parser';\nimport { toText } from 'very-small-parser/lib/markdown/block/toText';\n\nconst mdast = markdown.block.parse('Hello __world__!');\nconst text = toText(mdast); // Hello __world__!\n```\n\nConvert MDAST to HAST (Markdown AST to HTML AST):\n\n```js\nimport { markdown } from 'very-small-parser';\nimport { toHast } from 'very-small-parser/lib/markdown/block/toHast';\nimport { toText } from 'very-small-parser/lib/html/toText';\n\nconst mdast = markdown.block.parse('Hello __world__!');\nconst hast = toHast(mdast);\nconst html = toText(hast); // \u003cp\u003eHello \u003cstrong\u003eworld\u003c/strong\u003e!\u003c/p\u003e\n```\n\n\n### HTML\n\nParse HTML to HAST (Hypertext Abstract Syntax Tree):\n\n```js\nimport { html } from 'very-small-parser';\n\nconst ast = html.parse('\u003cb\u003eHello\u003c/b\u003e \u003ci\u003eworld\u003c/i\u003e!');\n```\n\nPretty-print HAST to HTML:\n\n```js\nimport { html } from 'very-small-parser';\nimport { toText } from 'very-small-parser/lib/html/toText';\n\nconst hast = html.parse('\u003cb\u003eHello\u003c/b\u003e \u003ci\u003eworld\u003c/i\u003e!');\nconst html = toText(hast); // '\u003cb\u003eHello\u003c/b\u003e \u003ci\u003eworld\u003c/i\u003e!'\n```\n\nSpecify tabulation size for indentation when pretty-printing:\n\n```js\nimport { html } from 'very-small-parser';\nimport { toText } from 'very-small-parser/lib/html/toText';\n\nconst tab = '  ';\nconst hast = html.parse('\u003cdiv\u003e\u003cb\u003eHello\u003c/b\u003e\u003ci\u003eworld\u003c/i\u003e!\u003c/div\u003e', tab);\nconst html = toText(hast);\n// \u003cdiv\u003e\n//   \u003cb\u003eHello\u003c/b\u003e\n//   \u003ci\u003eworld\u003c/i\u003e\n//   !\n// \u003c/div\u003e\n```\n\nConvert HAST to MDAST (HTML AST to Markdown AST):\n\n```js\nimport { html } from 'very-small-parser';\nimport { toMdast } from 'very-small-parser/lib/html/toMdast';\nimport { toText } from 'very-small-parser/lib/markdown/block/toText';\n\nconst hast = html.parse('\u003cp\u003e\u003cb\u003eHello\u003c/b\u003e \u003ci\u003eworld\u003c/i\u003e!\u003c/p\u003e');\nconst mdast = toMdast(hast);\nconst text = toText(mdast); // __Hello__ _world_!\n```\n\n\n### JSON-ML\n\nJSON-ML is a simple way to represent HTML as JSON. For example, the HTML\n`\u003cb\u003eHello\u003c/b\u003e` is represented as `['b', null, 'Hello']`. The first element is\nthe tag name, the second is the attributes, and the rest are children.\n\nThis package contains converters for JSON-ML to HAST and back. See the [`/src/html/json-ml`](./src/html/json-ml/) directory.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fstreamich%2Fvery-small-parser","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fstreamich%2Fvery-small-parser","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fstreamich%2Fvery-small-parser/lists"}