{"id":13822984,"url":"https://github.com/microformats/microformats-parser","last_synced_at":"2025-05-12T17:25:17.400Z","repository":{"id":37958208,"uuid":"263029247","full_name":"microformats/microformats-parser","owner":"microformats","description":"A JavaScript microformats parser for the browser and node.js","archived":false,"fork":false,"pushed_at":"2024-09-16T10:19:18.000Z","size":1824,"stargazers_count":58,"open_issues_count":9,"forks_count":11,"subscribers_count":5,"default_branch":"main","last_synced_at":"2025-05-12T17:24:44.330Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"https://microformats.github.io/microformats-parser/","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/microformats.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":"CONTRIBUTING.md","funding":null,"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}},"created_at":"2020-05-11T11:58:26.000Z","updated_at":"2025-03-15T00:44:22.000Z","dependencies_parsed_at":"2023-12-18T11:46:49.492Z","dependency_job_id":"4a414408-1a58-437f-87d1-9246c5680546","html_url":"https://github.com/microformats/microformats-parser","commit_stats":{"total_commits":203,"total_committers":5,"mean_commits":40.6,"dds":0.3349753694581281,"last_synced_commit":"c9c33a5d20f633d48756f9624a9bb904e4202cc7"},"previous_names":[],"tags_count":20,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/microformats%2Fmicroformats-parser","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/microformats%2Fmicroformats-parser/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/microformats%2Fmicroformats-parser/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/microformats%2Fmicroformats-parser/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/microformats","download_url":"https://codeload.github.com/microformats/microformats-parser/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":253785727,"owners_count":21964019,"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":[],"created_at":"2024-08-04T08:02:27.753Z","updated_at":"2025-05-12T17:25:17.378Z","avatar_url":"https://github.com/microformats.png","language":"TypeScript","readme":"# microformats-parser\n\nA JavaScript microformats v2 parser, with v1 back-compatibility. [View the demo](https://microformats.github.io/microformats-parser/). Works with both the browser and node.js.\n\nFollows the [microformats2 parsing specification](http://microformats.org/wiki/microformats2-parsing).\n\n**Table of contents**\n\n- [Quick start](#quick-start)\n  - [Installation](#installation)\n  - [Simple use](#simple-use)\n- [API](#api)\n  - [mf2()](#mf2)\n- [Support](#support)\n  - [Microformats v1](#microformats-v1)\n  - [Microformats v2](#microformats-v2)\n  - [Experimental options](#experimental-options)\n    - [`lang`](#lang)\n    - [`textContent`](#textcontent)\n    - [`metaformats`](#metaformats)\n- [Contributing](#contributing)\n\n## Quick start\n\n### Installation\n\n```bash\n# yarn\nyarn add microformats-parser\n\n# npm\nnpm i microformats-parser\n```\n\n### Simple use\n\n```javascript\nconst { mf2 } = require(\"microformats-parser\");\n\nconst parsed = mf2('\u003ca class=\"h-card\" href=\"/\" rel=\"me\"\u003eJimmy\u003c/a\u003e', {\n  baseUrl: \"http://example.com/\",\n});\n\nconsole.log(parsed);\n```\n\nOutputs:\n\n```json\n{\n  \"items\": [\n    {\n      \"properties\": {\n        \"name\": [\"Jimmy\"],\n        \"url\": [\"http://example.com/\"]\n      },\n      \"type\": [\"h-card\"]\n    }\n  ],\n  \"rel-urls\": {\n    \"http://example.com\": {\n      \"rels\": [\"me\"],\n      \"text\": \"Jimmy\"\n    }\n  },\n  \"rels\": {\n    \"me\": [\"http://example.com/\"]\n  }\n}\n```\n\n## API\n\n### mf2()\n\nUse: `mf2(html: string, options: { baseUrl: string, experimental: object })`\n\n- `html` (string, required) - the HTML string to be parsed\n- `options` (object, required) - parsing options, with the following properties:\n  - `baseUrl` (string, required) - a base URL to resolve relative URLs\n  - `experimental` (object, optional) - experimental (non-standard) options\n    - `lang` (boolean, optional) - enable support for parsing `lang` attributes\n    - `textContent` (boolean, optional) - enable support for better collapsing whitespace in text content.\n    - `metaformats` (boolean, optional) - enable meta tag fallback.\n\nReturns the parsed microformats from the HTML string\n\n## Support\n\n### Microformats v1\n\nThis package will parse microformats v1, however support will be limited to the v1 tests in the [microformats test suite](https://github.com/microformats/tests). Contributions are still welcome for improving v1 support.\n\n### Microformats v2\n\nWe provide support for all microformats v2 parsing, as detailed in the [microformats2 parsing specification](http://microformats.org/wiki/microformats2-parsing). If there is an issue with v2 parsing, please create an issue.\n\n### Experimental options\n\nThere is also support for some experimental parsing options. These can be enabled with the `experimental` flags in the `options` API.\n\n**Note: Experimental options are subject to change at short notice and may change their behaviour without a major version update**\n\n#### `lang`\n\nParse microformats for `lang` attributes. This will include `lang` on microformats and `e-*` properties where available.\n\nThese are sourced from the element themselves, a parent microformat, the HTML document or a meta tag.\n\n#### `textContent`\n\nWhen parsing microformats for text content, all the consecutive whitespace is collapsed into a single space. `\u003cbr/\u003e` and `\u003cp\u003e` tags are treated as line breaks.\n\n#### `metaformats`\n\nEnables fallback to [metaformats](https://microformats.org/wiki/metaformats) parsing which looks at `\u003cmeta\u003e` tags to infer content.\n\n## Contributing\n\nSee our [contributing guidelines](./CONTRIBUTING.md) for more information.\n","funding_links":[],"categories":["TypeScript"],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmicroformats%2Fmicroformats-parser","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmicroformats%2Fmicroformats-parser","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmicroformats%2Fmicroformats-parser/lists"}