Skip to content

Marked Plugin

The @mrsf/marked-mrsf package adds Sidemark review metadata to HTML generated by Marked. It uses the same shared controller and CSS as the markdown-it and rehype plugins, so the visual behavior and emitted mrsf:* events stay consistent.

Install

bash
npm install marked @mrsf/marked-mrsf

Live Demo

Quick Start

ts
import { Marked } from "marked";
import { markedMrsf } from "@mrsf/marked-mrsf";

const parser = new Marked();
parser.use(markedMrsf({
  documentPath: "docs/guide.md",
}));

const html = parser.parse(markdownSource);

Include the stylesheet:

ts
import "@mrsf/marked-mrsf/style.css";

Data Provisioning

The plugin supports the same sidecar loading priority as the other rendering plugins:

  1. comments
  2. loader
  3. sidecarPath
  4. documentPath

In browser environments, use comments or loader. The browser build warns if you pass file-system options.

Interactive Mode

ts
import { refreshAll } from "@mrsf/marked-mrsf/controller";

document.addEventListener("mrsf:submit", async (e) => {
  await saveComment((e as CustomEvent).detail);
});

refreshAll();

The controller adds gutter buttons, selection-based add-comment actions, and built-in dialogs for add/reply/edit/resolve/unresolve/delete. The plugin itself only adds data-mrsf-* line metadata and the serialized comment payload.

Options

OptionTypeDefaultDescription
commentsMrsfDocumentPre-loaded sidecar data
loader() => MrsfDocument | nullCustom sidecar loader
documentPathstringPath to Markdown file for auto-discovery
sidecarPathstringExplicit path to .review.yaml / .review.json
showResolvedbooleantrueShow resolved comments
dataContainer'script' | 'element''script'How to embed the serialized thread data
dataElementIdstring'mrsf-comment-data'Element id when dataContainer: 'element'
interactivebooleanfalseEnable controller action buttons
gutterPosition'left' | 'right''right'Badge placement
gutterForInlinebooleantrueShow badge for inline-highlighted comments
inlineHighlightsbooleantrueHighlight selected_text inline
lineHighlightbooleanfalseAdd background tint on commented lines
theme'light' | 'dark' | 'auto''auto'Color scheme hint
cwdstringprocess.cwd()Working directory for file resolution

Comparison

Choose the plugin based on your Markdown engine:

Markedmarkdown-itrehype
Package@mrsf/marked-mrsf@mrsf/markdown-it-mrsf@mrsf/rehype-mrsf
Best forMarked pipelines, client-side renderersmarkdown-it ecosystems like VitePressunified / MDX / Astro
Integration styleRenderer overrides + token hooksToken stream rule injectionhast tree transformation

Released under the MIT License.