{"id":18721983,"url":"https://github.com/realign/markdown-it-copy","last_synced_at":"2025-04-12T14:32:49.251Z","repository":{"id":41264657,"uuid":"228977757","full_name":"ReAlign/markdown-it-copy","owner":"ReAlign","description":"🔌 A markdown-it-plugin that copy code and others.","archived":false,"fork":false,"pushed_at":"2020-03-30T16:56:48.000Z","size":1695,"stargazers_count":13,"open_issues_count":2,"forks_count":7,"subscribers_count":0,"default_branch":"master","last_synced_at":"2025-04-10T13:18:25.104Z","etag":null,"topics":["markdown-it","markdown-it-plugin","markdown-it-plugins"],"latest_commit_sha":null,"homepage":"https://realign.github.io/markdown-it-copy/","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/ReAlign.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2019-12-19T04:54:07.000Z","updated_at":"2024-12-12T11:35:05.000Z","dependencies_parsed_at":"2022-09-20T23:31:25.959Z","dependency_job_id":null,"html_url":"https://github.com/ReAlign/markdown-it-copy","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/ReAlign%2Fmarkdown-it-copy","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ReAlign%2Fmarkdown-it-copy/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ReAlign%2Fmarkdown-it-copy/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ReAlign%2Fmarkdown-it-copy/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/ReAlign","download_url":"https://codeload.github.com/ReAlign/markdown-it-copy/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248581357,"owners_count":21128155,"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","markdown-it-plugins"],"created_at":"2024-11-07T13:39:12.767Z","updated_at":"2025-04-12T14:32:49.230Z","avatar_url":"https://github.com/ReAlign.png","language":"JavaScript","readme":"# markdown-it-copy\n\n[![NPM version][npm-image]][npm-url]\n[![download][downloads-image]][github-url]\u003cbr\u003e\n[![NPM][nodei-image]][npm-url]\n\n\u003e A markdown-it-plugin that copy code and others.\n\n## Todo\n\n* [ ] 复制内容尾部增加版权说明\n\n## Example\n\n[🔗 example](https://realign.github.io/markdown-it-copy/)\n\n![image_png](https://img.alicdn.com/tfs/TB1fcYbrhD1gK0jSZFKXXcJrVXa-1764-830.png)\n\n## Installation\n\n```bash\nnpm install markdown-it-copy -S\n```\n\n## Usage\n\n### Plugin\n\n```js\nconst options = {\n    btnText: String, // 'copy' | button text\n    failText: String, // 'copy fail' | copy-fail text\n    successText: String, // 'copy success' | copy-success text\n    successTextDelay: Number, // 2000 | successText show time [ms]\n    extraHtmlBeforeBtn: String, // '' | a html-fragment before \u003cbutton\u003e\n    extraHtmlAfterBtn: String, // '' | a html-fragment after \u003cbutton\u003e\n    showCodeLanguage: Boolean, // false | show code language before [btn || extraHtmlBeforeBtn] | [add-after-1.1.0]\n    attachText: String, // '' | some text append copyText， Such as: copyright | [add-after-1.2.0]\n};\n\nconst md = require('markdown-it')()\n    .use(require('markdown-it-copy'), options);\n\nmd.render(`${mdText}`);\n\n// Tips: you may need to highlight your code, as follow:\n\nconst hljs = require('highlight.js');\nconst hlOpts = {\n  highlight(str, lang) {\n    if (lang \u0026\u0026 hljs.getLanguage(lang)) {\n      try {\n        return hljs.highlight(lang, str).value;\n      } catch (__) {\n        console.log(__);\n      }\n    }\n    return '';\n  },\n};\n\nrequire('markdown-it')(hlOpts);\n```\n\n### Style of Button and Notify\n\nNormal-theme:\n\n* css: [default.css](https://github.com/ReAlign/markdown-it-copy/blob/master/theme/default.css)\n* stylus: [default.styl](https://github.com/ReAlign/markdown-it-copy/blob/master/theme/default.styl)\n\nalso, you can write style by yourself.\n\nthe html structure and class as follow:\n\n```html\n\u003cdiv class=\"m-mdic-copy-wrapper\"\u003e\n    \u003c!-- if need show it --\u003e\n    \u003cspan class=\"u-mdic-copy-code_lang\"\u003e${codeLang}\u003c/span\u003e\n    ${extraHtmlBeforeBtn}\n    \u003cdiv class=\"u-mdic-copy-notify\"\u003e\n        ${successText}\n    \u003c/div\u003e\n    \u003cbutton class=\"u-mdic-copy-btn j-mdic-copy-btn\"\u003e\n        ${btnText}\n    \u003c/button\u003e\n    ${extraHtmlAfterBtn}\n\u003c/div\u003e\n```\n\n## Releases\n\n### 1.0.x\n\n#### 1.0.0、1.0.1\n\n* [new function]\n  * Support basic copy function\n\n### 1.1.x\n\n#### 1.1.0\n\n* [new function]\n  * Support show `code-language` before `btn` or `extraHtmlBeforeBtn`\n\n#### 1.1.1\n\n* [fix bug]\n  * Compatible with a variety of templates\n    * `\u003cdiv class=\"language-js\"\u003e`\n    * `\u003ccode class=\"language-js\"\u003e`\n    * `\u003cpre class=\"language-js\"\u003e`\n    * etc.\n\n#### 1.1.2\n\n* [fix bug]\n  * `Single quotes` encode\n    * error: `'` -\u003e `\u0026apos;`\n    * ok: `'` -\u003e `\\'`\n\n### 1.2.x\n\n#### 1.2.0\n\n* [new function]\n  * Support append text behind to copy content, such as: Copyright info.\n\n[github-url]: https://github.com/ReAlign/markdown-it-copy\n[npm-url]: https://www.npmjs.com/package/markdown-it-copy\n[npm-image]: https://img.shields.io/npm/v/markdown-it-copy.svg\n[downloads-image]: https://img.shields.io/npm/dt/markdown-it-copy.svg\n[nodei-image]: https://nodei.co/npm/markdown-it-copy.png?downloads=true\u0026downloadRank=true\u0026stars=true\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frealign%2Fmarkdown-it-copy","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Frealign%2Fmarkdown-it-copy","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frealign%2Fmarkdown-it-copy/lists"}