Registry / serialization / markdown-it-emoji

markdown-it-emoji

JSON →
library3.0.0jsnpmunverified

markdown-it-emoji is a plugin for the `markdown-it` markdown parser, providing comprehensive support for emoji and emoticon syntax. It parses both standard Unicode emoji shortcodes (e.g., `:smile:`) and common emoticons (e.g., `:)`, `:-(`), converting them into their respective Unicode characters by default. The current stable version is 3.0.0. While no explicit release cadence is stated, it follows the `markdown-it` ecosystem, generally releasing new major versions to align with significant changes or improvements. Key differentiators include its tight integration with `markdown-it`'s plugin architecture, offering configurable emoji sets (full, light, bare), and allowing custom rendering functions for integration with libraries like Twemoji or custom icon fonts. It handles both ESM and CommonJS environments, with specific export changes introduced in v3.

npm install markdown-it-emoji
INSTALL
IMPORT
SIG · MARKDOWN-IT-EMOJI
M
markdown-it-emoji
serializationjavascriptv3.0.0
Install
Import
Disk
Pass rate
0/ 6
Env Coverage0 / 6
glibc
1822
musl
1822
Install & Compatibility
Where this runs
tested against v? · npm install
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
musl
node 18226 runs
build_error
glibc
node 18226 runs
build_error
Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

emoji
import { full as emoji } from 'markdown-it-emoji'
import emoji from 'markdown-it-emoji'
Version 3.0.0 changed exports to named exports for specific configurations (`full`, `light`, `bare`). Default import is no longer available. `require()` for ESM-only packages in v3 will fail.
markdownit
import markdownit from 'markdown-it'
import { markdownit } from 'markdown-it'
The `markdown-it` library typically uses a default export for its main constructor, which should be imported directly without destructuring.
twemoji
import twemoji from 'twemoji'
import { twemoji } from 'twemoji'
`twemoji` is commonly imported as a default export when used for custom emoji rendering. Ensure it's installed as a separate dependency if you plan to use it.

Demonstrates initializing `markdown-it` with the `markdown-it-emoji` plugin, using the `full` emoji set, and rendering a markdown string containing both standard and custom-configured emoticons/emojis.

import markdownit from 'markdown-it'; import { full as emoji } from 'markdown-it-emoji'; // Initialize markdown-it with the emoji plugin const md = markdownit().use(emoji, { // Example: Customize shortcuts shortcuts: { "hello_world": [":hi:", ":wave:"] } }); // Markdown content with emojis and custom shortcuts const markdownContent = ` Hello from mars :satellite:! I'm so happy :smile:. Let's wave: :hi: :wave:. `; // Render the markdown to HTML const htmlOutput = md.render(markdownContent); console.log(htmlOutput); // Expected output for :satellite:, :smile:, :hi:, :wave: // <p>Hello from mars 📡! // I'm so happy 😊. // Let's wave: 👋 👋.</p>
Debug
Known issues
breakingVersion 3.0.0 introduced breaking changes to the module exports. Previously, a default export might have been used, but now specific named exports (`full`, `light`, `bare`) must be imported.
fix
Update import statements from `import emoji from 'markdown-it-emoji'` or `const emoji = require('markdown-it-emoji')` to `import { full as emoji } from 'markdown-it-emoji'` (or `light`/`bare` as needed).
affects: >=3.0.0
gotchaWhen `markdown-it-emoji` is loaded directly into a browser environment without a module bundler, it exposes itself globally as `markdownitEmoji`, which might conflict with other scripts or lead to unexpected global state.
fix
Prefer using a module bundler like Webpack or Rollup for browser environments to manage dependencies and avoid global pollution, or ensure unique naming if manual script loading is unavoidable.
affects: >=1.0.0
gotchaWhen using Twemoji for custom rendering, rendered emoji images may not align correctly with line height without specific CSS. The default `twemoji.parse` output might also require additional configuration for size and type.
fix
Add `.emoji { height: 1.2em; }` CSS to ensure vertical alignment. Consult Twemoji documentation for `twemoji.parse` options (e.g., `size`, `ext`) to control image attributes.
affects: >=1.0.0
gotchaThe default emoji definitions and shortcuts can be overridden via plugin options (`defs`, `shortcuts`). Relying solely on the default set might lead to issues if emoji standards evolve or if specific custom requirements arise.
fix
Review the `defs` and `shortcuts` options to customize or extend the emoji and emoticon mapping to meet specific project requirements or to update to newer emoji sets if desired.
affects: >=1.0.0
Errors
Common errors & fixes
TypeError: markdown_it_emoji_1.full is not a function
Attempting to use a CommonJS `require()` syntax with a package that has switched to ESM named exports in v3, or incorrect default import usage in an ESM context.
fix
Ensure you are using `import { full as emoji } from 'markdown-it-emoji'` in an ESM context, or that your build tools correctly transpile and handle ESM imports for Node.js.
ReferenceError: markdownitEmoji is not defined
Trying to access the global `markdownitEmoji` in a browser environment when the script was loaded via a module system (e.g., import), or the script was not loaded at all.
fix
If using a module bundler, import it as `import { full as emoji } from 'markdown-it-emoji'`. If loading directly in HTML, ensure the script tag is present and correct, and you're accessing `markdownitEmoji` only after the script has fully loaded.
Upgrade
Version history
3.0.0latest on npm
Audit
Dependencies
markdown-itrequiredThe core markdown parser this plugin extends.
twemojioptionalOptional, for custom emoji rendering using Twitter's Twemoji library.
Agent activity
18 hits · last 30 days
node
18
Resources
markdown-it-emoji — npm install markdown-it-emoji · libregistry