
Security News
Attackers Are Hunting High-Impact Node.js Maintainers in a Coordinated Social Engineering Campaign
Multiple high-impact npm maintainers confirm they have been targeted in the same social engineering campaign that compromised Axios.
BOTTOM CHANGELOG CONTRIBUTING LICENSE
ts-md2html provides a simple, reliable way to convert Markdown files into HTML strings in TypeScript projects.
It is designed as a library rather than a Rollup plugin, giving you full control over when and how Markdown is processed, while maintaining strict UTF-8 validation and optional support for legacy encodings like ISO-8859-1 (mapped to latin1).
This library is intentionally small and focused. It is particularly useful when you want to:
It aims to provide a deterministic Markdown → HTML conversion layer, not a framework or extensible rendering engine.
utf8, latin1, iso-8859-1).Details on AI assistance during development
ts-md2html is built on top of the unified / remark / rehype ecosystem.
This choice favors correctness, extensibility, and long-term maintainability over minimalism.
Internally, Markdown is converted to HTML using the following pipeline:
remark-parse
Parses Markdown into a Markdown AST (MDAST).
remark-gfm
Adds GitHub-Flavored Markdown support.
remark-rehype
Transforms the Markdown AST into an HTML AST (HAST).
rehype-stringify
Serializes the HTML AST into a raw HTML string.
This pipeline is executed via unified, which acts as the orchestration layer.
Out of the box, the following features are supported:
| Feature | Supported | Notes |
|---|---|---|
| CommonMark | ✅ | Fully supported via remark-parse |
| GitHub-Flavored Markdown | ✅ | Enabled via remark-gfm |
| Tables | ✅ | GFM tables |
| Task Lists | ✅ | GFM task list items |
| Strikethrough | ✅ | GFM extension |
| Autolinks | ✅ | GFM extension |
| Raw HTML in Markdown | ⚠️ | Passed through, not sanitized |
| Syntax Highlighting | ❌ | Intentionally not included |
| HTML Sanitization | ❌ | Left to downstream tools |
Although ts-md2html exposes a minimal public API, the internal architecture is intentionally aligned with the unified ecosystem.
This means:
remark or rehype plugins.rehype-highlight).The library itself deliberately avoids configuration knobs for rendering, keeping the API stable and predictable.
Styling, wrapping, sanitization, and enrichment are expected to be handled by downstream tooling.
npm install ts-md2html
or
yarn add ts-md2html
import { md2html } from "ts-md2html";
(async () => {
const html = await md2html("./README.md");
console.log(html);
})();
Optional encoding support:
const html = await md2html("./README.md", { encoding: "latin1" });
This is especially useful when your Markdown contains legacy encodings like ISO-8859-1.
You can import ts-md2html directly in your Rollup configuration, for example:
import { md2html } from "ts-md2html";
const readmeHtml = await md2html("./README.md");
This allows you to embed the Markdown content into your code at build-time and use it anywhere in your application.
ts-md2html follows a strict, explicit error model.
Errors are not swallowed, normalized, or wrapped by the library.
If the provided file path does not exist or is not readable, the underlying filesystem error is propagated unchanged.
Typical error sources:
ENOENT (file not found)EACCES (permission denied)This allows calling code (e.g. build tools or CI pipelines) to fail fast and report meaningful diagnostics.
Empty files are considered valid input.
This behavior is intentional and aligns with the principle that absence of content is not an exceptional condition.
There is no concept of “invalid Markdown” at the parser level.
As a result, HTML output is always produced as long as the input can be decoded as text.
Invalid UTF-8 input without an explicit encoding will result in a decoding error being thrown.
This prevents silent data corruption and makes encoding issues explicit at build time.
md2html(file: string, options?: { encoding?: ExplicitEncoding }): Promise<string>
file: Path to the Markdown file.options.encoding: Optional. "utf8" | "latin1" | "iso-8859-1". If omitted, strict UTF-8 validation is enforced.Promise<string> containing the raw HTML.readTextWithExplicitEncoding(file: string, encoding: ExplicitEncoding): Promise<string>
Promise<string> containing the file content.readStrictUtf8(file: string): Promise<string>
Promise<string> containing the UTF-8 content.FAQs
Convert markdown to HTML
The npm package ts-md2html receives a total of 1 weekly downloads. As such, ts-md2html popularity was classified as not popular.
We found that ts-md2html demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Security News
Multiple high-impact npm maintainers confirm they have been targeted in the same social engineering campaign that compromised Axios.

Security News
Axios compromise traced to social engineering, showing how attacks on maintainers can bypass controls and expose the broader software supply chain.

Security News
Node.js has paused its bug bounty program after funding ended, removing payouts for vulnerability reports but keeping its security process unchanged.