Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/evitanrelta/github-markdown-batch-render

To batch-render Markdown strings via GitHub's API (using Octokit/REST). For mitigating GitHub's API's request rate-limit.
https://github.com/evitanrelta/github-markdown-batch-render

batch-processing batch-rendering gfm github-api github-flavored-markdown github-markdown markdown markdown-renderer octokit

Last synced: about 1 month ago
JSON representation

To batch-render Markdown strings via GitHub's API (using Octokit/REST). For mitigating GitHub's API's request rate-limit.

Awesome Lists containing this project

README

        

# Batch render markdowns via GitHub-API

For batch-rendering an array of Markdown strings via GitHub's API *(using Octokit/REST)*.

Uses only 1 GitHub-API request to render all the markdown strings.

> Useful for mitigating GitHub's API's request rate-limit.


## Install

```bash
npm i github-markdown-batch-render
```


## Usage

Basic usage:

````typescript
const markdowns = [
'**bold** _italic_',
'# Title\n\nParagrapgh',
'```\nCodeblock\n```'
]
const renderedMarkdowns = await ghMdBatchRender(markdowns)
/**
* 'renderedMarkdowns' will be: [
* '

bold italic

',
* '

Title

\n

Paragrapgh

',
* '
Codeblock\n
'
* ]
*/
````


Force use an `Octokit` instance:

```typescript
const octokit = new Octokit({ auth: 'personalaccesstoken' })
const renderedMarkdowns = await ghMdBatchRender(markdowns, { octokit })
```


Passing `mode` / `context` option(s) to the [`Octokit.rest.markdown.render`](https://octokit.github.io/rest.js/v19#markdown-render) method:

> Note: `ghMdBatchRender`'s `mode` option defaults to `"gfm"` unlike Octokit, which defaults to `"markdown"`.

```typescript
const renderedMarkdowns = await ghMdBatchRender(markdowns, {
mode: 'markdown', // default is "gfm"
context: 'github/linguist',
})
```