Go to main content

Textpattern CMS support forum

You are not logged in. Register | Login | Help

#1 2005-05-24 07:39:58

datafirm
Archived Plugin Author
From: Seattle, WA
Registered: 2004-07-22
Posts: 35
Website

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

#2 2005-05-24 09:04:20

Sencer
Archived Developer
From: cgn, de
Registered: 2004-03-23
Posts: 1,803
Website

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

#3 2005-05-24 22:09:26

datafirm
Archived Plugin Author
From: Seattle, WA
Registered: 2004-07-22
Posts: 35
Website

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

#4 2005-10-26 21:54:20

soulship
Member
From: Always Sunny Charleston
Registered: 2004-04-30
Posts: 669
Website

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

Board footer

Powered by FluxBB