GithubHelp home page GithubHelp logo

evitanrelta / github-markdown-batch-render Goto Github PK

View Code? Open in Web Editor NEW
0.0 1.0 0.0 24 KB

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

Home Page: https://www.npmjs.com/package/github-markdown-batch-render

License: MIT License

TypeScript 100.00%
markdown markdown-renderer batch-processing batch-rendering gfm github-api github-flavored-markdown github-markdown octokit

github-markdown-batch-render's Introduction

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's mode option defaults to "gfm" unlike Octokit, which defaults to "markdown".

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

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.