Go to main content

Textpattern CMS support forum

You are not logged in. Register | Login | Help

#25 2018-10-09 14:27:51

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

Re: Can I escape <p> without Textile?

etc wrote #314494:

Now that Stef is in charge of it, we could probably disable wrapping in <p></p> the lines starting with a <tag> (html or txp).

Hehe, if that’s possible it’d be grand. Which reminds me, would you like commit access :)

failing that, a Pull Request is fine… hint hint


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

#26 2018-10-09 20:49:53

jakob
Admin
From: Germany
Registered: 2005-01-20
Posts: 4,599
Website

Re: Can I escape <p> without Textile?

RedFox wrote #314491:

It’s 2018 and I still having <p>‘s all over the place. Using smd_macro gives:

<p></p><figure><p></p><img>......

That doesn’t look like an initial <p> tag caused by textile when placing a tag at the beginning of a line, though. Surely that would be <p><figure> … </figure></p>.

If you’re getting that in your macro, you might need more if statements to only output certain code when there is actual content. Sometimes, I agree, though, sometimes it’s really hard to avoid, especially with if_first/if_last and if_different.

What you can also do is use smd_wrap and wrap your entire body block in:

<txp:smd_wrap_all transform="replace|string|<p></p>|"> … </txp:smd_wrap_all>

That should remove all empty <p> tags. If you have some that happen to have spaces between them, you may need:

<txp:smd_wrap_all transform="replace|regex|#<p>\s?<\/p>#|"> … </txp:smd_wrap_all>

If memory serves, \s? should replace <p> tags with spaces, carriage returns and tabs or nothing at all between them.


TXP Builders – finely-crafted code, design and txp

Offline

#27 2018-10-09 21:34:01

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

Re: Can I escape <p> without Textile?

jakob wrote #314501:

That doesn’t look like an initial <p> tag caused by textile when placing a tag at the beginning of a line, though. Surely that would be <p><figure> … </figure></p>.

I think that is <p><figure> … </figure></p>, but, since it is invalid (p accepts only phrasing content), browsers transform it into

<p></p><figure> … </figure><p></p>

Offline

#28 2018-10-10 15:24:25

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

Re: Can I escape <p> without Textile?

Bloke wrote #314498:

Which reminds me, would you like commit access :) … failing that, a Pull Request is fine…

Whichever is less work for you :-)

Offline

#29 2018-10-10 16:00:40

Destry
Member
From: Haut-Rhin
Registered: 2004-08-04
Posts: 4,909
Website

Re: Can I escape <p> without Textile?

Stef and etc in charge of Textile. Things are gonna get lively! :thumb up:

A-hem, hr(class). ;)

Offline

#30 2018-10-10 16:06:57

Destry
Member
From: Haut-Rhin
Registered: 2004-08-04
Posts: 4,909
Website

Re: Can I escape <p> without Textile?

etc wrote #314494:

p:empty{display:none;}.

I never knew about such a pseudo element before. All these many years of f-ing around with spaces and trying to remember whatever else escape. Kill me now. Though usually it’s not the p element I have to escape; it’s often other types of tags.

Yes, can we please just write on the left edge of the box without the workarounds. I mean, I’m sure there have been reasons to not touch Textile before, but if we have since evolved to a higher plane of existence/capability, let’s make it so.

Offline

#31 2018-10-10 16:49:32

jakob
Admin
From: Germany
Registered: 2005-01-20
Posts: 4,599
Website

Re: Can I escape <p> without Textile?

etc wrote #314502:

I think that is <p><figure> … </figure></p>, but, since it is invalid (p accepts only phrasing content), browsers transform it into

<p></p><figure> … </figure><p></p>...

You could be right there. I didn’t know that. If that happens in the browser and not during markup output by the CMS, the replace methods I noted above won’t work, I guess.


TXP Builders – finely-crafted code, design and txp

Offline

#32 2018-10-10 18:18:03

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

Re: Can I escape <p> without Textile?

jakob wrote #314519:

… the replace methods I noted above won’t work, I guess.

That’s right … they don’t. I’ve tried them all.

Offline

#33 2018-10-10 18:21:10

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

Re: Can I escape <p> without Textile?

Destry wrote #314513:

Yes, can we please just write on the left edge of the box without the workarounds. I mean, I’m sure there have been reasons to not touch Textile before, but if we have since evolved to a higher plane of existence/capability, let’s make it so.

+1

Offline

#34 2018-10-10 18:34:39

jakob
Admin
From: Germany
Registered: 2005-01-20
Posts: 4,599
Website

Re: Can I escape <p> without Textile?

RedFox wrote #314522:

That’s right … they don’t. I’ve tried them all.

All? If it always happens around a figure, maybe this one would work on the cms output:

<txp:smd_wrap_all transform="replace|regex|#(<p>)?(<\/?figure>)(</p>)?#|$2"> … </txp:smd_wrap_all>

Perhaps… ?


TXP Builders – finely-crafted code, design and txp

Offline

#35 2018-10-11 07:52:50

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

Re: Can I escape <p> without Textile?

Destry wrote #314513:

Yes, can we please just write on the left edge of the box without the workarounds.

Done in 4.7.2 txp Textile, soon on Pete’s demo site, please test.

Offline

#36 2018-10-11 08:00:51

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

Re: Can I escape <p> without Textile?

jakob wrote #314524:

… maybe this one would work on the cms output:

It doesn’t … :o

Offline

Board footer

Powered by FluxBB