Textpattern CMS support forum
You are not logged in. Register | Login | Help
- Topics: Active | Unanswered
#1 2006-11-24 18:49:36
- Nell
- Member
- From: Mexico City, Mexico
- Registered: 2005-06-21
- Posts: 48
[textile] Classes and links with Textile 2
Hi!
Is there a way to add a class to a link with Textile 2? I tried (class)"link":http://www.url.com
, "(class)link":http://www.url.com
, and other variations, including spans, but it’s not working.
Thank you!
Offline
#2 2006-12-13 06:20:50
- stdmedia
- Member
- From: Canada
- Registered: 2006-01-05
- Posts: 51
Re: [textile] Classes and links with Textile 2
I’m also wondering this one myself. So I’ll give it a little bump.
Offline
#3 2006-12-14 16:25:43
- namtrok
- New Member
- Registered: 2006-12-14
- Posts: 1
Re: [textile] Classes and links with Textile 2
You were close, here is what I have discovered:
First in HTML:
<p><a href=“http://google.com” style=“style;”>This is a testlink</a></p>
<p><a href=“http://google.com” id=“coolid”>This is a testlink</a></p>
<p><a href=“http://google.com” class=“classer”>This is a testlink</a></p>
Then in textile:
"{style}This is a testlink":http://google.com
"(#coolid)This is a testlink":http://google.com
"(classer)This is a testlink":http://google.com
</notextle>
to do title text and a class the textile would be:
"(classer)This is the link text(This is the Title text)":http://google.com
Offline
#4 2006-12-15 05:56:23
- stdmedia
- Member
- From: Canada
- Registered: 2006-01-05
- Posts: 51
Re: [textile] Classes and links with Textile 2
Thank you very much.
Offline
Re: [textile] Classes and links with Textile 2
Hi guys, I’ve just upgraded to txp 4.0.4 and have the same problems as Nell i.e. I can neither give a class or id to a link.
Running namtroks 4 testcases through the “article” textarea within textpattern 4.0.4 results in testcase 1 working (adding a style) but none of the others.
Here’s the results:
"{style}This is a testlink":http://google.com
works fine..
"(#coolid)This is a testlink":http://google.com
results in:
[a href="http://google.com"](#coolid)This is a testlink[/a]
and
"(classer)This is a testlink":http://google.com
results in:
[a href="http://google.com"](classer)This is a testlink[/a]
and
"(classer)This is the link text(This is the Title text)":http://google.com
results in:
[a href="http://google.com" title="This is the Title text"](classer)This is a testlink[/a]
The testcases that fail on my blog are working when ran through textile.thresholdstate.com.
I’m stumped…
p.s. Of course, change all square brackets to their correct < and > counterparts in the above results.
Offline
Re: [textile] Classes and links with Textile 2
This works as it should (just tested it on Alex’s Textile homepage):
"[fr]{some inline style}(class#id)text(title)":http://url
(to test the most complex case, the less complex one works just as fine)
But with this kind of complexity, Textile isn’t the right tool for the job. Writing raw xhtml works better (well, at least we don’t need to remind another syntax).
Remember that Textile isn’t a replacement for HTML, just a text shortcut for several things we do a lot.
Last edited by Jeremie (2007-01-05 09:44:33)
Offline
Re: [textile] Classes and links with Textile 2
Bonjour Jeremie,
I understand that Textile isn’t a replacement for XHTML – that isn’t the question.
I’m just wondering why the test cases above pass when ran through the Textile homepage but not when used within an article in Textpattern 4.0.4.
It’s exactly the same classTextile.php being used in both cases.
If anyone else that has a 4.0.4 installation can verify that the testcases work/fail when entered as part of an articles body (and not the excerpt) I’d be extremely grateful.
Thanks again,
Brian.
Offline
Re: [textile] Classes and links with Textile 2
Are you sure? I don’t know the svn timeline by heart anymore, but there definitely was some work done on Textile since the 4.0.4 release.
I just tested my string on a rev 2191 install, worked fine too.
If this is a big issue for you, maybe you should update to the subversion’s head revision, or at least update the Textile class to it.
Offline
Re: [textile] Classes and links with Textile 2
Hi again,
I’ve grabbed the latest svn version of classTextile.php (I’ve even tried the crockery version) but nothing seems to have changed. I’m running PHP 5 so perhaps the functionality of preg_replace_callback has changed (not likely).
The following regExp, used by classTextile to parse the attributes never returns a result:
(?:(?:\([^)]+\))|(?:\{[^}]+\})|(?:\[[^]]+\])|(?:\<(?!>)|(?|\<\>|\=|[()]+(?! )))*
I can’t see anything wrong with the regular expression and indeed, the following bit of textile:
"(testclass)This is a testlink(title here)":http://www.google.com
should produce a match for the text (testclass) through the
(?:\([^)]+\))
part of the regExp (the very first piece of the overall regExp).
Adding a print_r($m) within the function fLink produces:
Array ( [0] => "(testclass)This is a testlink(title here)":http://www.google.com [1] => [2] => [3] => (testclass)This is a testlink [4] => title here [5] => http://www.google.com [6] => [7] => )
where:
0 = full regExp match
1 = $pre
2 = $atts
3 = $text
4 = $title
5 = $url
6 = $slash
7 = $post
As you can see, array index 2 is empty and the class (testclass) has been amalgamated into the link text within Array index 3.
I’m starting to think it’s my version of PHP (or something non-Textile related) to be the fault. Again, Im stumped…
Sorry to bog the forum down with such a tedious problem!
Offline
#10 2007-01-05 21:39:29
- zem
- Developer Emeritus
- From: Melbourne, Australia
- Registered: 2004-04-08
- Posts: 2,579
Re: [textile] Classes and links with Textile 2
Please test using the online textile preview. It’s running the current copy of Textile from svn. If you can reproduce a bug there, use the “report a bug” link.
All of your examples seem to work fine there.
Alex
Offline
Re: [textile] Classes and links with Textile 2
It’s not PHP 5. Subversion Textile works fine on OVH for example, using PHP 5.1.5.
Maybe you have a strange version or configuration of your PHP ?
Offline
#12 2007-01-06 17:54:55
- Ace of Dubs
- Member
- Registered: 2006-04-17
- Posts: 446
Re: [textile] Classes and links with Textile 2
FWIW, I also had this problem in 4.0.4 but resolved it by updating classTextile.php to the latest version (rev 2182)
Offline