Textpattern CMS support forum
You are not logged in. Register | Login | Help
- Topics: Active | Unanswered
Pages: 1
how to add class to href
How on earth can one add a class to an href in textile?
I see the following code
<code>
<pre>
return preg_replace_callback(‘/
([\s[{(]|[[:punct:]])? # $pre
“ # start
(’ . $this->c . ‘) # $atts
([^”]+) # $text
\s?
(?:\(([^)]+)\)(?=”))? # $title
“:
(\S+\b) # $url
(\/)? # $slash
([^\w\/;]*) # $post
(?=\s|$)
/Ux’, array(&$this, “fLink”), $text);
</pre>
</code>
I we should be able to extract an $atts using a (class). in the quotes before the text. This does not work, however.
Last edited by datafirm (2005-05-24 07:40:37)
Offline
Re: how to add class to href
It looks like it was written to work, but something is not quite right, try the following:
<notextile><pre>
“(“tos”)linkname”: http://www.textpattern.com
=> <p><a href=“http://www.textpattern.com” class=”“tos”“>linkname</a></p>
“(style=“tos”)linkname”: http://www.textpattern.com
=> <p><a href=“http://www.textpattern.com” class=“style=“tos”“>linkname</a></p>
</pre></notextile>
(remove the space before http)
I guess that’s why it is not advertised as working.
Last edited by Sencer (2005-05-24 09:05:56)
Offline
Re: how to add class to href
My solution to remove those extra double quotes. This way one can pass in a class for a Textile link and it will validate.
add this line:
$class = str_replace('"', '', $class);
To this block from the pba function:
<code>
<pre>
if (preg_match(“/\(([^()]+)\)/U”, $matched, $cls)) {
$class = $cls1;
$class = str_replace(‘”’, ‘’, $class);
$matched = str_replace($cls0, ‘’, $matched);
}
</pre>
</code>
Offline
Re: how to add class to href
Have any changes been made to this behavior? Having the same problem…. lots of article links and no way of classing them?
Jamie
Offline
Pages: 1