php-markdown icon indicating copy to clipboard operation
php-markdown copied to clipboard

Nofollow links

Open xPaw opened this issue 11 years ago • 9 comments

Would be nice to have an option to make all links rel="nofollow".

xPaw avatar Apr 28 '13 13:04 xPaw

it will be nice to add any attribute to any block For example:

# h1 title # [::attibute]
## h2 title ## [::attibute]

[attribute::][data-tip="test"]

And it convert to

<h1 data-tip="test">h1 title</h1>
<h2 data-tip="test">h2 title</h2>

funivan avatar May 07 '13 14:05 funivan

If I offer this it'll be a setting on the parser, not something within the syntax. I'm seriously considering offering a callback in the API to allow altering emitted link URLs and attributes, which would make this rather easy to do.

michelf avatar May 11 '13 10:05 michelf

Callback will be great solution =)

funivan avatar Jul 25 '13 12:07 funivan

I need something similar to be able to add a data- attribute to image tags, so I can post process the output to turn some images into picture.

Is there any progress on this issue?

I saw there's already support for id and class using {#id .picture} maybe we can do something like {#id .picture :data-group=test} which gets translated into <img data-group=test>

attiks avatar Dec 07 '14 15:12 attiks

Is there any progress on this issue?

Not much. The time can afford to put on PHP Markdown is rather limited these days.

I saw there's already support for id and class using {#id .picture} maybe we can do something like {#id .picture :data-group=test} which gets translated into <img data-group=test>

If you want to give it a shot, look at the doExtraAttributes function, as well as the id_class_attr_catch_re and id_class_attr_nocatch_re regular expressions.

michelf avatar Dec 07 '14 15:12 michelf

Google is strongly recommending href attributes. Some solution is needed. https://developers.google.com/search/docs/advanced/guidelines/qualify-outbound-links

jeffmcneill avatar Jan 08 '21 18:01 jeffmcneill

This should have been closed earlier. You can write [link](url){rel=nofollow} using the MarkdownExtra parser since 2014.

michelf avatar Jan 08 '21 19:01 michelf

Oh, well... maybe I closed it too soon. This is about adding the attribute to all links. It should probably work using something like the url_filter_func configuration but for the rel attribute.

michelf avatar Jan 08 '21 19:01 michelf

While on it, and if it's not asked too much: I'd love to see an option to have all external links rel=nofollow by default and just mark exceptions (maybe like [link](url){rel=} to unset the attribute). Would that be possible (and feasible)?

IzzySoft avatar May 07 '21 23:05 IzzySoft