showdownjs / showdown

A bidirectional Markdown to HTML to Markdown converter written in Javascript
http://www.showdownjs.com/
MIT License
14.26k stars 1.56k forks source link

Emojis as separate import #753

Open ohepworthbell opened 4 years ago

ohepworthbell commented 4 years ago

I know this issue has sort of been raised in issue #504 and more explicitly in #408, but is there anything in the pipeline for separating emojis into a completely different file? As ShowdownJS can be imported using require() or even ES6 import it would be great to have emojis as a completely separate module that can independently be imported, such like:

import showdown from 'showdown';
// No emojis

or

import {showdown, emojis} from 'showdown';
// Has emojis

That would give much more control over those who don't need/want/require emoji support, and can give much more ability to keep ShowdownJS as customisably streamlined as possible for the speed-conscious folk.

In the long-run, it would be great to also be able to break down the (e.g.) 'flavours' and other 'options' into modules too, to really allow people to further streamline their bundles, something like:

import {showdown, tables, specialChars, emojis} from 'showdown';

new showdown.Converter({
  tables: true,
  specialChars: true,
  emojis: true
});

or

import {showdown, github} from 'showdown';

// And 'github' automatically imports 'tables', 'specialChars', etc...
// Also have 'github' and 'githubNoEmoji'

new showdown.Converter({
  tables: true,
  specialChars: true,
  emojis: true
});

Would be a really sweet addition to the library :)