@labdigital/mdpostprocess
v0.2.0
Published
Replace custom scheme URLs (e.g. my://product/key) in markdown text
Keywords
Readme
Markdown post processor
Replace custom scheme URLs (for example my://product/key) in markdown text.
Installation
pnpm add @labdigital/mdpostprocessThe package is ESM-only and requires Node.js 22 or newer.
Usage
import { MarkdownPostProcessor } from "@labdigital/mdpostprocess";
const processor = new MarkdownPostProcessor("my");
processor.registerURL("product", /product\/(?<key>[A-Za-z0-9\-_]+)/);
const rawText = "see my://product/key for more information";
const processedText = await processor.process(rawText, (tags) => {
tags.get("product")?.forEach((p) => {
p.replaceValue = "/product/some-product-slug";
});
return tags;
});
// Outputs: see /product/some-product-slug for more information
console.log(processedText);