CoolFace
Datasetpublic

basant307/AI_Governance_Project

sourceHugging Faceapache-2.0updated 2mo agoView on Hugging Face
0likes48downloads
README.md197 linesDownload Raw Back to linkify-it
1linkify-it2==========3 4[![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)5[![NPM version](https://img.shields.io/npm/v/linkify-it.svg?style=flat)](https://www.npmjs.org/package/linkify-it)6[![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)7[![Gitter](https://badges.gitter.im/Join%20Chat.svg)](https://gitter.im/markdown-it/linkify-it)8 9> Links recognition library with FULL unicode support.10> Focused on high quality link patterns detection in plain text.11 12__[Demo](http://markdown-it.github.io/linkify-it/)__13 14Why it's awesome:15 16- Full unicode support, _with astral characters_!17- International domains support.18- Allows rules extension & custom normalizers.19 20 21Install22-------23 24```bash25npm install linkify-it --save26```27 28Browserification is also supported.29 30 31Usage examples32--------------33 34##### Example 135 36```js37import linkifyit from 'linkify-it';38const linkify = linkifyit();39 40// Reload full tlds list & add unofficial `.onion` domain.41linkify42  .tlds(require('tlds'))          // Reload with full tlds list43  .tlds('onion', true)            // Add unofficial `.onion` domain44  .add('git:', 'http:')           // Add `git:` protocol as "alias"45  .add('ftp:', null)              // Disable `ftp:` protocol46  .set({ fuzzyIP: true });        // Enable IPs in fuzzy links (without schema)47 48console.log(linkify.test('Site github.com!'));  // true49 50console.log(linkify.match('Site github.com!')); // [ {51                                                //   schema: "",52                                                //   index: 5,53                                                //   lastIndex: 15,54                                                //   raw: "github.com",55                                                //   text: "github.com",56                                                //   url: "http://github.com",57                                                // } ]58```59 60##### Example 2. Add twitter mentions handler61 62```js63linkify.add('@', {64  validate: function (text, pos, self) {65    const tail = text.slice(pos);66 67    if (!self.re.twitter) {68      self.re.twitter =  new RegExp(69        '^([a-zA-Z0-9_]){1,15}(?!_)(?=$|' + self.re.src_ZPCc + ')'70      );71    }72    if (self.re.twitter.test(tail)) {73      // Linkifier allows punctuation chars before prefix,74      // but we additionally disable `@` ("@@mention" is invalid)75      if (pos >= 2 && tail[pos - 2] === '@') {76        return false;77      }78      return tail.match(self.re.twitter)[0].length;79    }80    return 0;81  },82  normalize: function (match) {83    match.url = 'https://twitter.com/' + match.url.replace(/^@/, '');84  }85});86```87 88 89API90---91 92__[API documentation](http://markdown-it.github.io/linkify-it/doc)__93 94### new LinkifyIt(schemas, options)95 96Creates new linkifier instance with optional additional schemas.97Can be called without `new` keyword for convenience.98 99By default understands:100 101- `http(s)://...` , `ftp://...`, `mailto:...` & `//...` links102- "fuzzy" links and emails (google.com, foo@bar.com).103 104`schemas` is an object, where each key/value describes protocol/rule:105 106- __key__ - link prefix (usually, protocol name with `:` at the end, `skype:`107  for example). `linkify-it` makes sure that prefix is not preceded with108  alphanumeric char.109- __value__ - rule to check tail after link prefix110  - _String_ - just alias to existing rule111  - _Object_112    - _validate_ - either a `RegExp` (start with `^`, and don't include the113      link prefix itself), or a validator function which, given arguments114      _text_, _pos_, and _self_, returns the length of a match in _text_115      starting at index _pos_.  _pos_ is the index right after the link prefix.116      _self_ can be used to access the linkify object to cache data.117    - _normalize_ - optional function to normalize text & url of matched result118      (for example, for twitter mentions).119 120`options`:121 122- __fuzzyLink__ - recognize URL-s without `http(s)://` head. Default `true`.123- __fuzzyIP__ - allow IPs in fuzzy links above. Can conflict with some texts124  like version numbers. Default `false`.125- __fuzzyEmail__ - recognize emails without `mailto:` prefix. Default `true`.126- __---__ - set `true` to terminate link with `---` (if it's considered as long dash).127 128 129### .test(text)130 131Searches linkifiable pattern and returns `true` on success or `false` on fail.132 133 134### .pretest(text)135 136Quick check if link MAY BE can exist. Can be used to optimize more expensive137`.test()` calls. Return `false` if link can not be found, `true` - if `.test()`138call needed to know exactly.139 140 141### .testSchemaAt(text, name, offset)142 143Similar to `.test()` but checks only specific protocol tail exactly at given144position. Returns length of found pattern (0 on fail).145 146 147### .match(text)148 149Returns `Array` of found link matches or null if nothing found.150 151Each match has:152 153- __schema__ - link schema, can be empty for fuzzy links, or `//` for154  protocol-neutral  links.155- __index__ - offset of matched text156- __lastIndex__ - index of next char after mathch end157- __raw__ - matched text158- __text__ - normalized text159- __url__ - link, generated from matched text160 161 162### .matchAtStart(text)163 164Checks if a match exists at the start of the string. Returns `Match`165(see docs for `match(text)`) or null if no URL is at the start.166Doesn't work with fuzzy links.167 168 169### .tlds(list[, keepOld])170 171Load (or merge) new tlds list. Those are needed for fuzzy links (without schema)172to avoid false positives. By default:173 174- 2-letter root zones are ok.175- biz|com|edu|gov|net|org|pro|web|xxx|aero|asia|coop|info|museum|name|shop|рф are ok.176- encoded (`xn--...`) root zones are ok.177 178If that's not enough, you can reload defaults with more detailed zones list.179 180### .add(key, value)181 182Add a new schema to the schemas object.  As described in the constructor183definition, `key` is a link prefix (`skype:`, for example), and `value`184is a String to alias to another schema, or an Object with `validate` and185optionally `normalize` definitions.  To disable an existing rule, use186`.add(key, null)`.187 188 189### .set(options)190 191Override default options. Missed properties will not be changed.192 193 194## License195 196[MIT](https://github.com/markdown-it/linkify-it/blob/master/LICENSE)197 
basant307/AI_Governance_Project · CoolFace