{"id":20098381,"url":"https://github.com/wikibonsai/markdown-it-wikirefs","last_synced_at":"2026-02-13T10:38:16.034Z","repository":{"id":142456106,"uuid":"608248078","full_name":"wikibonsai/markdown-it-wikirefs","owner":"wikibonsai","description":"[[Wikirefs]] support for markdown-it.","archived":false,"fork":false,"pushed_at":"2024-12-17T22:31:25.000Z","size":154,"stargazers_count":2,"open_issues_count":0,"forks_count":0,"subscribers_count":0,"default_branch":"main","last_synced_at":"2025-09-20T21:46:34.683Z","etag":null,"topics":["markdown-it","markdown-it-plugin","wikibonsai","wikilink","wikiref"],"latest_commit_sha":null,"homepage":"https://www.npmjs.com/package/markdown-it-wikirefs","language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"gpl-3.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/wikibonsai.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE.md","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2023-03-01T16:15:46.000Z","updated_at":"2024-12-17T22:31:29.000Z","dependencies_parsed_at":"2025-09-20T21:32:53.106Z","dependency_job_id":"c123f7fc-bfc7-43d9-b222-164dbc1d40e5","html_url":"https://github.com/wikibonsai/markdown-it-wikirefs","commit_stats":{"total_commits":9,"total_committers":2,"mean_commits":4.5,"dds":0.2222222222222222,"last_synced_commit":"ade35f82bd9b1eb5be172814b25fd6875025142d"},"previous_names":[],"tags_count":2,"template":false,"template_full_name":null,"purl":"pkg:github/wikibonsai/markdown-it-wikirefs","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/wikibonsai%2Fmarkdown-it-wikirefs","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/wikibonsai%2Fmarkdown-it-wikirefs/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/wikibonsai%2Fmarkdown-it-wikirefs/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/wikibonsai%2Fmarkdown-it-wikirefs/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/wikibonsai","download_url":"https://codeload.github.com/wikibonsai/markdown-it-wikirefs/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/wikibonsai%2Fmarkdown-it-wikirefs/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":29401890,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-02-13T06:24:03.484Z","status":"ssl_error","status_checked_at":"2026-02-13T06:23:12.830Z","response_time":78,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.5:443 state=error: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"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","wikibonsai","wikilink","wikiref"],"created_at":"2024-11-13T17:03:28.709Z","updated_at":"2026-02-13T10:38:15.989Z","avatar_url":"https://github.com/wikibonsai.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# markdown-it-wikirefs\n\n[![A WikiBonsai Project](https://img.shields.io/badge/%F0%9F%8E%8B-A%20WikiBonsai%20Project-brightgreen)](https://github.com/wikibonsai/wikibonsai)\n[![NPM package](https://img.shields.io/npm/v/markdown-it-wikirefs)](https://npmjs.org/package/markdown-it-wikirefs)\n\nA markdown-it plugin to process [[[wikirefs]]](https://github.com/wikibonsai/wikirefs)\n\nNote that this plugin only parses the input -- it is up to you to assign appropriate linking information and/or index relationships (between files).\n\n🕸 Weave a semantic web in your [🎋 WikiBonsai](https://github.com/wikibonsai/wikibonsai) digital garden.\n\n## Install\n\nInstall with [npm](https://docs.npmjs.com/cli/v9/commands/npm-install):\n\n```\n$ npm install markdown-it-wikirefs\n```\n\n## Use\n\n```js\nimport markdownIt from 'markdown-it';\nimport wikirefs_plugin from 'markdown-it-wikirefs';\n\nconst md = markdownIt();\nconst options = {\n  resolveHtmlHref: (env: any, fname: string) =\u003e {\n    const extname: string = wikirefs.isMedia(fname) ? path.extname(fname) : '';\n    fname = fname.replace(extname, '');\n    return '/' + fname.trim().toLowerCase().replace(/ /g, '-').replace(/[^\\w-]+/g, '') + extname;\n  },\n  resolveHtmlText: (env: any, fname: string) =\u003e fname.replace(/-/g, ' '),\n  resolveEmbedContent: (env: any, fname: string) =\u003e fname + ' content',\n};\nmd.use(wikirefs_plugin, options);\nmd.render('[[wikilink]]');\n```\n\nRequire style imports work as well:\n\n```js\nconst wikirefs_plugin = require('markdown-it-wikirefs');\n\n// if you encounter issues, try:\nconst wikirefs_plugin = require('markdown-it-wikirefs').default;\n\n```\n\n## Syntax\n\nFor syntax specifications, see the [wikirefs-spec](https://github.com/wikibonsai/wikirefs/tree/main/spec) repo.\n\n## Option recommendations\n\nFor render output:\n- `resolveHtmlText`\n- `resolveHtmlHref`\n- `resolveEmbedContent`\n\nFor `wikiembeds` -- note:\n- [`path.extname(filename)`](https://nodejs.org/api/path.html#pathextnamepath) is used to identify the file extension which determines how the embed should be formatted.\n- Check for self-references and cycles when defining [`opts.resolveEmbedContent()`]().\n\nFor metadata population:\n- `addAttr`\n- `addLink`\n- `addEmbed`\n- `prepFile` (useful for clearing a cache for the current markdown file per render)\n\n## Options\n\n### `addAttr: (env: any, attrtype: string, fname: string) =\u003e void`\n\n### `addLink: (env: any, linktype: string, fname: string) =\u003e void`\n\n### `addEmbed: (env: any, fname: string) =\u003e void`\n\n### `attrs`\n\nThese are options wikiattrs-specific options. If `markdown-it-wikirefs` is being used in conjunction with `markdown-it-caml`, `attrs` options may be set in `markdown-it-caml` and will apply to `markdown-it-wikirefs` as well.\n\n#### `attrs.enable`\n\nA boolean property that toggles parsing and rendering wikiattrs on/off.\n\n#### `attrs.render`\n\nA boolean property that toggles rendering wikiattrs on/off. This is useful in the scenario where wikiattrs are used for metadata and not for display purposes; like a yaml-stand-in.\n\n#### `attrs.title`\n\nA string to be rendered in the wikiattrs' attrbox.\n\n### `baseUrl`\n\nA base url that is applied to all urls internally.\n\n### `cssNames`\n\nCSS classnames may be overridden here.\n\n#### `cssNames.attr`\n\nClassname for wikiattrs. Default is `attr`.\n\n#### `cssNames.link`\n\nClassname for wikilinks. Default is `link`.\n\n#### `cssNames.type`\n\nClassname for typed wikilinks. Default is `type`.\n\n#### `cssNames.wiki`\n\nClassname for valid wikirefs. Default is `wiki`.\n\n#### `cssNames.invalid`\n\nClassname for invalid wikirefs. Default is `invalid`.\n\n\n#### `cssNames.reftype`\n\nClassname for wikiref type. Default is `reftype__` and combined with the slugified form of the user-defined reftype.\n\n#### `cssNames.doctype`\n\nClassname for document type. Default is `doctype__` and combined with the slugified form of the user-defined doctype.\n\n#### `cssNames.attrbox`\n\nClassname for the wikiattr attrbox. Default is `attrbox`.\n\n#### `cssNames.attrboxTitle`\n\nClassname for the wikiattr attrbox title. Default is `attrbox-title`.\n\n### `links`\n\nThese are options wikilinks-specific options.\n\n#### `links.enable`\n\nA boolean property that toggles parsing/rendering wikilinks on/off.\n\n### `prepFile: (env: any) =\u003e void`\n\n### `resolveDocType: (env: any, fname: string) =\u003e string | undefined`\n\nA function which takes in markdown-it's `env` var and the `fname` extracted from a wikilink `[[fname]]`. It should return a string which is the name of the file's document type or `undefined` if no document type exists. (Relevant file data should be stored in `env`, but if not `fname` can be used to search for the file instead.)\n\n### `resolveEmbedContent: (env: any, fname: string) =\u003e string | undefined`\n\nA function which takes in markdown-it's `env` var and the `fname` extracted from a wikilink `[[fname]]`. It should return the content of an embedded markdown file. Be sure to handle self references and cycles with care when re-using the markdown-it instance to re-render content (e.g. `md.render(content)`).\n\n### `resolveHtmlHref: (env: any, fname: string) =\u003e string | undefined`\n\nA function which takes in markdown-it's `env` var and the `fname` extracted from a wikilink `[[fname]]`. It should return the url of the wikilink-ed file or `undefined` if no such file exists. If no such file exists, the wikilink will render as disabled and marked as invalid. (Relevant file data should be stored in `env`, but if not `fname` can be used to search for the file instead.)\n\nIt is recommended to override the default, but there is a default returns: `'/' + fname.trim().toLowerCase().replace(/ /g, '-').replace(/[^\\w-]+/g, '')`.\n\n### `resolveHtmlText: (env: any, fname: string) =\u003e string | undefined`\n\nA function which takes in markdown-it's `env` var and the `fname` extracted from a wikilink `[[fname]]`. It should return a string representing the text to populate the a tag's innertext of the wikilink-ed file -- this is often its title -- or `undefined` if no such file exists. If no such file exists, the filename will be used to populate innertext instead. Be sure to apply any text formatting such as lower-casing here. (Relevant file data should be stored in `env`, but if not `fname` can be used to search for the file instead.)\n\nIt is recommended to override the default, but there is a default which returns: `fname.replace('-', ' ')`.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fwikibonsai%2Fmarkdown-it-wikirefs","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fwikibonsai%2Fmarkdown-it-wikirefs","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fwikibonsai%2Fmarkdown-it-wikirefs/lists"}