fejes713 / render-content

✏️ Markdown and Liquid rendering pipeline for Node.js

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

@github-docs/render-content

Markdown and Liquid rendering pipeline for Node.js

Usage

const renderContent = require('@github-docs/render-content')

const html = await renderContent(`
# Beep
{{ foo }}
`, {
  foo: 'bar'
})

Creates:

<h1 id="beep"><a href="#beep">Beep</a></h1>
<p>bar</p>

Installation

$ npm install @github-docs/render-content

API

renderContent(markdown, context = {}, options = {})

Render a string of markdown with optional context. Returns a Promise.

Liquid will be looking for includes in ${process.cwd()}/includes.

Options:

  • encodeEntities: Encode html entities. Default: false.
  • fileName: File name for debugging purposes.
  • textOnly: Output text instead of html using cheerio.

.liquid

The Liquid instance used internally.

.liquidOcticons(string)

Render Octicons in string. Returns a String.

Examples:

{{ octicon-kebab-horizontal The horizontal kebab icon }}

With optional color:

{{ octicon-diff-removed The diff removed icon color-red }}

.extendMarkdown(string)

Extend the following markdown tags:

  • mac
  • windows
  • linux
  • all
  • tip (with extra styling)
  • note (with extra styling)
  • warning (with extra styling)
  • danger (with extra styling)

From

{{#TAG}}
content
{{/TAG}}

To

<div class="extended-markdown TAG EXTRA_STYLING">
content
</div>

Returns a String.

License

MIT

About

✏️ Markdown and Liquid rendering pipeline for Node.js


Languages

Language:JavaScript 100.0%