remark-wiki-link-plus icon indicating copy to clipboard operation
remark-wiki-link-plus copied to clipboard

Feature: Support for markdown -> markdown remark usage (emit [text](url) / ![alt](url))

Open z2k-gwp opened this issue 3 months ago • 1 comments

Summary

  • Today the plugin is excellent for Markdown→HTML pipelines (Remark → Rehype → HTML).
  • However, when using a Markdown→Markdown pipeline (Remark → remark-stringify), wikilinks are re-emitted as [[...]] instead of standard Markdown links/images.
  • Note: there is also a small serialization quirk: an empty alias results in a trailing | (e.g., [[Page|]]).

Motivation / Use cases

  • Static-site workflows that want to stay in Markdown space (e.g., generate MD/MDX for Docusaurus or other toolchains) and let another compiler do the HTML step.
  • Linting/formatting or content export scenarios where standard link syntax is required downstream.
  • Uniform link resolution (aliases, fragments, shortest permalinks) without committing to the Rehype stage.

Example

const transformed = await unified()
  .use(remarkParse)
  .use(wikiLinkPlugin, {
    aliasDivider: "|",
    format: "regular",
    // no urlResolver provided in this minimal case
  })
  .use(remarkStringify)
  .process("> [[How to Get Started in Under 2 Minutes]]");

// Observed output:
// > [[How to Get Started in Under 2 Minutes|]]

Implementation options

  1. You could add a toMarkdown extension export ( .use(remarkStringify, extensions: [wikiLinkToMarkdown({ mode: "standard" })]});)
  2. add an inline transform flag ( use(wikiLink, { ..., stringify: "standard" | "wikilink" }); )

z2k-gwp avatar Sep 12 '25 09:09 z2k-gwp

@z2k-gwp good suggestion.

rufuspollock avatar Oct 07 '25 09:10 rufuspollock