{"id":14007,"library":"shortcode-parser","title":"Shortcode Parser","description":"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`.","status":"abandoned","version":"0.0.1","language":"javascript","source_language":"en","source_url":"https://github.com/derdesign/shortcode-parser","tags":["javascript"],"install":[{"cmd":"npm install shortcode-parser","lang":"bash","label":"npm"},{"cmd":"yarn add shortcode-parser","lang":"bash","label":"yarn"},{"cmd":"pnpm add shortcode-parser","lang":"bash","label":"pnpm"}],"dependencies":[],"imports":[{"note":"This package is CommonJS-only and does not support ES modules. Attempting to use `import` syntax will fail.","wrong":"import shortcode from 'shortcode-parser';","symbol":"shortcode","correct":"const shortcode = require('shortcode-parser');"},{"note":"Methods like `add` are accessed via the default CommonJS export, not as named ES module imports.","wrong":"import { add } from 'shortcode-parser';","symbol":"add","correct":"shortcode.add('bold', function(buf, opts) { /* ... */ });"},{"note":"The `parse` function is a method of the object exported by `require('shortcode-parser')`.","wrong":"import { parse } from 'shortcode-parser';","symbol":"parse","correct":"shortcode.parse(str, data, context);"}],"quickstart":{"code":"const shortcode = require('shortcode-parser');\n\n// Add a handler for the 'bold' shortcode\nshortcode.add('bold', function(buf, opts) {\n  let content = buf;\n  if (opts.upper) {\n    content = buf.toUpperCase();\n  }\n  return `<strong>${content}</strong>`;\n});\n\n// Define a shortcode handler (e.g., for markdown, though 'marked' isn't a direct dependency)\n// For demonstration, we'll just wrap it.\nconst myCustomShortcodeHandlers = {\n  markdown: function(buf, opts) {\n    // In a real app, you might use a library like 'marked' here:\n    // return require('marked')(buf, opts);\n    return `<div>--- Markdown Content ---\\n${buf}\\n--- End Markdown Content ---</div>`;\n  }\n};\n\n// String containing shortcodes\nconst str = \"This is [bold upper=true]Bold Text[/bold]!!! Also, some [markdown]## Hello World\\nThis is a markdown test.[/markdown]\";\n\n// Parse the string with registered shortcodes\nconst output = shortcode.parse(str);\nconsole.log('Output with registered handlers:\\n', output);\n\n// Parse with custom handlers provided via context\nconst outputWithContext = shortcode.parse(str, {}, myCustomShortcodeHandlers);\nconsole.log('\\nOutput with context handlers:\\n', outputWithContext);","lang":"javascript","description":"Demonstrates how to install, require, add custom shortcode handlers, and parse strings containing both registered and context-specific shortcodes."},"warnings":[{"fix":"Do not use this package for new projects. For existing projects, consider a full migration to a modern shortcode parsing library.","message":"This 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.","severity":"breaking","affected_versions":"0.0.1"},{"fix":"Always use `const shortcode = require('shortcode-parser');` when integrating this package into your application.","message":"The 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.","severity":"gotcha","affected_versions":"0.0.1"},{"fix":"Migrate to a actively maintained shortcode parsing library. Examples include `shortcode-insert`, `universal-shortcodes`, or `@hewes/shortcode`.","message":"This 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.","severity":"breaking","affected_versions":"0.0.1"},{"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.","message":"The 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.","severity":"gotcha","affected_versions":"0.0.1"}],"env_vars":null,"search_vec":"'0.0.1':46 '0.10':58 '2013':51 '2016':69 'abandon':85 'activ':89,108 'age':73 'altern':110 'attribut':23,30 'automat':25 'cadenc':97 'clean':34 'clear':95 'close':19 'consid':107 'develop':90,98 'due':70 'effect':84 'enclos':21 'end':64 'end-of-lif':63 'environ':105 'explicit':54 'featur':28 'function':9,101 'handl':31 'hewes/shortcode':119 'includ':29 'insert':114 'javascript':14,36,104,120 'key':27 'known':43 'last':42 'librari':4 'life':66 'like':111 'lint':35 'maintain':109 'mainten':92 'modern':103 'node.js':56,79 'octob':50,68 'packag':53,82 'pars':11 'parser':2,7 'provid':8 'publish':48 'reach':61 'releas':44,96 'relianc':75 'runtim':80 'seek':99 'self':18 'self-clos':17 'shortcod':1,6,12,22,113,117 'shortcode-insert':112 'shortcode-pars':5 'similar':100 'sourc':37 'support':15 'target':55 'test':40 'typecast':26 'unit':39 'univers':116 'universal-shortcod':115 'unsupport':78 'version':45,57 'x':59","created_at":"2026-04-20T01:57:26.833718+00:00","updated_at":"2026-04-20T01:57:26.833718+00:00","problems":[{"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');`","cause":"Attempting to `require()` an ES module, or `import` a CommonJS module in an ES module context when the package is incorrectly configured or interpreted.","error":"Error: require() of ES Module ... shortcode-parser.js from ... not supported."},{"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.","cause":"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.","error":"TypeError: shortcode.add is not a function"},{"fix":"Run `npm install shortcode-parser` or `yarn add shortcode-parser` in your project directory.","cause":"The package `shortcode-parser` has not been installed in the project's `node_modules`.","error":"Error: Cannot find module 'shortcode-parser'"}],"ecosystem":"npm","meta_description":null,"install_score":null,"quickstart_score":null,"quickstart_tag":null,"pypi_latest":null,"cli_name":"","cli_version":null,"type":"library","homepage":null,"github":"https://github.com/derdesign/shortcode-parser","docs":null,"changelog":null,"pypi":null,"npm":"https://www.npmjs.com/package/shortcode-parser","openapi_spec":null,"status_page":null,"smithery":null,"categories":["data","serialization"],"base_url":null,"auth_type":null,"provenance":{"verified_status":null,"verified_at":null,"last_verified":"2026-06-17","next_check":"2026-07-18","install_tag":null}}