Textpattern CMS support forum
You are not logged in. Register | Login | Help
- Topics: Active | Unanswered
XHTML in text field
I want to put a div-tag around the first paragraph of some of my entries because they will be styled differently.
However, when I put the XHTML into the text field it get enclosed by p-tags.
Is there a way to avoid this? I tried the textile way:
div(abstract) bla bla but it didn’t get parsed.
Any ideas?
Last edited by andreas (2004-03-11 21:22:49)
Offline
Re: XHTML in text field
You would be duplicating a block element. Why not simply make the first paragraph of a different class? E.g. “p(first). Some text”
Last edited by mamash (2004-03-11 21:34:43)
Who’s gonna textdrive you home tonight?
Offline
Re: XHTML in text field
OK. I see. I had tried that but had forgotten the dot after the closing bracket so I thought it didn’t work.
Thanks.
Offline
Re: XHTML in text field
The essence of this question is the same as mine about definition lists. I think Textile needs to take better account of XHTML.
drew mclellan
Offline
Re: XHTML in text field
I made a small change to the textile code that will prevent an HTML tag on a line by itself from being auto-wrapped in “p” tags. I did this so I could have multi-paragraph blockquotes. It should solve your problem.
On line 437, just replace this:
<code>$line = preg_replace(‘/^(?!\\t|<\\/?pre|<\\/?code|$| )(.*)/’, “\\t<p>$1</p>”, $line);</code>
with this:
<code>if (!preg_match(‘/^<[\\/\\!]*?[^<>]*?>(<br \\/>)?$/i’, $line)) { $line = preg_replace(‘/^(?!\\t|<\\/?pre|<\\/?code|$| )(.*)/’, “\\t<p>$1</p>”, $line); }</code>
Edited: backslashes didn’t turn up
Edited 2: make sure there’s a blank line between the tag and the previous/next item
Last edited by thekolonel (2004-03-12 08:50:24)
Offline
Re: XHTML in text field
Dude. that is some heavy regexp.
[bows in deference]
Offline
Re: XHTML in text field
thekolonel, will your hack work in the latest version of txp?
Offline
Re: XHTML in text field
thekolonel: that is very, very nice.
Offline
Re: XHTML in text field
This still works as-is. It’s spared me tons of pain with blockquotes, image shadows, etc.
Offline
Re: XHTML in text field
yeah, thanks a lot, it’s great! Regular expressions rule, gotta learn how to do that someday soon…
Offline
Re: XHTML in text field
Big question here re: the code below – when I replace it I don’t get syntax highlighting but when I remove the second *? it all highlights correctly. Is the code ok even if it doesn’t bring the correct highlights??? Cos this fixes a serious problem I have been dealing with! Thanks.
> if (!preg_match(‘/^<[\/\!]*?[^<>]*?>(<br \/>)?$/i’, $line)) { $line = preg_replace(‘/^(?!\t|<\/?pre|<\/?code|$| )(.*)/’, “\t<p>$1</p>”, $line); }
To even the least of these…
Offline
Re: XHTML in text field
The code as written in the original post should pass syntax (anything in quotes should, really). What editor are you using?
Last edited by thekolonel (2004-04-22 05:37:54)
Offline