php-markdown
php-markdown copied to clipboard
Nofollow links
Would be nice to have an option to make all links rel="nofollow"
.
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>
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.
Callback will be great solution =)
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>
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.
Google is strongly recommending href attributes. Some solution is needed. https://developers.google.com/search/docs/advanced/guidelines/qualify-outbound-links
This should have been closed earlier. You can write [link](url){rel=nofollow}
using the MarkdownExtra parser since 2014.
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.
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)?