{"id":13393460,"url":"https://github.com/markdown-it/linkify-it","last_synced_at":"2025-06-21T19:11:03.266Z","repository":{"id":27041198,"uuid":"30506329","full_name":"markdown-it/linkify-it","owner":"markdown-it","description":"Links recognition library with full unicode support","archived":false,"fork":false,"pushed_at":"2023-12-01T21:47:39.000Z","size":190,"stargazers_count":693,"open_issues_count":12,"forks_count":62,"subscribers_count":11,"default_branch":"master","last_synced_at":"2025-06-17T04:35:28.448Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"http://markdown-it.github.io/linkify-it/","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/markdown-it.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":".github/FUNDING.yml","license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null},"funding":{"github":"markdown-it","open_collective":"markdown-it","tidelift":"npm/linkify-it"}},"created_at":"2015-02-08T21:22:37.000Z","updated_at":"2025-06-10T16:09:50.000Z","dependencies_parsed_at":"2023-12-04T02:11:25.118Z","dependency_job_id":null,"html_url":"https://github.com/markdown-it/linkify-it","commit_stats":{"total_commits":149,"total_committers":14,"mean_commits":"10.642857142857142","dds":"0.24832214765100669","last_synced_commit":"5e79093543092562b4348ea58395110357f3d296"},"previous_names":[],"tags_count":28,"template":false,"template_full_name":null,"purl":"pkg:github/markdown-it/linkify-it","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/markdown-it%2Flinkify-it","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/markdown-it%2Flinkify-it/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/markdown-it%2Flinkify-it/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/markdown-it%2Flinkify-it/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/markdown-it","download_url":"https://codeload.github.com/markdown-it/linkify-it/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/markdown-it%2Flinkify-it/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":260633501,"owners_count":23039367,"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-07-30T17:00:53.353Z","updated_at":"2025-06-21T19:10:58.256Z","avatar_url":"https://github.com/markdown-it.png","language":"JavaScript","funding_links":["https://github.com/sponsors/markdown-it","https://opencollective.com/markdown-it","https://tidelift.com/funding/github/npm/linkify-it"],"categories":["JavaScript","Packages","包","目录","others","URL","Number"],"sub_categories":["URL"],"readme":"linkify-it\n==========\n\n[![CI](https://github.com/markdown-it/linkify-it/actions/workflows/ci.yml/badge.svg)](https://github.com/markdown-it/linkify-it/actions/workflows/ci.yml)\n[![NPM version](https://img.shields.io/npm/v/linkify-it.svg?style=flat)](https://www.npmjs.org/package/linkify-it)\n[![Coverage Status](https://img.shields.io/coveralls/markdown-it/linkify-it/master.svg?style=flat)](https://coveralls.io/r/markdown-it/linkify-it?branch=master)\n[![Gitter](https://badges.gitter.im/Join%20Chat.svg)](https://gitter.im/markdown-it/linkify-it)\n\n\u003e Links recognition library with FULL unicode support.\n\u003e Focused on high quality link patterns detection in plain text.\n\n__[Demo](http://markdown-it.github.io/linkify-it/)__\n\nWhy it's awesome:\n\n- Full unicode support, _with astral characters_!\n- International domains support.\n- Allows rules extension \u0026 custom normalizers.\n\n\nInstall\n-------\n\n```bash\nnpm install linkify-it --save\n```\n\nBrowserification is also supported.\n\n\nUsage examples\n--------------\n\n##### Example 1\n\n```js\nimport linkifyit from 'linkify-it';\nconst linkify = linkifyit();\n\n// Reload full tlds list \u0026 add unofficial `.onion` domain.\nlinkify\n  .tlds(require('tlds'))          // Reload with full tlds list\n  .tlds('onion', true)            // Add unofficial `.onion` domain\n  .add('git:', 'http:')           // Add `git:` protocol as \"alias\"\n  .add('ftp:', null)              // Disable `ftp:` protocol\n  .set({ fuzzyIP: true });        // Enable IPs in fuzzy links (without schema)\n\nconsole.log(linkify.test('Site github.com!'));  // true\n\nconsole.log(linkify.match('Site github.com!')); // [ {\n                                                //   schema: \"\",\n                                                //   index: 5,\n                                                //   lastIndex: 15,\n                                                //   raw: \"github.com\",\n                                                //   text: \"github.com\",\n                                                //   url: \"http://github.com\",\n                                                // } ]\n```\n\n##### Example 2. Add twitter mentions handler\n\n```js\nlinkify.add('@', {\n  validate: function (text, pos, self) {\n    const tail = text.slice(pos);\n\n    if (!self.re.twitter) {\n      self.re.twitter =  new RegExp(\n        '^([a-zA-Z0-9_]){1,15}(?!_)(?=$|' + self.re.src_ZPCc + ')'\n      );\n    }\n    if (self.re.twitter.test(tail)) {\n      // Linkifier allows punctuation chars before prefix,\n      // but we additionally disable `@` (\"@@mention\" is invalid)\n      if (pos \u003e= 2 \u0026\u0026 tail[pos - 2] === '@') {\n        return false;\n      }\n      return tail.match(self.re.twitter)[0].length;\n    }\n    return 0;\n  },\n  normalize: function (match) {\n    match.url = 'https://twitter.com/' + match.url.replace(/^@/, '');\n  }\n});\n```\n\n\nAPI\n---\n\n__[API documentation](http://markdown-it.github.io/linkify-it/doc)__\n\n### new LinkifyIt(schemas, options)\n\nCreates new linkifier instance with optional additional schemas.\nCan be called without `new` keyword for convenience.\n\nBy default understands:\n\n- `http(s)://...` , `ftp://...`, `mailto:...` \u0026 `//...` links\n- \"fuzzy\" links and emails (google.com, foo@bar.com).\n\n`schemas` is an object, where each key/value describes protocol/rule:\n\n- __key__ - link prefix (usually, protocol name with `:` at the end, `skype:`\n  for example). `linkify-it` makes sure that prefix is not preceded with\n  alphanumeric char.\n- __value__ - rule to check tail after link prefix\n  - _String_ - just alias to existing rule\n  - _Object_\n    - _validate_ - either a `RegExp` (start with `^`, and don't include the\n      link prefix itself), or a validator function which, given arguments\n      _text_, _pos_, and _self_, returns the length of a match in _text_\n      starting at index _pos_.  _pos_ is the index right after the link prefix.\n      _self_ can be used to access the linkify object to cache data.\n    - _normalize_ - optional function to normalize text \u0026 url of matched result\n      (for example, for twitter mentions).\n\n`options`:\n\n- __fuzzyLink__ - recognize URL-s without `http(s)://` head. Default `true`.\n- __fuzzyIP__ - allow IPs in fuzzy links above. Can conflict with some texts\n  like version numbers. Default `false`.\n- __fuzzyEmail__ - recognize emails without `mailto:` prefix. Default `true`.\n- __---__ - set `true` to terminate link with `---` (if it's considered as long dash).\n\n\n### .test(text)\n\nSearches linkifiable pattern and returns `true` on success or `false` on fail.\n\n\n### .pretest(text)\n\nQuick check if link MAY BE can exist. Can be used to optimize more expensive\n`.test()` calls. Return `false` if link can not be found, `true` - if `.test()`\ncall needed to know exactly.\n\n\n### .testSchemaAt(text, name, offset)\n\nSimilar to `.test()` but checks only specific protocol tail exactly at given\nposition. Returns length of found pattern (0 on fail).\n\n\n### .match(text)\n\nReturns `Array` of found link matches or null if nothing found.\n\nEach match has:\n\n- __schema__ - link schema, can be empty for fuzzy links, or `//` for\n  protocol-neutral  links.\n- __index__ - offset of matched text\n- __lastIndex__ - index of next char after mathch end\n- __raw__ - matched text\n- __text__ - normalized text\n- __url__ - link, generated from matched text\n\n\n### .matchAtStart(text)\n\nChecks if a match exists at the start of the string. Returns `Match`\n(see docs for `match(text)`) or null if no URL is at the start.\nDoesn't work with fuzzy links.\n\n\n### .tlds(list[, keepOld])\n\nLoad (or merge) new tlds list. Those are needed for fuzzy links (without schema)\nto avoid false positives. By default:\n\n- 2-letter root zones are ok.\n- biz|com|edu|gov|net|org|pro|web|xxx|aero|asia|coop|info|museum|name|shop|рф are ok.\n- encoded (`xn--...`) root zones are ok.\n\nIf that's not enough, you can reload defaults with more detailed zones list.\n\n### .add(key, value)\n\nAdd a new schema to the schemas object.  As described in the constructor\ndefinition, `key` is a link prefix (`skype:`, for example), and `value`\nis a String to alias to another schema, or an Object with `validate` and\noptionally `normalize` definitions.  To disable an existing rule, use\n`.add(key, null)`.\n\n\n### .set(options)\n\nOverride default options. Missed properties will not be changed.\n\n\n## License\n\n[MIT](https://github.com/markdown-it/linkify-it/blob/master/LICENSE)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmarkdown-it%2Flinkify-it","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmarkdown-it%2Flinkify-it","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmarkdown-it%2Flinkify-it/lists"}