Registry / serialization / kramed

kramed

JSON →
library0.5.6jsnpmunverified

A markdown parser and compiler forked from marked, designed to be kramdown-compatible and support MathJax. The current stable version is 0.5.6, with no active development since 2016. It offers synchronous and asynchronous rendering, customizable renderers, and built-in highlighting integration. Unlike marked, kramed aims to align with the kramdown standard (common in Jekyll) and provides enhanced math support, making it suitable for documentation tools like GitBook. However, it is now largely superseded by modern markdown parsers such as marked (post-0.6) and markdown-it.

npm install kramed
INSTALL
IMPORT
SIG · KRAMED
K
kramed
serializationjavascriptv0.5.6
harness data pending
Install & Compatibility
Where this runs

No compatibility data collected yet for this library.

Code
Verified usage

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

kramed
import kramed from 'kramed'; // or const kramed = require('kramed')
import { kramed } from 'kramed';
kramed is a default export; named import will fail. CJS require works but ESM is preferable.
Renderer
import { Renderer } from 'kramed';
import Renderer from 'kramed';
Renderer is a named export, not default. Do not confuse with kramed.Renderer property.
Lexer / Parser
import { Lexer, Parser } from 'kramed';
These named exports exist but are rarely used directly; kramed() calls them internally.

Parses a simple markdown string into HTML using kramed with common options. Uses ES module import.

import kramed from 'kramed'; const options = { gfm: true, tables: true, breaks: false, pedantic: false, sanitize: true, smartLists: true, smartypants: false }; const markdownString = '# Hello World\n\nThis is **bold** and `code`.'; const html = kramed(markdownString, options); console.log(html); // Output: <h1 id="hello-world">Hello World</h1>\n<p>This is <strong>bold</strong> and <code>code</code>.</p>\n
kramed --version
Debug
Known issues
breakingkramed.setOptions does not return the kramed function, but sets global state.
fix
Call setOptions before rendering, or pass options directly to kramed() instead.
affects: >=0.5.0
deprecatedThe package is no longer maintained; last release in 2016. Unpatched vulnerabilities may exist.
fix
Migrate to a maintained alternative like marked, markdown-it, or unified/remark.
affects: all
gotchasanitize option defaults to true, which strips HTML tags from output. This may break intended inline HTML.
fix
Set sanitize: false if you want to allow raw HTML, but be aware of XSS risks.
affects: >=0.5.0
gotchakramed.lexer and kramed.parser are not documented and their API may change without notice.
fix
Use the high-level kramed() function instead of calling lexer/parser directly.
affects: all
breakingAsync callback style (kramed(str, callback)) is only valid when options.highlight uses async highlighting.
fix
Do not pass a callback unless you have set an async highlight function; otherwise use synchronous return.
affects: >=0.5.0
gotchaMathJax support requires custom renderer; not built-in despite documentation claims.
fix
Extend the Renderer class to handle math tokens, or use a dedicated math plugin.
affects: all
Errors
Common errors & fixes
ReferenceError: kramed is not defined
Using ESM import with wrong syntax (e.g., import { kramed } from 'kramed') instead of default import.
fix
Use 'import kramed from 'kramed';' or 'const kramed = require('kramed');'
TypeError: kramed is not a function
Rarely, bundlers may mangle the default export if mixing CJS/ESM.
fix
Ensure your bundler config uses esModuleInterop or use require().
kramed(...).trim is not a function
Nowadays with bundlers, if you import kramed and try to call a method on the result, but kramed returns a string; this error usually occurs when you accidentally call kramed on an object.
fix
Check that the argument to kramed() is a string, not a buffer or HTML.
Cannot find module 'kramed'
Not installed or typo in package name (e.g., 'kramed' vs 'kraemde').
fix
Run 'npm install kramed' and verify package.json has 'kramed' in dependencies.
Upgrade
Version history
0.5.6latest on npm
Audit
Dependencies
pygmentize-bundledoptionalOptional peer dep for async code highlighting example.
highlight.jsoptionalOptional peer dep for synchronous code highlighting example.
Agent activity
4 hits · last 30 days
node
4
Resources
kramed — npm install kramed · libregistry