GithubHelp home page GithubHelp logo

Comments (4)

gregjacobs avatar gregjacobs commented on May 24, 2024

Hey choxnox, how are you looking to specify this? Would a rel option that applies the "rel" attribute to all generated anchor tags work? Or are you looking for more control that you can specify it on a per-anchor basis?

from autolinker.js.

jamcole avatar jamcole commented on May 24, 2024

I'd like this too.

For now, I pipe the output through jQuery to do it reliably, but obviously it's a little heavy because it has to create a dom and such.

var retHtml = Autolinker.link(html, {newWindow: false, stripPrefix: false, truncate: 100, twitter: false, className: 'autolinked'});
var retSel = $($.parseHTML('<div class="autolink-outer-wrapper"><div class="autolink-inner-wrapper">'+retHtml+'</div><div>'));
retSel.find('a.autolinked').attr('rel', 'nofollow');
var newHtml = retSel.find('.autolink-inner-wrapper').first().html();

from autolinker.js.

pruhstal avatar pruhstal commented on May 24, 2024

Have a fix here: 02f2e81

from autolinker.js.

gregjacobs avatar gregjacobs commented on May 24, 2024

Finally possible using replaceFn! Example:

var html = Autolinker.link( text, {
    replaceFn : function( autolinker, match ) {
        var tag = autolinker.getTagBuilder().build( match );  // Returns an Autolinker.HtmlTag instance
        tag.setAttr( 'rel', 'nofollow' );

        return tag;
    }
} );

from autolinker.js.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.