Registry / serialization / showdown

showdown

JSON →
library0.1.0.dev0jsnpmunverified

Showdown is an open-source JavaScript library designed for converting Markdown formatted text into HTML. It is a robust, cross-platform solution, capable of operating both client-side in web browsers and server-side within Node.js environments. The current stable version is 2.1.0, with releases occurring periodically to address bugs, update dependencies, and introduce features; for instance, version 2.0.0 primarily focused on maintenance, updating its `yargs` dependency and Node.js support. Key differentiators include its foundational basis on John Gruber's original Markdown specifications, long-standing stability, and an experimental HTML to Markdown converter introduced in version 1.9.0, providing versatile bidirectional conversion capabilities. Unlike some newer, more opinionated Markdown parsers, Showdown offers extensive configuration options to control the conversion process, allowing users to enable or disable various Markdown features.

npm install showdown
INSTALL
IMPORT
SIG · SHOWDOWN
S
showdown
serializationjavascriptv0.1.0.dev0
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.

Converter
import { Converter } from 'showdown';
import showdown from 'showdown';
For modern ESM environments (e.g., Node.js with type:module or bundlers), `Converter` is a named export. The default export might be undefined or an unexpected object in some setups.
showdown (CommonJS object)
const showdown = require('showdown');
const { Converter } = require('showdown');
In CommonJS (Node.js < 14, or CJS modules), `require('showdown')` returns an object containing the `Converter` class and other utilities. The `Converter` class is accessed as `showdown.Converter`.
Converter (Global in browser)
const converter = new showdown.Converter();
const converter = new Converter();
When loaded directly in a browser via a `<script>` tag (e.g., from CDN), the `showdown` object is exposed globally on `window`, containing the `Converter` class.

This quickstart demonstrates how to initialize the Showdown converter with several common options (emoji, strikethrough, tables, tasklists) and convert a Markdown string into an HTML string using CommonJS syntax.

const showdown = require('showdown'); const converter = new showdown.Converter({ emoji: true, strikethrough: true, tables: true, tasklists: true, openLinksInNewWindow: true }); const markdownText = ` # Hello, Showdown! This is a **Markdown** example with some common features. - List item 1 - List item 2 - Sub-item ~~Strikethrough text~~ and an :emoji:! 🎉 | Header 1 | Header 2 | |---|---| | Cell 1 | Cell 2 | - [x] Task 1 (completed) - [ ] Task 2 (pending) [Visit ShowdownJS](https://showdownjs.com/) `; const html = converter.makeHtml(markdownText); console.log(html); // Expected output: An HTML string representing the converted Markdown.
Debug
Known issues
breakingThe command-line interface (CLI) for `showdown` changed how 'extra options' are passed. Instead of direct flags like `--strikethrough`, you must now use the `-c` flag for each option.
fix
Update your CLI commands. For example, `showdown makehtml -i foo.md -o bar.html --strikethrough --emoji` becomes `showdown makehtml -i foo.md -o bar.html -c strikethrough -c emoji`.
affects: >=2.1.0
breakingSupported Node.js versions were updated to align with the official Node.js release schedule. This dropped support for older, unmaintained Node.js versions.
fix
Ensure your Node.js environment is running a version in the 'Current', 'Active', or 'Maintenance' phase (e.g., 12.x, 14.x, 16.x, 17.x at the time of the 2.0.0 release). Upgrade Node.js if necessary.
affects: >=2.0.0
breakingThe library's license changed from BSD to MIT with the 2.0.0 release. This primarily affects legal compliance and redistribution terms.
fix
Review the new MIT license terms if your project's licensing or distribution depends on Showdown's license.
affects: >=2.0.0
gotchaThe `yargs` dependency, used for CLI parsing, was updated to mitigate security vulnerabilities. While primarily an internal change, it could potentially introduce subtle behavioral differences or require adjustments if you relied on specific `yargs` behaviors in custom CLI scripts.
fix
Test your CLI scripts and custom integrations thoroughly after upgrading to ensure no unexpected changes in argument parsing or behavior.
affects: >=2.0.0
gotchaWhile Showdown claims compatibility with very old browsers (e.g., IE6, Firefox 1.5), using it in such environments may not be practical or fully functional with modern Markdown features. Modern development typically targets more recent browser versions.
fix
For new projects, ensure you are testing against contemporary browser versions. If targeting extremely old browsers, be prepared for potential edge cases or feature limitations.
affects: *
Errors
Common errors & fixes
ReferenceError: showdown is not defined
The Showdown library was not properly loaded in the browser environment, or accessed incorrectly in a module context.
fix
In browsers, ensure you have included `<script src="path/to/showdown.min.js"></script>` before attempting to use it. In a module, ensure it's imported via `require` or `import`.
TypeError: showdown.Converter is not a constructor
Attempted to call `showdown.Converter()` as a function instead of instantiating it with `new`.
fix
Always use `new showdown.Converter()` to create a new converter instance.
Error: Unknown option: --strikethrough (or other CLI options)
Using the pre-v2.1.0 CLI syntax for extra options after upgrading to Showdown 2.1.0 or newer.
fix
For CLI options like `strikethrough` or `emoji`, use the `-c` flag for each option. E.g., `showdown makehtml -i input.md -o output.html -c strikethrough -c emoji`.
ReferenceError: require is not defined
Attempting to use CommonJS `require()` in an ECMAScript Module (ESM) context (e.g., a Node.js file with `"type": "module"` in `package.json`).
fix
Refactor your import statements to use ESM syntax: `import { Converter } from 'showdown';` and then `new Converter();`.
Upgrade
Version history
0.1.0.dev0latest on npm
Audit
Dependencies

No dependency data recorded yet.

Agent activity
5 hits · last 30 days
node
4
Resources