Registry / data / shortcode-parser

shortcode-parser

JSON →
library0.0.1jsnpmunverified

This library, `shortcode-parser`, provides functionality for parsing shortcodes in JavaScript, supporting both self-closing and enclosing shortcodes, attributes, and automatic typecasting. Key features include attribute handling and a clean, linted JavaScript source with unit tests. Its last known release, version `0.0.1`, was published in October 2013. The package explicitly targets Node.js versions `0.10.x`, which reached its End-of-Life in October 2016. Due to its age and reliance on an unsupported Node.js runtime, this package is effectively abandoned. There is no active development or maintenance, and no clear release cadence. Developers seeking similar functionality in modern JavaScript environments should consider actively maintained alternatives like `shortcode-insert`, `universal-shortcodes`, or `@hewes/shortcode`.

npm install shortcode-parser
INSTALL
IMPORT
SIG · SHORTCODE-PARSER
S
shortcode-parser
datajavascriptv0.0.1
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.

shortcode
const shortcode = require('shortcode-parser');
import shortcode from 'shortcode-parser';
This package is CommonJS-only and does not support ES modules. Attempting to use `import` syntax will fail.
add
shortcode.add('bold', function(buf, opts) { /* ... */ });
import { add } from 'shortcode-parser';
Methods like `add` are accessed via the default CommonJS export, not as named ES module imports.
parse
shortcode.parse(str, data, context);
import { parse } from 'shortcode-parser';
The `parse` function is a method of the object exported by `require('shortcode-parser')`.

Demonstrates how to install, require, add custom shortcode handlers, and parse strings containing both registered and context-specific shortcodes.

const shortcode = require('shortcode-parser'); // Add a handler for the 'bold' shortcode shortcode.add('bold', function(buf, opts) { let content = buf; if (opts.upper) { content = buf.toUpperCase(); } return `<strong>${content}</strong>`; }); // Define a shortcode handler (e.g., for markdown, though 'marked' isn't a direct dependency) // For demonstration, we'll just wrap it. const myCustomShortcodeHandlers = { markdown: function(buf, opts) { // In a real app, you might use a library like 'marked' here: // return require('marked')(buf, opts); return `<div>--- Markdown Content ---\n${buf}\n--- End Markdown Content ---</div>`; } }; // String containing shortcodes const str = "This is [bold upper=true]Bold Text[/bold]!!! Also, some [markdown]## Hello World\nThis is a markdown test.[/markdown]"; // Parse the string with registered shortcodes const output = shortcode.parse(str); console.log('Output with registered handlers:\n', output); // Parse with custom handlers provided via context const outputWithContext = shortcode.parse(str, {}, myCustomShortcodeHandlers); console.log('\nOutput with context handlers:\n', outputWithContext);
Debug
Known issues
breakingThis package is extremely old, last published in October 2013. It explicitly targets Node.js 0.10.x, which reached End-of-Life in October 2016. It is highly unlikely to run on modern Node.js versions (v12+) without significant compatibility issues or runtime errors.
fix
Do not use this package for new projects. For existing projects, consider a full migration to a modern shortcode parsing library.
affects: 0.0.1
gotchaThe package is CommonJS-only and does not provide ES module exports. Attempting to use `import shortcode from 'shortcode-parser';` or named imports will result in `ERR_REQUIRE_ESM` or similar errors in an ES module context.
fix
Always use `const shortcode = require('shortcode-parser');` when integrating this package into your application.
affects: 0.0.1
breakingThis project is unmaintained, meaning there will be no updates for bug fixes, performance improvements, security vulnerabilities, or compatibility with newer JavaScript features or Node.js runtimes. Using it may introduce significant security risks or stability issues.
fix
Migrate to a actively maintained shortcode parsing library. Examples include `shortcode-insert`, `universal-shortcodes`, or `@hewes/shortcode`.
affects: 0.0.1
gotchaThe documentation's example for `parse(str, data, context)` and `parseInContext(str, context, data)` shows `charcodes` within the context object (as `charcodes: function(buf, opts) { return marked(buf, opts); }`). However, the API section states that `context`'s methods will be used as *shortcode handlers* directly, implying `charcodes` would be a shortcode name.
fix
If providing handlers via the `context` parameter, ensure the keys of the `context` object match your shortcode names. The example may be confusing or demonstrate an undocumented flexibility.
affects: 0.0.1
Errors
Common errors & fixes
Error: require() of ES Module ... shortcode-parser.js from ... not supported.
Attempting to `require()` an ES module, or `import` a CommonJS module in an ES module context when the package is incorrectly configured or interpreted.
fix
This package is CommonJS-only. If your project is an ES module, you must either refactor to use `require()` via `createRequire` (Node.js) or transition to a modern ESM-compatible shortcode parser. Example: `import { createRequire } from 'module'; const require = createRequire(import.meta.url); const shortcode = require('shortcode-parser');`
TypeError: shortcode.add is not a function
The default export from `require('shortcode-parser')` is an object, and `add` is a method on it. This error could occur if `shortcode` variable itself is not the expected object.
fix
Ensure you are correctly assigning the result of `require('shortcode-parser')` to a variable (e.g., `const shortcode = require('shortcode-parser');`) and calling methods directly on that variable.
Error: Cannot find module 'shortcode-parser'
The package `shortcode-parser` has not been installed in the project's `node_modules`.
fix
Run `npm install shortcode-parser` or `yarn add shortcode-parser` in your project directory.
Upgrade
Version history
0.0.1latest on npm
Audit
Dependencies

No dependency data recorded yet.

Agent activity
7 hits · last 30 days
node
6
OpenAI (training)
1
Resources