{"id":19218623,"url":"https://github.com/shepherdwind/match-pairs","last_synced_at":"2025-07-23T17:04:19.714Z","repository":{"id":238096669,"uuid":"795863228","full_name":"shepherdwind/match-pairs","owner":"shepherdwind","description":"A plugin that fixes the logic for bold text in markdown-it","archived":false,"fork":false,"pushed_at":"2024-05-06T14:24:34.000Z","size":23,"stargazers_count":1,"open_issues_count":2,"forks_count":1,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-01-04T19:22:51.803Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"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/shepherdwind.png","metadata":{"files":{"readme":"readme-cn.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,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2024-05-04T09:23:48.000Z","updated_at":"2024-05-06T14:24:38.000Z","dependencies_parsed_at":"2024-05-06T15:52:16.718Z","dependency_job_id":"d981dcc3-63ab-4662-be41-512f518fabfe","html_url":"https://github.com/shepherdwind/match-pairs","commit_stats":null,"previous_names":["shepherdwind/match-pairs"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/shepherdwind%2Fmatch-pairs","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/shepherdwind%2Fmatch-pairs/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/shepherdwind%2Fmatch-pairs/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/shepherdwind%2Fmatch-pairs/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/shepherdwind","download_url":"https://codeload.github.com/shepherdwind/match-pairs/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":240292395,"owners_count":19778311,"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":[],"created_at":"2024-11-09T14:27:29.116Z","updated_at":"2025-02-23T09:14:42.938Z","avatar_url":"https://github.com/shepherdwind.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# markdown-match-pairs\n\n这是一个修正 markdown-it 对于加粗逻辑的插件。\n\n## 问题\n\n默认情况，markdown-it 识别 `**` 是否可以作为标签闭合的原则是这样的\n- 如果左边有空格，那么 `open = true`\n- 如果右边有空格，那么 `close = true`\n- 如果都不是空格，看是否有特殊字符 `+-=` 之类的关键字符，或者其他语言的分割符比如 `：` 中文的分号，如果有这些符号也作为空格处理\n\n这导致了以下解析结果\n```js\nrender('**==foo==**') === '\u003cp\u003e**\u003cmark\u003efoo\u003c/mark\u003e**\u003c/p\u003e';\nrender('**中文：**中文') === '\u003cp\u003e**中文：**中文\u003c/p\u003e';\n```\n\n实际情况，这里都期望是输出一个 strong 标签。\n\n## 实现逻辑\n\n这个实现逻辑是这样的，插入一个函数在 `balance_pairs` 之前。在 inline 的 rule 解析完成以后，对 delimiters 进行修正，修正以后，`**` 是否可以闭合取决于前面是否有没有 open 的 `**`.\n\n使用这个插件以后，上面例子输出如下\n\n```js\nrender('**==foo==**') === '\u003cp\u003e\u003cstrong\u003e\u003cmark\u003efoo\u003c/mark\u003e\u003c/strong\u003e\u003c/p\u003e';\nrender('**中文：**中文') === '\u003cp\u003e\u003cstrong\u003e中文：\u003c/strong\u003e中文\u003c/p\u003e';\n```\n\n\n## install\n\n```\nnpm install markdown-match-pairs --save\n```\n\n## Usage\n\n```js\nvar md = require('markdown-it')()\n            .use(require('markdown-it-mark'));\n```\n\n## 测试\n\n本插件从 markdown-it 仓库把现有的用例都复制过来了，保证老的用例是通过的。\n\n## License\n\nMIT","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fshepherdwind%2Fmatch-pairs","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fshepherdwind%2Fmatch-pairs","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fshepherdwind%2Fmatch-pairs/lists"}