docs/lib/render-content
Hector Alfaro 61885e9e6d
Annotations frontend (#37724)
Co-authored-by: Kevin Heis <heiskr@users.noreply.github.com>
Co-authored-by: Peter Bengtsson <peterbe@github.com>
2023-06-12 20:53:31 +00:00
..
plugins Annotations frontend (#37724) 2023-06-12 20:53:31 +00:00
README.md Add README images to internal-docs folder (#36346) 2023-04-12 16:31:32 +00:00
create-processor.js Code-headers plugin rewrite (#37654) 2023-06-12 15:04:49 +00:00
index.js Move annotate from Liquid to info string (#37651) 2023-06-08 19:25:23 +00:00
liquid.js Remove ver_gt and ver_lt (#35838) 2023-03-23 22:33:59 +00:00
renderContent.js remove all uses of encodeEntities (#34202) 2023-01-26 20:29:04 +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:

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

Screenshot of a code block showing the clipboard icon that is displayed when you use {:copy} annotation.

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