Go to main content

Textpattern CMS support forum

You are not logged in. Register | Login | Help

#1 2004-03-11 21:22:02

andreas
Member
Registered: 2004-02-28
Posts: 453
Website

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

#2 2004-03-11 21:34:14

mamash
Member
From: Prague
Registered: 2004-02-21
Posts: 127
Website

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

#3 2004-03-11 21:41:41

andreas
Member
Registered: 2004-02-28
Posts: 453
Website

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

#4 2004-03-11 22:07:58

Drew
Plugin Author
From: Red pillar box, Baker St.
Registered: 2004-02-15
Posts: 53
Website

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

#5 2004-03-12 08:13:02

thekolonel
Archived Plugin Author
From: NYC
Registered: 2004-03-01
Posts: 28
Website

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

#6 2004-03-31 04:35:36

jdueck
Plugin Author
From: Minneapolis, MN
Registered: 2004-02-27
Posts: 147
Website

Re: XHTML in text field

Dude. that is some heavy regexp.

[bows in deference]

Offline

#7 2004-04-21 03:00:34

Cantide
Member
From: Wellington, New Zealand
Registered: 2004-03-03
Posts: 27
Website

Re: XHTML in text field

thekolonel, will your hack work in the latest version of txp?

Offline

#8 2004-04-21 04:50:22

jason
Member
From: USA
Registered: 2004-02-23
Posts: 85
Website

Re: XHTML in text field

thekolonel: that is very, very nice.

Offline

#9 2004-04-21 08:06:37

thekolonel
Archived Plugin Author
From: NYC
Registered: 2004-03-01
Posts: 28
Website

Re: XHTML in text field

This still works as-is. It’s spared me tons of pain with blockquotes, image shadows, etc.

Offline

#10 2004-04-21 08:47:06

bjorn
Member
From: sweden
Registered: 2004-02-24
Posts: 10
Website

Re: XHTML in text field

yeah, thanks a lot, it’s great! Regular expressions rule, gotta learn how to do that someday soon…

Offline

#11 2004-04-21 16:47:36

jbrew
Member
From: Imperial Beach, California
Registered: 2004-03-04
Posts: 78
Website

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

#12 2004-04-22 05:37:16

thekolonel
Archived Plugin Author
From: NYC
Registered: 2004-03-01
Posts: 28
Website

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

Board footer

Powered by FluxBB