1
0
mirror of synced 2025-12-19 18:10:59 -05:00
Files
docs/lib/render-content
Peter Bengtsson 07a3e2a48c Preview hover cards (#34702)
Co-authored-by: Grace Park <gracepark@github.com>
Co-authored-by: Joe Oak <41307427+joeoak@users.noreply.github.com>
2023-03-21 19:59:49 +00:00
..
2023-03-21 19:59:49 +00:00
2021-08-18 15:52:44 +00:00
2021-07-14 14:35:01 -07:00

Markdown and Liquid rendering pipeline.

Usage

const renderContent = require('.')

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

Creates:

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

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:

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