unified

Project: remarkjs/remark-gemoji

Package: remark-gemoji@5.0.0

  1. Dependencies: 1·Dependents: 3
  2. remark plugin to parse Gemoji shortcodes
  1. remark 186
  2. unified 154
  3. plugin 131
  4. markdown 115
  5. mdast 81
  6. remark-plugin 71
  7. github 8
  8. emoji 5
  9. gemoji 2

remark-gemoji

Build Coverage Downloads Size Sponsors Backers Chat

remark plugin to parse Gemoji shortcodes.

Install

npm:

npm install remark-gemoji

Use

Say example.js looks as follows (note: remark-gemoji isn’t used):

var unified = require('unified')
var parse = require('remark-parse')

var tree = unified()
  .use(parse, {pedantic: true, position: false})
  .parse(':heavy_check_mark:')

console.dir(tree, {depth: null})

Running node example yields:

{ type: 'root',
  children:
   [ { type: 'paragraph',
       children:
        [ { type: 'text', value: ':heavy' },
          { type: 'emphasis',
            children: [ { type: 'text', value: 'check' } ] },
          { type: 'text', value: 'mark:' } ] } ] }

If we now add remark-gemoji by applying the following diff to example.js:

 var parse = require('remark-parse')
+var gemoji = require('remark-gemoji')

 var tree = unified()
   .use(parse, {pedantic: true, position: false})
+  .use(gemoji)
   .parse(':heavy_check_mark:')

If we now run node example again, you’ll see the following:

{ type: 'root',
  children:
   [ { type: 'paragraph',
       children: [ { type: 'text', value: ':heavy_check_mark:' } ] } ] }

API

remark().use(gemoji)

Plugin to parse Gemoji shortcodes. This doesn’t do much other than creating whole Text nodes for Gemoji, and ensuring Gemoji shortcodes with underscores are not seen as emphasis in pedantic mode.

Note: when compiling, pedantic must be false! Otherwise, the underscores in Gemoji shortcodes are still escaped.

Although, GitHub itself doesn’t care: :heavy\_check\_mark:.

Security

Use of remark-gemoji does not involve rehype (hast) or user content so there are no openings for cross-site scripting (XSS) attacks.

Contribute

See contributing.md in remarkjs/.github for ways to get started. See support.md for ways to get help.

This project has a code of conduct. By interacting with this repository, organization, or community you agree to abide by its terms.

License

MIT © Titus Wormer