Textpattern CMS support forum
You are not logged in. Register | Login | Help
- Topics: Active | Unanswered
How do I strip <p> tags from an txp:excerpt w/o turning off Textile?
Howdy—
I’m presenting an excerpt inline and I want to get rid of the paragraph elements (<p>
… </p>
) generated by Textile— but I want to keep Textile on for the typography and stuff. Is there a way to do this?
I’m excerpting the same articles in another context, and I want those excerpts untouched, so changing the excerpts at the article level isn’t what I need.
Thanks!
Edit: The solution was right under my nose!
Last edited by johnstephens (2009-05-15 16:58:59)
Offline
#2 2009-05-14 01:13:06
- immarabi
- Member
- Registered: 2008-04-29
- Posts: 57
Re: How do I strip <p> tags from an txp:excerpt w/o turning off Textile?
Hi,
Just put notextile.
and then one space before your text and it will remove the <p> tags.
Last edited by immarabi (2009-05-14 01:13:23)
Offline
Re: How do I strip <p> tags from an txp:excerpt w/o turning off Textile?
notextile.
seems to eliminate all Textile, the same as choosing “Leave text untouched” under “Excerpt Markup”. As I said before, I want to keep Textile active for its typography and automatic escaping of &
.
The other thing is that I don’t want to strip the paragraph element from the excerpt in every context, just in this listform:
<li><strong><txp:title />:</strong> <txp:excerpt /></li>
Elsewhere, I’m using the same excerpt, and I want to keep the <p>
tags:
<h3>About this thing: </h3>
<txp:excerpt />
I expect that php-jujitsu may be needed to accomplish this.
Last edited by johnstephens (2009-05-14 01:39:42)
Offline
Re: How do I strip <p> tags from an txp:excerpt w/o turning off Textile?
<txp:pax_grep from="|<p>|,|</p>|" to=","><txp:excerpt /></txp:pax_grep>
You can probably also use rah_replace for this, but I already have pax_grep active on my site.
Offline
Re: How do I strip <p> tags from an txp:excerpt w/o turning off Textile?
Or a slightly simpler pattern:
<txp:pax_grep from="/<\/?p>/" to=""><txp:excerpt /></txp:pax_grep>
Code is topiary
Offline
Re: How do I strip <p> tags from an txp:excerpt w/o turning off Textile?
Dude, why are you making my life more awesome all the live-long day?
Offline
Re: How do I strip <p> tags from an txp:excerpt w/o turning off Textile?
The various native methods are outlined in this TXP Tip.
Offline
Re: How do I strip <p> tags from an txp:excerpt w/o turning off Textile?
Thanks, Jonathan— I’m a huge fan of TXP Tips, and I’ve seen this article before.
Those methods would be fine if the excerpt was never supposed to have <p>
elements, but as I said before, I’m still using the normal <p>
-wrapped excerpts for these articles in another context. Doing Textile-fu on the article level doesn’t allow for that differentiation, and requires thinking about it every time I write a new article in that section.
Offline
#9 2009-05-15 12:11:54
- MyOwn31
- New Member
- From: Russia
- Registered: 2008-10-15
- Posts: 9
Re: How do I strip <p> tags from an txp:excerpt w/o turning off Textile?
Haven’t you tried putting a space before the excerpt text? This works on ThresoldState at least…
Offline