michelf / php-markdown

Parser for Markdown and Markdown Extra derived from the original Markdown.pl by John Gruber.
http://michelf.ca/projects/php-markdown/
Other
3.42k stars 529 forks source link

Nofollow links #93

Open xPaw opened 11 years ago

xPaw commented 11 years ago

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

funivan commented 11 years ago

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>
michelf commented 11 years ago

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.

funivan commented 11 years ago

Callback will be great solution =)

attiks commented 9 years ago

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>

michelf commented 9 years ago

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.

jeffmcneill commented 3 years ago

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

michelf commented 3 years ago

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

michelf commented 3 years ago

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.

IzzySoft commented 3 years ago

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)?