docs/lib/render-content
Sarah Schneider 534996d81c change ifver to ifversion 2021-06-10 11:53:56 -04:00
..
plugins be more flexible so we do not rewrite hardcoded deprecated versions OR supported 2021-04-26 16:01:44 -04:00
README.md Move render-content code to this repo (#16544) 2020-11-25 11:20:23 -05:00
create-processor.js divs mess up the DOM and create empty <p> tags; use spans instead so they stay nested in <p>s 2021-04-22 11:15:01 -04:00
index.js change ifver to ifversion 2021-06-10 11:53:56 -04:00
liquid.js Use Liquidjs instead of Liquid (#16743) 2021-02-08 12:58:51 -05:00
renderContent.js add option to return cheerio object from renderContent instead of html 2021-02-23 20:30:09 -05: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.