{"id":17023253,"url":"https://github.com/boehs/markdown-it-wikilinks","last_synced_at":"2026-03-16T11:38:21.067Z","repository":{"id":42509719,"uuid":"464274905","full_name":"boehs/markdown-it-wikilinks","owner":"boehs","description":"🔗🌱 A custom fork of markdown-it-wikilinks","archived":false,"fork":false,"pushed_at":"2023-03-07T12:14:29.000Z","size":283,"stargazers_count":3,"open_issues_count":2,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-04-12T10:15:12.116Z","etag":null,"topics":["markdown-it","markdown-it-plugin"],"latest_commit_sha":null,"homepage":"https://www.npmjs.com/package/@gardeners/markdown-it-wikilinks","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/boehs.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2022-02-27T23:00:56.000Z","updated_at":"2023-03-13T17:04:12.000Z","dependencies_parsed_at":"2023-01-28T01:01:02.350Z","dependency_job_id":null,"html_url":"https://github.com/boehs/markdown-it-wikilinks","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/boehs%2Fmarkdown-it-wikilinks","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/boehs%2Fmarkdown-it-wikilinks/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/boehs%2Fmarkdown-it-wikilinks/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/boehs%2Fmarkdown-it-wikilinks/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/boehs","download_url":"https://codeload.github.com/boehs/markdown-it-wikilinks/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248550619,"owners_count":21122934,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["markdown-it","markdown-it-plugin"],"created_at":"2024-10-14T07:12:42.949Z","updated_at":"2026-03-16T11:38:16.001Z","avatar_url":"https://github.com/boehs.png","language":"JavaScript","readme":"# Markdown-It Wikilinks\n\n[![Build Status](https://travis-ci.org/jsepia/markdown-it-wikilinks.svg?branch=master)](https://travis-ci.org/jsepia/markdown-it-wikilinks) [![Coverage Status](https://coveralls.io/repos/github/jsepia/markdown-it-wikilinks/badge.svg?branch=master)](https://coveralls.io/github/jsepia/markdown-it-wikilinks?branch=master)\n\nRenders [Wikimedia-style links](https://www.mediawiki.org/wiki/Help:Links#Internal_links) in [markdown-it](https://github.com/markdown-it/markdown-it). This is useful for making Markdown-based wikis.\n\n## Usage\n\nInstall this into your project:\n\n```bash\nnpm --save install markdown-it-wikilinks\n```\n\n...and *use* it:\n\n```js\nconst wikilinks = require('@gardeners/markdown-it-wikilinks')(options)\nconst md = require('markdown-it')()\n    .use(wikilinks)\n    .render('Click [[Wiki Links|here]] to learn about [[/Wiki]] links.')\n```\n\n**Output:**\n\n```html\n\u003cp\u003eClick \u003ca href=\"./Wiki_Links.html\"\u003ehere\u003c/a\u003e to learn about \u003ca href=\"/Wiki.html\"\u003eWiki\u003c/a\u003e links.\u003c/p\u003e\n```\n\n## Options\n\n### `linkPattern`\n\n**Default:** `/\\[\\[([^|]+?)(\\|([\\s\\S]+?))?\\]\\]/`\n\nThe regex to use when matching WikiLinks.\n\n```js\n// Allow exclamation marks to be used.\nconst html = require('markdown-it')()\n  .use(require('@gardeners/markdown-it-wikilinks')({ linkPattern: /\\[\\[([\\w\\s/!]+)(\\|([\\w\\s/!]+))?\\]\\]/ }))\n  .render('[[Slate!]]')\n  // \u003cp\u003e\u003ca href=\"./Slate!.html\"\u003eSlate!\u003c/a\u003e\u003c/p\u003e\n```\n\n### `imagePattern`\n\n**Default:** undefined\n\nThe common regex for images is `/!\\[\\[([^]+?)\\]\\]/` (note the inclusion of ! at the start).\n\n### `assetPrefix`\n\n**Default:** ''\n\nA prefix for image urls, normally `/assets/`\n\n\n### `baseURL`\n\n**Default:** `/`\n\nThe base URL for absolute wiki links.\n\n```js\nconst html = require('markdown-it')()\n  .use(require('@gardeners/markdown-it-wikilinks')({ baseURL: '/wiki/' }))\n  .render('[[/Main Page]]')\n  // \u003cp\u003e\u003ca href=\"/wiki/Main_Page.html\"\u003eMain Page\u003c/a\u003e\u003c/p\u003e\n```\n\n### `relativeBaseURL`\n\n**Default:** `./`\n\nThe base URL for relative wiki links.\n\n```js\nconst html = require('markdown-it')()\n  .use(require('@gardeners/markdown-it-wikilinks')({ relativeBaseURL: '#', suffix: '' }))\n  .render('[[Main Page]]')\n  // \u003cp\u003e\u003ca href=\"#Main_Page\"\u003eMain Page\u003c/a\u003e\u003c/p\u003e\n```\n\n### `makeAllLinksAbsolute`\n\n**Default:** `false`\n\nRender all wiki links as absolute links.\n\n### `uriSuffix`\n\n**Default:** `.html`\n\nAppend this suffix to every URL.\n\n```js\nconst html = require('markdown-it')()\n  .use(require('@gardeners/markdown-it-wikilinks')({ uriSuffix: '.php' }))\n  .render('[[Main Page]]')\n  // \u003cp\u003e\u003ca href=\"./Main_Page.php\"\u003eMain Page\u003c/a\u003e\u003c/p\u003e\n```\n\n### `htmlAttributes`\n\n**Default:** `{}`\n\nAn object containing HTML attributes to be applied to every link.\n\n```js\nconst attrs = {\n  'class': 'wikilink',\n  'rel': 'nofollow'\n}\nconst html = require('markdown-it')()\n  .use(require('@gardeners/markdown-it-wikilinks')({ htmlAttributes: attrs }))\n  .render('[[Main Page]]')\n  // \u003cp\u003e\u003ca href=\"./Main_Page.html\" class=\"wikilink\" rel=\"nofollow\"\u003eMain Page\u003c/a\u003e\u003c/p\u003e\n```\n\n### `generatePageNameFromLabel`\n\nUnless otherwise specified, the labels of the links are used as the targets. This means that a non-[piped](https://meta.wikimedia.org/wiki/Help:Piped_link) link such as `[[Slate]]` will point to the `Slate` page on your website.\n\nBut say you wanted a little more flexibility - like being able to have `[[Slate]]`, `[[slate]]`, `[[SLATE]]` and `[[Slate!]]` to all point to the same page. Well, you can do this by providing your own custom `generatePageNameFromLabel` function.\n\n#### Example\n\n```js\nconst _ = require('lodash')\n\nfunction myCustomPageNameGenerator(label) {\n  return label.split('/').map(function(pathSegment) {\n    // clean up unwanted characters, normalize case and capitalize the first letter\n    pathSegment = _.deburr(pathSegment)\n    pathSegment = pathSegment.replace(/[^\\w\\s]/g, '')\n\n    // normalize case\n    pathSegment = _.capitalize(pathSegment.toLowerCase())\n\n    return pathSegment\n  })\n}\n\nconst html = require('markdown-it')()\n  .use(require('@gardeners/mardkwon-it-wikilinks')({ generatePageNameFromLabel: myCustomPageNameGenerator }))\n  .render('Vive la [[révolution!]] VIVE LA [[RÉVOLUTION!!!]]')\n  // \u003cp\u003eVive la \u003ca href=\"./Revolution.html\"\u003erévolution!\u003c/a\u003e VIVE LA \u003ca href=\"./Revolution.html\"\u003eRÉVOLUTION!!!\u003c/a\u003e\u003c/p\u003e\n```\n\nPlease note that the `generatePageNameFromLabel` function does not get applied for [piped links](https://meta.wikimedia.org/wiki/Help:Piped_link) such as `[[/Misc/Cats/Slate|kitty]]` since those already come with a target.\n\n### `postProcessPageName`\n\nA transform applied to every page name. You can override it just like `generatePageNameFromLabel` (see above).\n\nThe default transform does the following things:\n\n- trim surrounding whitespace\n- [sanitize](https://github.com/parshap/node-sanitize-filename) the string\n- replace spaces with underscores\n\n### `postProcessLabel`\n\nA transform applied to every link label. You can override it just like `generatePageNameFromLabel` (see above).\n\nAll the default transform does is trim surrounding whitespace.\n\n### `includeWikilinks`\n\n**Default:** `false`\n\nInclude wikilink delimiters (`[[`, `]]`) in output\n\n- **false**: Do not include delimiters in output\n- **\"inner\"**: Include delimiters inside the link\n- **\"outer\"**: Wrap the link with delimiters\n\n## TODO\n\n- Unit test options\n- Add examples to `postProcessPageName` and `postProcessLabel`\n\n## Credits\n\nBased on [markdown-it-ins](https://github.com/markdown-it/markdown-it-ins) by Vitaly Puzrin, Alex Kocharin.\n\n### Differences with [`markdown-it-obsidian`](https://www.npmjs.com/package/markdown-it-obsidian)\n\n- Wikistyle images via that fork\n- `markdown-it-obsidian` checks that the page exists before linking, `@gardeners/markdown-it-wikilinks` does not\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fboehs%2Fmarkdown-it-wikilinks","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fboehs%2Fmarkdown-it-wikilinks","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fboehs%2Fmarkdown-it-wikilinks/lists"}