How to use the linkifyjs/html function in linkifyjs

To help you get started, we’ve selected a few linkifyjs 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 DefinitelyTyped / DefinitelyTyped / types / linkifyjs / linkifyjs-tests.tsx View on Github external
tagName: "span"
    });

    linkifyHtml("#swag", {
        tagName: {
            hashtag: "span"
        }
    });

    /* target */

    linkifyHtml("github.com", {
        target: "_parent"
    });

    linkifyHtml("test-email@example.com", {
        target: {
            url: "_parent",
            email: null
        }
    });

    /* validate */

    // Don't linkify links that don't begin in a protocol
    // e.g., "http://google.com" will be linkified, but "google.com" will not.
    linkifyHtml("www.google.com", {
        validate: {
            url(value) {
                return /^(http|ftp)s?:\/\//.test(value);
            }
        }
github DefinitelyTyped / DefinitelyTyped / types / linkifyjs / linkifyjs-tests.tsx View on Github external
linkifyHtml("", {
        events: {
            click(e) {
                alert("Link clicked!");
            },
            mouseover(e) {
                alert("Link hovered!");
            }
        }
    });

    /* defaultProtocol */

    /* format */

    linkifyHtml("", {
        format(value, type) {
            if (type === "url" && value.length > 50) {
                value = value.slice(0, 50) + "…";
            }
            return value;
        }
    });

    linkifyHtml("", {
        format: {
            url(value) {
                return value.length > 50 ? value.slice(0, 50) + "…" : value;
            }
        }
    });
github Human-Connection / Human-Connection / backend / src / middleware / xssMiddleware.js View on Github external
function clean(dirty) {
  if (!dirty) {
    return dirty
  }

  // Convert embeds to a-tags
  dirty = embedToAnchor(dirty)
  dirty = linkifyHtml(dirty)
  dirty = sanitizeHtml(dirty, {
    allowedTags: [
      'iframe',
      'img',
      'p',
      'h3',
      'h4',
      'br',
      'hr',
      'b',
      'i',
      'em',
      'strong',
      'a',
      'pre',
      'ul',
github Zamiell / hanabi-live / public / js / src / chat.ts View on Github external
export const add = (data: ChatMessage, fast: boolean) => {
    let chat;
    if (data.room === 'lobby') {
        chat = $('#lobby-chat-text');
    } else if ($('#lobby-chat-pregame-text').is(':visible')) {
        chat = $('#lobby-chat-pregame-text');
    } else {
        chat = $('#game-chat-text');
    }
    if (!chat) {
        throw new Error('Failed to get the chat element in the "chat.add()" function.');
    }

    // Linkify any links
    data.msg = linkifyHtml(data.msg, {
        target: '_blank',
    });

    // Convert emotes to images
    data.msg = fillDiscordEmotes(data.msg);
    data.msg = fillLocalEmotes(data.msg);

    // Get the hours and minutes from the time
    const datetime = new Intl.DateTimeFormat(
        undefined,
        {
            hour: '2-digit',
            minute: '2-digit',
            hour12: false,
        },
    ).format(new Date(data.datetime));
github assembl / assembl / assembl / static2 / js / app / utils / linkify.js View on Github external
export function transformLinksInHtml(html: string): string {
  let content = linkifyHtml(html);
  content = addIframeForStoryChief(content);
  return content;
}
github HiDeoo / YaTA / src / libs / Message.ts View on Github external
const parsedMessage = Array.from(message)

    const emotes = this.parseAdditionalEmotes(words, userstate.emotes || {})
    this.parseEmotes(parsedMessage, emotes)
    this.parseHighlights(words, parsedMessage)
    this.parseMentions(words, parsedMessage, currentUsername)
    this.parsePreviews(message)

    let parsedMessageStr = escape(parsedMessage).join('')

    if (!_.isNil(userstate.bits) && userstate.bits > 0) {
      parsedMessageStr = this.parseCheermotes(parsedMessageStr, userstate.bits)
    }

    return linkifyHtml(parsedMessageStr, {
      attributes: {
        'data-tip': '',
      },
    })
  }
github nanu-c / axolotl / axolotl-web / src / main.js View on Github external
linkify: function (content) {
      return LinkifyHtml(content);
    },
  },
github webex / react-widgets / packages / node_modules / @ciscospark / react-container-activity-list / src / formatters / linkify.js View on Github external
export default (activity) => {
  const linkifyOptions = {
    ignoreTags: ['code', 'pre'],
    className: 'ciscospark-activity-link'
  };

  if (activity.content) {
    return Object.assign({}, activity, {content: linkifyHtml(activity.content, linkifyOptions)});
  }

  return Object.assign({}, activity, {content: linkifyStr(activity.displayName, linkifyOptions)});
};
github coralproject / talk / src / core / server / services / comments / pipeline / phases / linkify.ts View on Github external
export const linkify: IntermediateModerationPhase = async ({
  comment,
}): Promise => ({
  body: linkifyjs(comment.body, config),
});

linkifyjs

Find URLs, email addresses, #hashtags and @mentions in plain-text strings, then convert them into HTML <a> links.

MIT
Latest version published 12 months ago

Package Health Score

79 / 100
Full package analysis