{"id":15017166,"url":"https://github.com/discretetom/bimark","last_synced_at":"2026-04-13T02:30:17.746Z","repository":{"id":146173768,"uuid":"614831393","full_name":"DiscreteTom/bimark","owner":"DiscreteTom","description":"Auto create bidirectional links between markdown files.","archived":false,"fork":false,"pushed_at":"2023-04-05T16:16:50.000Z","size":151,"stargazers_count":7,"open_issues_count":3,"forks_count":2,"subscribers_count":2,"default_branch":"main","last_synced_at":"2024-10-14T07:40:56.174Z","etag":null,"topics":["bimark","foam","markdown","md","nodejs","obsidian"],"latest_commit_sha":null,"homepage":"","language":"TypeScript","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/DiscreteTom.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE","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}},"created_at":"2023-03-16T12:12:39.000Z","updated_at":"2024-05-21T23:23:31.000Z","dependencies_parsed_at":null,"dependency_job_id":"34391646-ceeb-41b6-8eeb-645e768d9848","html_url":"https://github.com/DiscreteTom/bimark","commit_stats":{"total_commits":153,"total_committers":2,"mean_commits":76.5,"dds":0.0065359477124182774,"last_synced_commit":"44f38a926e6861c303299e89d1ca1270251897a7"},"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/DiscreteTom%2Fbimark","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/DiscreteTom%2Fbimark/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/DiscreteTom%2Fbimark/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/DiscreteTom%2Fbimark/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/DiscreteTom","download_url":"https://codeload.github.com/DiscreteTom/bimark/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":219847861,"owners_count":16556346,"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":["bimark","foam","markdown","md","nodejs","obsidian"],"created_at":"2024-09-24T19:49:59.177Z","updated_at":"2026-04-13T02:30:17.674Z","avatar_url":"https://github.com/DiscreteTom.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# [[BiMark]]\n\n[![npm](https://img.shields.io/npm/v/bimark?style=flat-square)](https://www.npmjs.com/package/bimark)\n![license](https://img.shields.io/github/license/DiscreteTom/bimark?style=flat-square)\n\nAuto create [[bidirectional links]] between markdown files.\n\n## Installation\n\nFor API usage:\n\n```bash\nnpm install bimark\n```\n\nOther usages:\n\n- [Online playground](https://discretetom.github.io/bimark-playground/), see [bimark-playground](https://github.com/DiscreteTom/bimark-playground).\n- CLI, see [bimark-cli](https://github.com/DiscreteTom/bimark-cli).\n- VSCode extension, see [vscode-bimark](https://github.com/DiscreteTom/vscode-bimark).\n\n## Usage\n\n### Basic\n\nCreate definitions in markdown documents with `[[name]]`:\n\n```md\n# [[BiMark]]\n\nBiMark is a tool to auto create [[bidirectional links]] between markdown files.\n\nOnce bidirectional links are created, you can use it to navigate between markdown files.\n```\n\nIn the above example, `BiMark` and `bidirectional links` are definitions.\n\nAfter rendering, all definitions and references will be modified to add an id, and all references will be automatically replaced with links:\n\n```md\n# \u003cspan id=\"bimark\"\u003eBiMark\u003c/span\u003e\n\n[\u003cspan id=\"bimark-ref-1\"\u003eBiMark\u003c/span\u003e](#bimark) is a tool to auto create \u003cspan id=\"bidirectional-links\"\u003ebidirectional links\u003c/span\u003e between markdown files.\n\nOnce the [\u003cspan id=\"bidirectional-links-ref-1\"\u003ebidirectional links\u003c/span\u003e](#bidirectional-links) is created, you can use it to navigate between markdown files.\n```\n\n### Explicit Reference\n\nYou can create references explicitly using `[[#id]]` or `[[@name]]`:\n\n```md\n# [[BiMark]]\n\n[[#bimark]] is a tool to auto create [[bidirectional links]] between markdown files.\n\nOnce the [[@bidirectional links]] is created, you can use it to navigate between markdown files.\n```\n\n### Advanced Definition\n\n- You can use `[[name:id]]` to specify the id of the definition.\n- If there are aliases for a definition, you can use `[[name|alias1|alias2]]`.\n  - If you don't specify the id, the name will be used to calculate the id.\n\n```md\n# [[BiMark|bi-mark|bimark]]\n\n# [[BiMark|bi-mark|bimark:bimark]]\n```\n\n### Escaped Reference\n\nYou can escape a reference using `[[!any string]]`:\n\n```md\n# [[BiMark]]\n\n[[!BiMark]] is a tool to auto create [[bidirectional link]] between markdown files.\n```\n\nThe escaped reference will not check if the definition exists, not be replaced with a link, and will not be assigned with an id.\n\n### API\n\n```ts\nimport { BiMark } from \"bimark\";\n\n// collect from and render a single file, return the rendered content\nBiMark.singleFile(\"# [[BiMark]]\");\n\n// collect definitions\nconst bm = new BiMark().collect(\"file1.md\", content1);\n\n// render files\nbm.render(\"file1.md\", content1);\nbm.render(\"file2.md\", content2);\n\n// list reverse links\nbm.getReverseRefs({ name: \"BiMark\" }); // =\u003e ['file1.md#bimark-ref-1', 'file2.md#bimark-ref-2']\n```\n\n### BiML\n\nYou can also use `BiML` to parse and render HTML documents, the APIs are almost the same as `BiMark`.\n\n```ts\nimport { BiML } from \"bimark\";\n\n// collect from and render a single file, return the rendered content\nBiML.singleFile(\"\u003cp\u003e[[BiML]]\u003c/p\u003e\");\n\n// collect definitions\nconst bm = new BiML().collect(\"file1.html\", content1);\n\n// render files\nbm.render(\"file1.html\", content1);\nbm.render(\"file2.html\", content2);\n\n// list reverse links\nbm.getReverseRefs({ name: \"BiML\" }); // =\u003e ['file1.html#biml-ref-1', 'file2.html#biml-ref-2']\n```\n\n### Extensibility\n\nBiMark provides low-level classes `BiDoc`/`BiParser` for you:\n\n- `BiDoc` is the base class of `BiMark`/`BiML`. You can extend this class to parse other file types.\n- `BiParser` is the low level parser to parse text string to `Fragment` for further processing.\n\n## FAQ\n\n- Where can I make a definition/reference?\n  - For markdown, texts(e.g. headings, paragraphs, lists).\n  - For HTML, you can customize this by passing `selectors` options to `BiML.collect/render`.\n- How to solve the problem of duplicate ids?\n  - You can use `[[name:id]]` to specify the id of a definition.\n- What characters are allowed in the name/alias of a definition?\n  - Regex: `` [^$\u0026+,/:;=?!@\"'\u003c\u003e#%{}|\\\\^~[\\]`\\n\\r] ``.\n  - Yes, spaces are allowed.\n  - Language specific characters are allowed, e.g. `[[中文]]` is allowed.\n- What characters are allowed in the id of a definition?\n  - Regex: `` [^$\u0026+,/:;=?!@ \"'\u003c\u003e#%{}|\\\\^~[\\]`\\n\\r] ``.\n  - No, spaces are not allowed.\n- What characters are allowed in the escaped reference?\n  - Regex: `.*?`\n\n## [CHANGELOG](https://github.com/DiscreteTom/bimark/blob/main/CHANGELOG.md)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdiscretetom%2Fbimark","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdiscretetom%2Fbimark","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdiscretetom%2Fbimark/lists"}