How to use the linkify-it.add function in linkify-it

To help you get started, we’ve selected a few linkify-it examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github dev-andremonteiro / react-native-twitter-clone / app / utils.js View on Github external
let hexArr = hex.match(/[A-Za-z0-9]{2}/g).map(v => parseInt(v, 16));
  return `rgba(${hexArr[0]},${hexArr[1]},${hexArr[2]},`;
}

export const rgbaColors = {
  primary: hexToRGBArray(colors.primary),
  secondary: hexToRGBArray(colors.secondary),
  dark_gray: hexToRGBArray(colors.dark_gray),
  light_gray: hexToRGBArray(colors.light_gray),
  exlight_gray: hexToRGBArray(colors.exlight_gray),
  exexlight_gray: hexToRGBArray(colors.exexlight_gray),
  white: hexToRGBArray(colors.white)
};

import Hyperlink from "react-native-hyperlink";
const customLinkify = require("linkify-it")()
  .add("@", {
    validate: function(text, pos, self) {
      var tail = text.slice(pos);

      if (!self.re.twitter) {
        self.re.twitter = new RegExp(
          "^([a-zA-Z0-9_]){1,15}(?!_)(?=$|" + self.re.src_ZPCc + ")"
        );
      }
      if (self.re.twitter.test(tail)) {
        // Linkifier allows punctuation chars before prefix,
        // but we additionally disable `@` ("@@mention" is invalid)
        if (pos >= 2 && tail[pos - 2] === "@") {
          return false;
        }
        return tail.match(self.re.twitter)[0].length;
github Doha26 / Instagram-clone / src / utils / methods.tsx View on Github external
import React from "react";
// @ts-ignore
import Hyperlink from "react-native-hyperlink";
import {colors} from "./theme";
import {Text} from "native-base";

const first_linkify = require("linkify-it")()
    .add("@", {
        validate: function(text:any, pos:any, self:any) {
            var tail = text.slice(pos);

            if (!self.re.twitter) {
                self.re.twitter = new RegExp(
                    "^([a-zA-Z0-9_]){1,15}(?!_)(?=$|" + self.re.src_ZPCc + ")"
                );
            }
            if (self.re.twitter.test(tail)) {

                if (pos >= 2 && tail[pos - 2] === "@") {
                    return false;
                }
                return tail.match(self.re.twitter)[0].length;
            }

linkify-it

Links recognition library with FULL unicode support

MIT
Latest version published 11 months ago

Package Health Score

71 / 100
Full package analysis