Textpattern CMS support forum
You are not logged in. Register | Login | Help
- Topics: Active | Unanswered
Here's a possible fix for the image alignment problem
Hi,
as you’ve probably noticed, aligning images with the Textile alignment conventions (i.e. adding a “<”, “>” or “=” after the introducing “!”) is a nightmare – it doesn’t work at all or breaks your image reference, prepending the alignment char to the filename.
I tinkered a little with the classTextile.php, and it seems that the interaction between the CSS regexp (“($this->c)”) and the overall regexp is the problem – if you comment it out, the alignment works ok.
However, it seems like a trick fixes the entire problem for images:
In line 608 of “classTextile.php” in function function image($text), remove the trailing “?” from the regexp fragment like so:
ACTUAL: (\<|\=|\>)? # optional alignment atts
NEW: (\<|\=|\>) # optional alignment atts — REMOVED TRAILING ‘?’ TO MAKE PATTERN UNGREEDY
Since the parameter “/U” (ungreedy) is given for the entire regexp, the questionmark has the inverse meaning and results in a “greedy” pattern. Removing it seems to fix the problem (but I’m afraid I have to admit that I don’t exactly understand why… darn experimental programming/bugfixing :).
If you encountered this problem as well, please try out the fix-hack and tell me if it works for you, too. Since I don’t have a TXP site up and running yet (not with content and lots of Textile code, anyway), I’d like to know if there are any side-effects on larger sites. It’s not likely, though, since the function only applies to images.
Cheers,
- Björn
Offline
#2 2005-11-16 21:21:21
- zem
- Developer Emeritus
- From: Melbourne, Australia
- Registered: 2004-04-08
- Posts: 2,579
Re: Here's a possible fix for the image alignment problem
Since the parameter ”/U” (ungreedy) is given for the entire regexp, the questionmark has the inverse meaning and results in a “greedy” pattern. Removing it seems to fix the problem
The question mark doesn’t mean “greedy” in that context; it means “optional”. Removing it breaks any image that doesn’t specify an alignment.
Alex
Offline
#3 2005-11-16 21:32:30
- zem
- Developer Emeritus
- From: Melbourne, Australia
- Registered: 2004-04-08
- Posts: 2,579
Re: Here's a possible fix for the image alignment problem
??
does the trick.
Alex
Offline