How to use the autolinker.link function in autolinker

To help you get started, we’ve selected a few autolinker 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 joehand / hyperirc-web / index.js View on Github external
if (data.from === 'dat-gitter') {
      var split = data.message.split(/(\([\S]*\))/)
      data.gitter = true
      // long gitter messages don't have username at beginning
      if (split.length > 1) {
        data.from = split[1].slice(1,split[1].length - 1)
        data.message = split[2]
      } else {
        // continued message, get previous message user
        data.from = state.messages[0].from
        data.message = split[0]
      }
    }

    data.moment = moment(data.timestamp)
    data.html = Autolinker.link(data.message)
    return data
  }
github withspectrum / spectrum / src / App / RightColumn / Components / Bubbles / index.js View on Github external
const formatMessageForFrequencyLinks = (message: string): string => {
    if (!message) {
      return '';
    }
    const cleanMessage = sanitizeHtml(message);

    const linkedMessage = Autolinker.link(
      cleanMessage.replace(
        FREQUENCIES,
        `$1https://spectrum.chat/${activeCommunity}/$2`,
      ),
    );
    // Remove the "spectrum.chat" part from the link text so in the message
    // you just see "~frequency", but it's linked to the frequency
    return linkedMessage.replace(FREQUENCY_ANCHORS, '>$1');
  };
github uiur / ssslack / client / route.js View on Github external
ALLOWED_ATTR: ['href'],
        ALLOW_DATA_ATTR: false
      })

      return h('.message', [image].concat([
        h('.right', [
          h('span.sender', message.sender),
          h('span.timestamp', message.timestamp),
          h('span.content', convertHTML('<span>' + pureContent + '</span>'))
        ])
      ]))
    } else {
      return h('.message.message-without-image', [
        h('span.sender', message.sender),
        h('span.timestamp', message.timestamp),
        h('span.content', convertHTML('<span>' + autolinker.link(message.content, { stripPrefix: false }) + '</span>'))
      ])
    }
  })
github kogg / hovercards / integrations / instagram / index.js View on Github external
.then(function(results) {
				var user        = Object.assign({}, results[0], results[1]);
				var user_counts = _.result(user, 'counts');

				var text = Autolinker.link(_.result(user, 'bio', ''), { mention: 'instagram', hashtag: 'instagram' });

				return _.pick(
					Object.assign(
						user_to_account(user),
						{
							text:  text,
							stats: {
								content:   Number(_.result(user_counts, 'media')),
								followers: Number(_.result(user_counts, 'followed_by')),
								following: Number(_.result(user_counts, 'follows'))
							},
							content: results[2] && {
								api:     'instagram',
								type:    'account_content',
								id:      _.result(user, 'username'),
								content: _.map(results[2], media_to_content)
github k0kubun / Nocturn / src / components / tweet.js View on Github external
autolinkedText(tweet) {
    let text = tweet.text;

    for (let entity of tweet.entities.urls) {
      text = text.replace(entity.url, entity.expanded_url);
    }
    for (let entity of (tweet.entities.media || [])) {
      text = text.replace(entity.url, entity.display_url);
    }

    return {
      __html: Autolinker.link(
        text.replace(/\n/g, '<br>'),
        { className: 'external-link' },
      ),
    };
  }
github withspectrum / spectrum / src / App / components / ChatDetail / index.js View on Github external
formatMessage(message) {
    if (!message) {
      return '';
    }
    let cleanMessage = sanitizeHtml(message);
    let linkedMessage = Autolinker.link(cleanMessage);
    return linkedMessage;
  }
github hackjutsu / Lepton / app / containers / snippet / index.js View on Github external
renderSnippetDescription (gist) {
    const { title, description, customTags } = descriptionParser(gist.brief.description)

    const htmlForDescriptionSection = []
    if (title.length &gt; 0) {
      htmlForDescriptionSection.push(<div>{ title }</div>)
    }
    htmlForDescriptionSection.push(
      <div>
    )
    htmlForDescriptionSection.push(
      <div>
        { customTags.length &gt; 0
          ? <span>
            <div>
            <span>{ customTags.substring('#tags:'.length) }</span>
          
          : null }
        <span></span></div></span></div></div>
github devnews / web / src / components / GitHub / GitHubRepo.js View on Github external
let getDescription = () => {
        const safeDescription = escape(props.repo.description);
        return {
            __html: Autolinker.link(safeDescription, {
                email: false,
                phone: false,
                twitter: false,
            }),
        };
    };