Use GitHub API to render markdown.
npm install @hyrious/gfm !total lines  
This repo provides a site, a cli tool,
a nodejs library and a deno library. Below is the library description.
``shell-session`globally (as cli)
> npm i -g @hyrious/gfmlocally (as library)
> npm i -D @hyrious/gfmdeno see below
As cli:
> Note: only one \*.md maybe passed to gfm, multiple files are ignored.
` content of this file content of this file content of this fileshell-session`
> gfm file.md
> cat file.md | gfmstart a local server (like the site, with hot reloading enabled)
> gfm --serve file.mdyou may want to use a token to increase rate limit,
simply append --token and it will ask for it before going.
> gfm file.md --token
Input Token (invisible):
As library:
`js`
import { render } from "@hyrious/gfm";
const rateLimit = {};
const html = await render("# markdown", { token, rateLimit });
console.log(rateLimit, html);
As deno library (you have to use it with --allow-net):
`ts`
import { render } from "https://esm.run/@hyrious/gfm";
// same interface as nodejs library
As native browser module:
`html`
As iife or umd (like jquery):
`html`
> Note: render results are not cached, you should implement caching on your own.
The library is written in .mjs to use vanilla import in nodejs (since 14).require
It then uses rollup to convert mjs to cjs for users.browser
It uses , module and conditional exports in package.json to support many platforms.
I personally made this package for a reference of the correct way
to support multiple environments in one package.
You (Me) should look at package.json for more details.
package.json with comments
`js``
{
// node's require and import, to override it, see "exports"
"main": "dist/index.js",
// https://nodejs.org/api/packages.html#packages_conditional_exports
"exports": {
"import": "./src/index.mjs",
"require": "./dist/index.js"
},
// front-end bundler read this (like vite or webpack)
"module": "src/index.browser.mjs",
// cdn like jsdelivr read this
"browser": "dist/index.browser.js"
}
MIT @ hyrious