docs/lib/render-content
Peter Bengtsson 9c47ca166e
speed up link checker on PR (#32992)
2022-11-28 22:10:22 +00:00
..
plugins remove legacy asset plugin (#23588) 2022-07-11 14:06:53 -07:00
README.md Fix liquidjs link 2022-08-25 18:31:28 -04:00
create-processor.js speed up link checker on PR (#32992) 2022-11-28 22:10:22 +00:00
doctocat-link-icon.js Use Doctocat link header style (#21615) 2021-09-21 18:14:38 -04:00
index.js remove liquid tags (#20937) 2021-08-18 15:52:44 +00:00
liquid.js Pretty format (#20352) 2021-07-14 14:35:01 -07:00
renderContent.js optimize render of textOnly snippets (#31581) 2022-10-11 17:52:03 +00:00

README.md

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:

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