Registry / serialization / md-utils-ts

md-utils-ts

JSON →
library2.0.0jsnpmunverified

`md-utils-ts` is a lightweight, TypeScript-first utility library designed for programmatic generation of common Markdown syntax elements. Currently at version 2.0.0, it provides a focused collection of functions to create bold text, italics, strikethroughs, underlines, anchor links, code blocks (inline and multi-line), equations, and headings (H1-H6). The library emphasizes simplicity and type safety, offering both individual named exports for each utility (e.g., `bold`, `h1`) and a bundled `md` object for convenience (e.g., `md.italic`). Unlike comprehensive Markdown parsers or renderers, `md-utils-ts` strictly focuses on outputting valid Markdown strings, making it ideal for scenarios where you need to construct Markdown content dynamically without heavy dependencies. Its release cadence is likely stable, with updates driven by new Markdown syntax needs or minor enhancements.

npm install md-utils-ts
INSTALL
IMPORT
SIG · MD-UTILS-TS
M
md-utils-ts
serializationjavascriptv2.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.

bold
import { bold } from 'md-utils-ts'
const bold = require('md-utils-ts').bold
md-utils-ts is an ESM-first, TypeScript library. Named exports like `bold` are individual utility functions.
md
import md from 'md-utils-ts'
import { md } from 'md-utils-ts'
The `md` object is the default export and contains all utility functions as properties (e.g., `md.italic()`).
codeBlock
import { codeBlock } from 'md-utils-ts'
import codeBlock from 'md-utils-ts'
Functions like `codeBlock` are available as direct named exports for granular import control.

Demonstrates importing both the default `md` object and named utility functions to create various Markdown elements like headings, bold text, links, code blocks, and equations.

import md, { bold, h1, anchor, codeBlock, equationBlock } from "md-utils-ts"; // Create a main heading const title = h1("Welcome to md-utils-ts!"); // Bold and italic text using individual exports and the 'md' object const importantText = bold("This text is important.") + " " + md.italic("And this is emphasized."); // Create an anchor link const githubLink = anchor("md-utils-ts GitHub", "https://github.com/TomPenguin/md-utils-ts"); // Generate a TypeScript code block const tsExample = codeBlock("typescript")(` function greet(name: string): string { return \`Hello, \${name}!\`; } console.log(greet("World")); `); // Create an equation block const pythagoreanTheorem = equationBlock("a^2 + b^2 = c^2"); console.log(title); console.log(importantText); console.log(githubLink); console.log("\n--- TypeScript Example ---\n" + tsExample); console.log("\n--- Math Example ---\n" + pythagoreanTheorem);
Debug
Known issues
gotchamd-utils-ts explicitly states that it does not support Markdown table generation directly. Attempting to create complex tables will require manual string formatting or integration with another library.
fix
For generating Markdown tables, integrate a dedicated library such as `markdown-table` from the `@wooorm` ecosystem, as `md-utils-ts` focuses on simpler, atomic Markdown elements.
affects: >=2.0.0
gotchaThis library is strictly for *generating* Markdown strings. It does not provide functionality for *parsing* existing Markdown content or *rendering* Markdown into HTML or other formats.
fix
For parsing or rendering Markdown, integrate with a dedicated Markdown parser/renderer library (e.g., `marked`, `remark`, `markdown-it`). `md-utils-ts`'s role is limited to constructing the Markdown string itself.
affects: >=2.0.0
gotchaThe `code` and `equation` functions are higher-order functions that require an initial boolean argument (`inline`) to determine output format, returning another function that takes the `language`/`text`.
fix
When using `code(inline)` or `equation(inline)`, remember to call it twice: first with the `inline` boolean, then with the content. For convenience, use `inlineCode`, `codeBlock`, `inlineEquation`, or `equationBlock` which are pre-configured versions.
affects: >=2.0.0
Errors
Common errors & fixes
TypeError: (0 , md_utils_ts__WEBPACK_IMPORTED_MODULE_0__.bold) is not a function
Attempting to use a named export (e.g., `bold`) directly from a default import, or incorrect CommonJS `require` syntax.
fix
Ensure named exports are correctly destructured: `import { bold } from 'md-utils-ts';`. If using CommonJS (not recommended for this ESM-first library), access named exports as properties: `const { bold } = require('md-utils-ts');`.
TS2305: Module '"md-utils-ts"' has no exported member 'md'.
Attempting to import `md` as a named export when it is the default export of the package.
fix
Import the default export correctly: `import md from 'md-utils-ts';`.
Module not found: Error: Can't resolve 'md-utils-ts'
The package `md-utils-ts` is not installed in the project's `node_modules` directory or the package name is misspelled in the import statement.
fix
Run `npm install md-utils-ts` or `yarn add md-utils-ts` to install the package. Double-check the spelling of the import path.
TypeError: md.bold is not a function
Attempting to call a utility function (e.g., `bold`) directly as a property of the `md` default import when it's also available as a named export, leading to confusion or incorrect binding.
fix
If you are using the `md` default import, access its properties correctly, e.g., `md.bold("text")`. If you prefer direct named imports, use `import { bold } from 'md-utils-ts'` and then `bold("text")`.
Upgrade
Version history
2.0.0latest on npm
Audit
Dependencies

No dependency data recorded yet.

Agent activity
8 hits · last 30 days
node
8
Resources
md-utils-ts — npm install md-utils-ts · libregistry