{"id":15413517,"url":"https://github.com/wooorm/create-gfm-fixtures","last_synced_at":"2025-09-26T09:31:12.969Z","repository":{"id":62354757,"uuid":"435983586","full_name":"wooorm/create-gfm-fixtures","owner":"wooorm","description":"Create GFM fixtures","archived":false,"fork":false,"pushed_at":"2024-11-15T13:50:36.000Z","size":69,"stargazers_count":3,"open_issues_count":0,"forks_count":0,"subscribers_count":3,"default_branch":"main","last_synced_at":"2025-01-03T19:36:47.255Z","etag":null,"topics":["gfm","github","markdown"],"latest_commit_sha":null,"homepage":"","language":"JavaScript","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/wooorm.png","metadata":{"files":{"readme":"readme.md","changelog":null,"contributing":null,"funding":"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},"funding":{"github":"wooorm"}},"created_at":"2021-12-07T18:18:00.000Z","updated_at":"2024-11-15T13:50:40.000Z","dependencies_parsed_at":"2024-12-17T22:17:07.307Z","dependency_job_id":null,"html_url":"https://github.com/wooorm/create-gfm-fixtures","commit_stats":{"total_commits":14,"total_committers":1,"mean_commits":14.0,"dds":0.0,"last_synced_commit":"68f03d46d228a7a0c9946cc60056714d9afa34d7"},"previous_names":[],"tags_count":3,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/wooorm%2Fcreate-gfm-fixtures","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/wooorm%2Fcreate-gfm-fixtures/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/wooorm%2Fcreate-gfm-fixtures/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/wooorm%2Fcreate-gfm-fixtures/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/wooorm","download_url":"https://codeload.github.com/wooorm/create-gfm-fixtures/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":234300867,"owners_count":18810667,"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":["gfm","github","markdown"],"created_at":"2024-10-01T16:57:32.299Z","updated_at":"2025-09-26T09:31:12.963Z","avatar_url":"https://github.com/wooorm.png","language":"JavaScript","funding_links":["https://github.com/sponsors/wooorm"],"categories":[],"sub_categories":[],"readme":"# create-gfm-fixtures\n\n[![Build][build-badge]][build]\n[![Coverage][coverage-badge]][coverage]\n\nCreate GFM fixtures.\n\n## Contents\n\n* [What is this?](#what-is-this)\n* [When should I use this?](#when-should-i-use-this)\n* [Install](#install)\n* [Use](#use)\n* [API](#api)\n  * [`createGfmFixtures(url[, options])`](#creategfmfixturesurl-options)\n  * [`Options`](#options)\n  * [`Keep`](#keep)\n* [Types](#types)\n* [Compatibility](#compatibility)\n* [Security](#security)\n* [Contribute](#contribute)\n* [License](#license)\n\n## What is this?\n\nThis is a small tool you can use in tests, with some markdown fixtures, and\nit’ll crawl the HTML that github.com generates for each fixture.\n\nThe problem this solves is that GitHub uses varying closed-source algorithms to\nturn markdown into HTML.\nNotably, there are differences between markdown files in repos, gists, comments\n(including issue and PR posts), and their [`/markdown` endpoint][endpoint].\nThese algos are also all different from their documentation (e.g., [GFM][],\n[Writing on GitHub][])\nSome of these are documented while others have to be reverse engineered.\nThis project helps with the reverse engineering.\n\nGitHub also adds a bunch of “stuff” to user content they render, such as\n`dir=\"auto\"` on each element.\nThis project tries to revert those things that are more specific to `github.com`,\nattempting to uncover the functionality that matches their core markdown\nimplementation instead.\nIn some cases, it is possible in markdown to embed HTML that matches what GitHub\nwould create.\nThe different cleaning tasks here cannot distinguish between GitHub and users,\nand due to this, it’s not possible to use this project to figure out how GitHub\nhandles HTML in markdown.\n\n## When should I use this?\n\nWhen you’re making markdown parsers (as in, [`micromark`][micromark] or\nextensions to it).\n\n## Install\n\nThis package is [ESM only][esm].\nIn Node.js (version 18+), install with [npm][]:\n\n```sh\nnpm install create-gfm-fixtures\n```\n\n## Use\n\n```js\nimport assert from 'node:assert/strict'\nimport fs from 'node:fs/promises'\nimport test from 'node:test'\nimport {createGfmFixtures} from 'create-gfm-fixtures'\n\ntest('fixtures', async function () {\n  const fixtures = new URL('url/to/fixtures/')\n  const input = await fs.readFile(new URL('example.md', fixtures))\n  // ^-- This is our input to some process.\n\n  await createGfmFixtures(fixtures)\n\n  // Now the corresponding HTML is generated.\n  const expected = await fs.readFile(new URL('example.html', fixtures))\n\n  assert.equal('\u003ch1\u003ehi\u003c/h1\u003e', expected)\n  // ^-- Assume this `string` is somehow generated from `input`.\n})\n```\n\n## API\n\nThis package exports the identifier `createGfmFixtures`.\nThere is no default export.\n\n### `createGfmFixtures(url[, options])`\n\nFinds all markdown files (`**/*.md`) inside `url` and generates HTML files for\nthem if they’re either a) missing, b) `UPDATE` is set in env.\n\n###### Parameters\n\n* `url` (`URL`) — URL to folder containing fixtures\n* `options` (`Options`) — configuration (optional)\n\n###### Returns\n\nPromise that resolves when done (`Promise\u003cundefined\u003e`).\n\n###### Configuration from files\n\nEnd markdown files with `file.md` or `comment.md` to choose whether to crawl as\nmarkdown files or as comments.\nThe default is to use “file”.\n\nInclude `offline` in a filename stem part (split on `.`) to never send a\nfixture to GitHub and generate HTML for it.\n\n###### Configuration from env\n\n* pass `UPDATE=1` (any truthy value will do) to regenerate fixtures\n* place a `GH_TOKEN` or `GITHUB_TOKEN` in env when generating files,\n  this token needs a `gist` (Create gists) scope\n\n### `Options`\n\nConfiguration (`Object`, optional) with the following fields:\n\n###### `options.toHtml`\n\nOptions passed to [`hast-util-to-html`][hast-util-to-html-options]\n(`Object`, optional).\n\n###### `options.controlPictures`\n\nWhether to allow [`control-pictures`][control-pictures] in markdown and replace\nthem with the control characters they represent before sending it off to GitHub\n(`boolean`, default: `false`).\n\n###### `options.keep`\n\nParts of the pipeline to keep (`Keep`, optional).\n\n### `Keep`\n\nKeep certain parts of GHs pipeline (`Object`, optional) with the following\nfields:\n\n###### `keep.dir`\n\nKeep `dir=\"auto\"` (`boolean`, default: `false`).\n\n###### `keep.heading`\n\nKeep `.anchor` in headings (`boolean`, default: `false`).\n\n###### `keep.link`\n\nKeep `rel=\"nofollow\"` on links (`boolean`, default: `false`).\n\n###### `keep.camo`\n\nKeep `camo.githubusercontent.com` on images (`boolean`, default: `false`).\n\n###### `keep.image`\n\nKeep `max-width:100%` on images and `a[target=_blank]` parent wrapper\n(`boolean`, default: `false`).\n\n###### `keep.issue`\n\nKeep `.issue-link`s (`boolean`, default: `false`).\n\n###### `keep.mention`\n\nKeep attributes on `.user-mention`s (`boolean`, default: `false`).\n\n###### `keep.table`\n\nKeep the `markdown-accessiblity-table` custom element around tables\n(`boolean`, default: `false`).\n\n###### `keep.tasklist`\n\nKeep classes on tasklist-related elements, and `id` on their inputs\n(`boolean`, default: `false`).\n\n###### `keep.frontmatter`\n\nKeep visible frontmatter (`boolean`, default: `false`).\n\n## Types\n\nThis package is fully typed with [TypeScript][].\nIt exports the additional types `Options` and `Keep`.\n\n## Compatibility\n\nThis package is at least compatible with all maintained versions of Node.js.\nAs of this writing, that is Node.js 18+.\n\n## Security\n\nAssuming you trust the markdown files in your repo, this package is safe.\n\n## Contribute\n\nYes please!\nSee [How to Contribute to Open Source][contribute].\n\n## License\n\n[MIT][license] © [Titus Wormer][author]\n\n\u003c!-- Definitions --\u003e\n\n[build-badge]: https://github.com/wooorm/create-gfm-fixtures/workflows/main/badge.svg\n\n[build]: https://github.com/wooorm/create-gfm-fixtures/actions\n\n[coverage-badge]: https://img.shields.io/codecov/c/github/wooorm/create-gfm-fixtures.svg\n\n[coverage]: https://codecov.io/github/wooorm/create-gfm-fixtures\n\n[npm]: https://docs.npmjs.com/cli/install\n\n[license]: license\n\n[author]: https://wooorm.com\n\n[esm]: https://gist.github.com/sindresorhus/a39789f98801d908bbc7ff3ecc99d99c\n\n[typescript]: https://www.typescriptlang.org\n\n[contribute]: https://opensource.guide/how-to-contribute/\n\n[endpoint]: https://docs.github.com/en/rest/reference/markdown\n\n[micromark]: https://github.com/micromark/micromark\n\n[gfm]: https://github.github.com/gfm/\n\n[writing on github]: https://docs.github.com/en/github/writing-on-github\n\n[hast-util-to-html-options]: https://github.com/syntax-tree/hast-util-to-html#options\n\n[control-pictures]: https://github.com/wooorm/control-pictures\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fwooorm%2Fcreate-gfm-fixtures","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fwooorm%2Fcreate-gfm-fixtures","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fwooorm%2Fcreate-gfm-fixtures/lists"}