@github-docs/render-content

5.2.1 • Public • Published

@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.

Code block headers

You can add a header to code blocks by adding the {:copy} annotation after the code fences:

```js{:copy}
const copyMe = true
```

This renders:

image

The un-highlighted text is available as button.js-btn-copy's data-clipboard-text attribute.

License

MIT

Versions

Current Tags

VersionDownloads (Last 7 Days)Tag
5.2.16latest

Version History

VersionDownloads (Last 7 Days)Published
5.2.16
5.2.01
5.1.01
5.0.00
4.0.00
3.0.10
3.0.00
2.3.30
2.3.20
2.3.10
2.3.01
2.2.01
2.1.10
2.1.00
2.0.00
1.1.10
1.1.00
1.0.11
1.0.01

Package Sidebar

Install

npm i @github-docs/render-content

Weekly Downloads

12

Version

5.2.1

License

MIT

Unpacked Size

35.7 kB

Total Files

11

Last publish

Collaborators

  • sarahs
  • zeke