Go to main content

Textpattern CMS support forum

You are not logged in. Register | Login | Help

#1 2012-11-21 11:26:48

RedFox
Member
From: Netherlands
Registered: 2005-03-25
Posts: 805
Website

Can I escape <p> without Textile?

With smd_thumbnail and smd_macro I’ve made a user friendly tag (slideshow) > <txp:lightbox_more id="6,25,47" label="" rel="schilderijen" />

Now this will render a list (<ul>) between <p> tags. I can avoid this by using Textile > 1) type a space before the tag or 2) use notextile. … it’s simple but can be easily forgotten by my clients.

My question is: can it be done inside the source tag? >

<txp:images id="{img_id}" category="{cat}" wraptag="ul" break="li" class="lightbox-one" sort="rand()" label="{titel}" labeltag="h6">
<a href="<txp:image_url />" class="fancybox" rel="{gallery}">
<txp:smd_thumbnail type="thumb" />
</a>
</txp:images>

… so my clients have to do nothing special. Thanks for tips and tricks.

Offline

#2 2012-11-21 11:31:57

gaekwad
Server grease monkey
From: People's Republic of Cornwall
Registered: 2005-11-19
Posts: 4,137
GitHub

Re: Can I escape <p> without Textile?

Use rah_replace to zap the <p>?

Offline

#3 2012-11-21 11:57:30

RedFox
Member
From: Netherlands
Registered: 2005-03-25
Posts: 805
Website

Re: Can I escape <p> without Textile?

Thanks Pete …

… but when looking closer I’ve a problem with the output of the tag even before doing some magic with Textile or whatever … look at this piece of HTML >

<article>
<h3>Schilderijen</h3>
<p class="intro">In haar schilderijen houdt Clara ervan zich op de grens tussen figuratief en abstract te begeven. </p>
<p></p>
<h6>Museumnacht (2)</h6>
<ul class="lightbox-one">
<li>
<a class="fancybox" rel="museumnacht" href="http://www.claraelders.nl/txpnew/images/20.jpg">
</li>
<li style="display: none;">
</ul>
<p></p>
<p>Haar werk is vaak helder en vrolijk van kleur. Thema’s zijn elementen uit de natuur zoals organische vormen ontleend aan bloemen, vissen en vogels of de sfeer van vuur/aarde/lucht/water.</p>
<p></p>

<p> tags all over the place … !?

They disappear after using Textile so I presume it has something to do with using the <txp:lightbox_...> tag … !?

What’s happening here?

Last edited by RedFox (2012-11-21 11:58:15)

Offline

#4 2012-11-21 12:27:40

gaekwad
Server grease monkey
From: People's Republic of Cornwall
Registered: 2005-11-19
Posts: 4,137
GitHub

Re: Can I escape <p> without Textile?

Hi Joop – the <p> tags are all appearing outside of the images code in your opening post, which I assume means they’re all within an article body, right? The blank lines in the article body are making the <p></p> appear, I think. Can I ask why you want to remove the <p> tags? I’m curious.

Offline

#5 2012-11-21 12:53:19

Bloke
Developer
From: Leeds, UK
Registered: 2006-01-29
Posts: 11,271
Website GitHub

Re: Can I escape <p> without Textile?

It’s a limitation of the way Textile treats paragraphs, irrespective of content. A leading space or notextile. helps but, as you say, clients forget. Trying to defer the output to inside the macro fails because Textile has already rendered it on article save.

The only way I can think to do it is a “vacuum up empty tags in the HTML output” plugin (perhaps on article save). Dunno if there is one of those yet. Or you could do it on the public side by using jQuery to remove wrapper <p> tags.

Last edited by Bloke (2012-11-21 12:54:34)


The smd plugin menagerie — for when you need one more gribble of power from Textpattern. Bleeding-edge code available on GitHub.

Txp Builders – finely-crafted code, design and Txp

Offline

#6 2012-11-21 14:34:09

etc
Developer
Registered: 2010-11-11
Posts: 5,053
Website GitHub

Re: Can I escape <p> without Textile?

Replacing <txp:body /> in article form by

<rah_replace from="<p></p>" to="">
  <txp:body />
</rah_replace>

should (over)kill empty paragraphs. You can replace other stuff this way, of course. All this will (?) be easier in 4.6.

Offline

#7 2012-11-21 14:50:46

RedFox
Member
From: Netherlands
Registered: 2005-03-25
Posts: 805
Website

Re: Can I escape <p> without Textile?

Oleg … LOL, that’s heavy stuff man … :)

Bloke … I expected the <ul> would be rendered into a <p> tag … but instead the <ul> is on its own and everywhere else there are empty <p> tags. Maybe I don’t understand what you’re saying, but can you give it another try?

[edit]
Oleg … it doesn’t work … !?

Last edited by RedFox (2012-11-21 15:08:29)

Offline

#8 2012-11-21 15:16:51

etc
Developer
Registered: 2010-11-11
Posts: 5,053
Website GitHub

Re: Can I escape <p> without Textile?

RedFox wrote:

Oleg … it doesn’t work … !?

Jukka’s plugin not working? Impossible! I guess then body is rendered with <p><ul>...</ul></p>, and it’s the browser that does the cleanup, unwrapping uls. Try

<rah_replace from="<p><ul,</ul></p>" to="<ul,</ul>">
  <txp:body />
</rah_replace>

Offline

#9 2012-11-21 15:21:31

RedFox
Member
From: Netherlands
Registered: 2005-03-25
Posts: 805
Website

Re: Can I escape <p> without Textile?

Oleg … no, the article renders as follows (e.g.) >

<p></p>
<ul>...</ul>
<p></p>

See a former post

Last edited by RedFox (2012-11-21 15:23:08)

Offline

#10 2012-11-21 15:36:22

etc
Developer
Registered: 2010-11-11
Posts: 5,053
Website GitHub

Re: Can I escape <p> without Textile?

RedFox wrote:

Oleg … no, the article renders as follows (e.g.) >

How do you see it? Browsers do some html cleanup, so viewing doc source is not very reliable. Can you look into textpattern db table?

Edit: looking at the source I see

	<p><ul class="lightbox-more">
...
</ul>
</p>

Last edited by etc (2012-11-21 15:45:22)

Offline

#11 2012-11-21 16:04:37

RedFox
Member
From: Netherlands
Registered: 2005-03-25
Posts: 805
Website

Re: Can I escape <p> without Textile?

Oleg … because every <p> has a margin-bottom: 1.618em; … and so the empty ones too. If there weren’t empty <p>’s I could easily see it.

Offline

#12 2012-11-21 18:22:51

etc
Developer
Registered: 2010-11-11
Posts: 5,053
Website GitHub

Re: Can I escape <p> without Textile?

Joop, there are empty <p>, but they are created by the browser, not by Textpattern/Textile. If you look at the code of your article, say by clicking <> (HTML) button in the edit tab, you will see something like <p><txp:lightbox_more id="6,25,47" label="" rel="schilderijen" /></p>. It will be transformed into <p><ul>...</ul></p> by txp parser and served like this to the visitors browser. The browser will rightly consider it as invalid markup and unwrap <ul> from <p>, thus leaving empty <p> behind.

That’s my theory, to confirm or otherwise, replace <txp:body /> in article form by (with linebreak)

<rah_replace from="<p><ul,</ul>
</p>" to="<ul,</ul>">
  <txp:body />
</rah_replace>

Textile probably shouldn’t wrap txp: tags in paragraphs, but currently it does.

Offline

Board footer

Powered by FluxBB