{"id":17310607,"url":"https://github.com/digitalmoksha/linkify-it-rb","last_synced_at":"2025-04-14T14:15:03.844Z","repository":{"id":29354621,"uuid":"32888895","full_name":"digitalmoksha/linkify-it-rb","owner":"digitalmoksha","description":"Links recognition library used with motion-markdown-it (for Ruby and RubyMotion)","archived":false,"fork":false,"pushed_at":"2023-01-14T17:24:20.000Z","size":76,"stargazers_count":4,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-04-14T14:14:58.783Z","etag":null,"topics":["linkify","motion-markdown-it","ruby","rubymotion"],"latest_commit_sha":null,"homepage":"","language":"Ruby","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"other","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/digitalmoksha.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}},"created_at":"2015-03-25T20:26:22.000Z","updated_at":"2023-01-02T22:18:37.000Z","dependencies_parsed_at":"2023-01-16T22:30:36.846Z","dependency_job_id":null,"html_url":"https://github.com/digitalmoksha/linkify-it-rb","commit_stats":null,"previous_names":[],"tags_count":7,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/digitalmoksha%2Flinkify-it-rb","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/digitalmoksha%2Flinkify-it-rb/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/digitalmoksha%2Flinkify-it-rb/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/digitalmoksha%2Flinkify-it-rb/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/digitalmoksha","download_url":"https://codeload.github.com/digitalmoksha/linkify-it-rb/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248894943,"owners_count":21179153,"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":["linkify","motion-markdown-it","ruby","rubymotion"],"created_at":"2024-10-15T12:37:48.812Z","updated_at":"2025-04-14T14:15:03.816Z","avatar_url":"https://github.com/digitalmoksha.png","language":"Ruby","funding_links":[],"categories":[],"sub_categories":[],"readme":"# linkify-it-rb\n\n[![Gem Version](https://badge.fury.io/rb/linkify-it-rb.svg)](http://badge.fury.io/rb/linkify-it-rb)\n[![Build Status](https://github.com/digitalmoksha/linkify-it-rb/actions/workflows/ci.yml/badge.svg)](https://github.com/digitalmoksha/linkify-it-rb/actions/workflows/ci.yml)\n\nThis gem is a port of the [linkify-it javascript package](https://github.com/markdown-it/linkify-it) by Vitaly Puzrin, that is used for the [markdown-it](https://github.com/markdown-it/markdown-it) package.\n\n_Currently synced with linkify-it 4.0.1_\n\n---\n\nLinks recognition library with full unicode support. Focused on high quality link pattern detection in plain text.  For use with both Ruby and RubyMotion.\n\n__[Javascript Demo](http://markdown-it.github.io/linkify-it/)__\n\nFeatures:\n\n- Full unicode support, with astral characters\n- International domain support\n- Allows rules extension \u0026 custom normalizers\n\n\nInstall\n-------\n\n### Ruby\n\nAdd it to your project's `Gemfile`\n\n\tgem 'linkify-it-rb'\n\nand run `bundle install`\n\n### RubyMotion\n\nAdd it to your project's `Gemfile`\n\n\tgem 'linkify-it-rb'\n\nEdit your `Rakefile` and add\n\n\trequire 'linkify-it-rb'\n\nand run `bundle install`\n\nUsage examples\n--------------\n\n##### Example 1\n\n```ruby\nlinkify = Linkify.new\n\n# Reload full tlds list \u0026 add unofficial `.onion` domain.\nlinkify.tlds('onion', true)      # Add unofficial `.onion` domain\nlinkify.add('git:', 'http:')     # Add `git:` protocol as \"alias\"\nlinkify.add('ftp:', null)        # Disable `ftp:` protocol\nlinkify.set({fuzzyIP: true})     # Enable IPs in fuzzy links (without schema)\n\nlinkify.test('Site github.com!'))\n=\u003e true\n\nlinkify.match('Site github.com!'))\n=\u003e [#\u003cLinkify::Match @schema=\"\", @index=5, @lastIndex=15, @raw=\"github.com\", @text=\"github.com\", @url=\"github.com\"\u003e]\n```\n\n##### Example 2. Add twitter mentions handler\n\n```ruby\nlinkify.add('@', {\n  validate: lambda do |text, pos, obj|\n    tail = text.slice(pos..-1)\n    if (!obj.re[:twitter])\n      obj.re[:twitter] =  Regexp.new('^([a-zA-Z0-9_]){1,15}(?!_)(?=$|' + LinkifyRe::SRC_Z_P_CC + ')')\n    end\n    if (obj.re[:twitter] =~ tail)\n      return 0 if (pos \u003e= 2 \u0026\u0026 text[pos - 2] == '@')\n      return tail.match(obj.re[:twitter])[0].length\n    end\n    return 0\n  end,\n  normalize: lambda do |m, obj|\n    m.url = 'https://twitter.com/' + m.url.sub(/^@/, '')\n  end\n})\n```\n\n\nAPI\n---\n\n### LinkifyIt.new(schemas, options)\n\nCreates new linkifier instance with optional additional schemas.\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 a Hash, 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-rb` 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  - _Hash_\n    - _validate_ - either a `RegExp (start with `^`, and don't include the\n      link prefix itself), or a validator block 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 block 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 MAYBE 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 nil 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### .matchAtStart(text)\n\nChecks if a match exists at the start of the string. Returns `Match`\n(see docs for `match(text)`) or nil if no URL is at the start.\nDoesn't work with fuzzy links.\n\n### .tlds(list[, keepOld])\n\nLoad (or merge) new tlds list. These are needed for fuzzy links (without schema)\nto avoid false positives. By default this algorithm uses:\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### .set(options)\n\nOverride default options. Missed properties will not be changed.\n\n## License\n\n[MIT](https://github.com/digitalmoksha/linkify-it-rb/blob/master/LICENSE)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdigitalmoksha%2Flinkify-it-rb","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdigitalmoksha%2Flinkify-it-rb","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdigitalmoksha%2Flinkify-it-rb/lists"}