{"id":23034471,"url":"https://github.com/r4ai/remark-embed","last_synced_at":"2025-08-14T16:32:00.829Z","repository":{"id":245635287,"uuid":"818815496","full_name":"r4ai/remark-embed","owner":"r4ai","description":"A remark plugin to embed the content of the URL.","archived":false,"fork":false,"pushed_at":"2025-08-07T16:28:42.000Z","size":1686,"stargazers_count":4,"open_issues_count":7,"forks_count":1,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-08-08T21:24:32.074Z","etag":null,"topics":["link-card","oembed","ogp","open-graph","remark","remark-plugin"],"latest_commit_sha":null,"homepage":"https://jsr.io/@r4ai/remark-embed","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/r4ai.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"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,"zenodo":null}},"created_at":"2024-06-23T00:29:09.000Z","updated_at":"2025-08-01T00:35:13.000Z","dependencies_parsed_at":"2024-06-23T05:01:56.715Z","dependency_job_id":"003845d2-ce0e-4a58-9952-2a8d9aaae691","html_url":"https://github.com/r4ai/remark-embed","commit_stats":null,"previous_names":["r4ai/remark-embed"],"tags_count":6,"template":false,"template_full_name":null,"purl":"pkg:github/r4ai/remark-embed","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/r4ai%2Fremark-embed","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/r4ai%2Fremark-embed/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/r4ai%2Fremark-embed/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/r4ai%2Fremark-embed/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/r4ai","download_url":"https://codeload.github.com/r4ai/remark-embed/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/r4ai%2Fremark-embed/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":269659349,"owners_count":24455103,"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-09T02:00:10.424Z","response_time":111,"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":["link-card","oembed","ogp","open-graph","remark","remark-plugin"],"created_at":"2024-12-15T16:32:09.729Z","updated_at":"2025-08-14T16:32:00.437Z","avatar_url":"https://github.com/r4ai.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# @r4ai/remark-embed\n\n[![JSR](https://jsr.io/badges/@r4ai/remark-embed)](https://jsr.io/@r4ai/remark-embed)\n[![codecov](https://codecov.io/gh/r4ai/remark-embed/graph/badge.svg?token=B9EZXC0PR8)](https://codecov.io/gh/r4ai/remark-embed)\n[![CI](https://github.com/r4ai/remark-embed/actions/workflows/ci.yml/badge.svg)](https://github.com/r4ai/remark-embed/actions/workflows/ci.yml)\n[![Version or Publish](https://github.com/r4ai/remark-embed/actions/workflows/changeset-version.yml/badge.svg)](https://github.com/r4ai/remark-embed/actions/workflows/changeset-version.yml)\n[![CodeQL](https://github.com/r4ai/remark-embed/actions/workflows/github-code-scanning/codeql/badge.svg)](https://github.com/r4ai/remark-embed/actions/workflows/github-code-scanning/codeql)\n\nA remark plugin to embed the content of the URL.\n\n## Features\n\n- Embed website using [oEmbed](https://en.wikipedia.org/wiki/OEmbed) by [`transformerOEmbed`](https://jsr.io/@r4ai/remark-embed/doc/transformers/~/transformerOEmbed)\n  - YouTube\n  - Spotify\n  - SpeakerDeck\n  - ...\n- Generate link card using [Open Graph](https://ogp.me/) metadata by [`transformerLinkCard`](https://jsr.io/@r4ai/remark-embed/doc/transformers/~/transformerLinkCard)\n  - Twitter\n  - Facebook\n  - ...\n- Fully customizable with [transformers](https://jsr.io/@r4ai/remark-embed/doc/~/RemarkEmbedOptions.transformers)\n  - You can define your own [transformer](https://jsr.io/@r4ai/remark-embed/doc/~/Transformer)\n\n### About this plugin\n\nThis plugin rewrite a paragraph containing only a URL, such as the following, into any element through the [transformer](https://jsr.io/@r4ai/remark-embed/doc/~/Transformer).\n\n```md\nhttps://example.com/hoge\n```\n\n\u003e [!note]\n\u003e Note that URLs such as the following will not be converted:\n\u003e\n\u003e - `according to https://example.com/hoge`\n\u003e - `[example](https://example.com/hoge)`\n\u003e\n\u003e URL must be the only content in the paragraph.\n\u003e\n\u003e Also, if there is no blank line before and after the paragraph, it will not be converted.\n\n### Transformer\n\nCurrently, this plugin provides the following transformers:\n\n- [`transformerOEmbed`](https://jsr.io/@r4ai/remark-embed/doc/transformers/~/transformerOEmbed) - embeds the URL content by fetching the oEmbed metadata\n- [`transformerLinkCard`](https://jsr.io/@r4ai/remark-embed/doc/transformers/~/transformerLinkCard) - generates a link card by fetching the Open Graph metadata\n\nYou can also define your own [transformer](https://jsr.io/@r4ai/remark-embed/doc/~/Transformer). Please refer to the transformer in the [./src/transformers](./src/transformers) directory for details on how to define them.\n\nFollowing is the algorithm of how this plugin will apply the transformers.\n\n1. let `elements` be a list of link nodes such that each node's parent paragraph contains only one link\\\n   Example: `elements = [{ type: 'link', url: 'https://example.com/hoge' }]`\n2. for each `element` of `elements`, do the following in parallel:\n   1. let `url` be the `element`'s url value.\n   2. for each `transformer` of `transformers`, do the following in sequence:\n      1. if `transformer.match(url)` is `true`:\n         1. replace the `element`'s tag name with the result of `transformer.tagName(url)`\n         2. replace the `element`'s properties with the result of `transformer.properties(url)`\n         3. replace the `element`'s children with the result of `transformer.children(url)`\n\n## Installation\n\n- **Bun**:\n\n  ```sh\n  bun add @r4ai/remark-embed\n  ```\n\n- **Deno**:\n\n  ```sh\n  deno add @r4ai/remark-embed\n  ```\n\n- **NPM**:\n\n  ```sh\n  npm install @r4ai/remark-embed\n  ```\n\n- **PNPM**:\n\n  ```sh\n  pnpm add @r4ai/remark-embed\n  ```\n\n- **Yarn**:\n\n  ```sh\n  yarn add @r4ai/remark-embed\n  ```\n\n## Usage\n\n```ts\nimport rehypeStringify from \"rehype-stringify\";\nimport remarkParse from \"remark-parse\";\nimport remarkRehype from \"remark-rehype\";\nimport { unified } from \"unified\";\nimport remarkEmbed from \"@r4ai/remark-embed\";\nimport { transformerOEmbed } from \"@r4ai/remark-embed/transformers\";\n\nconst md = `\n\u003chttps://www.youtube.com/watch?v=jNQXAC9IVRw\u003e\n`;\n\nconst html = (\n  await unified()\n    .use(remarkParse)\n    .use(remarkRehype)\n    .use(remarkEmbed, {\n      transformers: [transformerOEmbed()],\n    })\n    .use(rehypeStringify)\n    .process(md)\n).toString();\n\nconsole.log(html);\n```\n\nYields:\n\n```html\n\u003cp\u003e\n  \u003cdiv class=\"oembed oembed-video\"\u003e\n    \u003ciframe\n      width=\"200\"\n      height=\"150\"\n      src=\"https://www.youtube.com/embed/jNQXAC9IVRw?feature=oembed\"\n      frameborder=\"0\"\n      allow=\"accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture; web-share\"\n      referrerpolicy=\"strict-origin-when-cross-origin\"\n      allowfullscreen\n      title=\"Me at the zoo\"\u003e\n    \u003c/iframe\u003e\n  \u003c/div\u003e\n\u003c/p\u003e\n```\n\n## Documentation\n\nSee: \u003chttps://jsr.io/@r4ai/remark-embed/doc\u003e\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fr4ai%2Fremark-embed","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fr4ai%2Fremark-embed","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fr4ai%2Fremark-embed/lists"}