docs/lib/render-content
Jason Etcovitch f2c08b31a8
Static method isn't a thing on this version? (#17580)
2021-01-29 17:38:50 -05:00
..
plugins Static method isn't a thing on this version? (#17580) 2021-01-29 17:38:50 -05:00
README.md Move render-content code to this repo (#16544) 2020-11-25 11:20:23 -05:00
create-processor.js Remove cheerio from Page#render (#17566) 2021-01-29 15:44:50 -05:00
index.js Sublanding page all guides section (#16869) 2021-01-18 12:23:23 +00:00
liquid.js Move render-content code to this repo (#16544) 2020-11-25 11:20:23 -05:00
renderContent.js Move the rewriteLocalLinks behavior to an AST pipeline plugin (#17550) 2021-01-29 15:36:17 +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.