Skip to content

How to add additional shortcuts? #55

@markg85

Description

@markg85

Hi,

I'm trying to add additional shortcuts like so:

import markdownIt from 'markdown-it'
import { full as emoji } from 'markdown-it-emoji'
const md = markdownIt()
  .use(emoji, {
    shortcuts: {
        "fa-eye": [":fa-eye:"]
    }
  })

I'm trying to support font-awesome (now fork-awesome) support. Typing :fa-eye: should render the fork-awesome emoji for that. I know how to do that part (emoji rule overwrite to handle the fa-* emoji's) but i'm stuck at even defining additional shortcuts.

When debugging that shortcut that i'm adding is present in this code (full.mjs in this project):

export default function emoji_plugin (md, options) {
  const defaults = {
    defs: emojies_defs,
    shortcuts: emojies_shortcuts,
    enabled: []
  }

  const opts = md.utils.assign({}, defaults, options || {})

  bare_emoji_plugin(md, opts)
};

However, after the line:

const opts = md.utils.assign({}, defaults, options || {})

It's already reduced to just my shortcut. The default ones emojies_shortcuts get lost here.
Next, it's passed into the bare_emoji_plugin via bare_emoji_plugin(md, opts).

In the bare handling this line:

const opts = normalize_opts(md.utils.assign({}, defaults, options || {}))

Removes anything that was there, the resulting opts.shortcuts is now empty {}...

Am i doing something wrong here?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions