github-markdown-batch-render
v1.1.0
Published
To batch-render Markdown strings via GitHub's API (using Octokit/REST). For mitigating GitHub's API's request rate-limit.
Downloads
4
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
npm i github-markdown-batch-render
Usage
Basic usage:
const markdowns = [
'**bold** _italic_',
'# Title\n\nParagrapgh',
'```\nCodeblock\n```'
]
const renderedMarkdowns = await ghMdBatchRender(markdowns)
/**
* 'renderedMarkdowns' will be: [
* '<p><strong>bold</strong> <em>italic</em></p>',
* '<h1>Title</h1>\n<p>Paragrapgh</p>',
* '<pre class="notranslate"><code class="notranslate">Codeblock\n</code></pre>'
* ]
*/
Force use an Octokit
instance:
const octokit = new Octokit({ auth: 'personalaccesstoken' })
const renderedMarkdowns = await ghMdBatchRender(markdowns, { octokit })
Passing mode
/ context
option(s) to the Octokit.rest.markdown.render
method:
Note:
ghMdBatchRender
'smode
option defaults to"gfm"
unlike Octokit, which defaults to"markdown"
.
const renderedMarkdowns = await ghMdBatchRender(markdowns, {
mode: 'markdown', // default is "gfm"
context: 'github/linguist',
})