Textpattern CMS support forum

You are not logged in. Register | Login | Help

#31 2017-12-18 10:06:04

Bloke
Developer
From: Leeds, UK
Registered: 2006-01-29
Posts: 8,834
Website

Re: Poll: useful 'escape' transforms

etc wrote #308320:

I think, e.g. for “inline” Textile. I have added implode value (the name to debate)

Nice, that’ll be handy. I made a note on the commit about the name of the transform before I saw this post. You’re right, we need to think of something less geeky for it. No inspiration right now, sorry.


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

#32 2017-12-18 12:01:50

etc
Developer
Registered: 2010-11-11
Posts: 3,418
Website

Re: Poll: useful 'escape' transforms

Bloke wrote #308321:

we need to think of something less geeky for it.

That’s also the purpose of this thread, including other values too. Is excerpt="tags" less geeky than excerpt="strip" for strip_tags()? I’d better finish it now, not sure to have an internet connection the next week.

Offline

#33 2017-12-18 12:09:18

phiw13
Plugin Author
From: Japan
Registered: 2004-02-27
Posts: 1,756
Website

Re: Poll: useful 'escape' transforms

etc wrote #308322:

That’s also the purpose of this thread, including other values too. Is excerpt="tags" less geeky than excerpt="strip" for strip_tags()?

You mean escape, right? But probably yes, escape=tags is less programmer lingo. implode … hold on I need to consult my dictionaries here ;-)

Offline

#34 2017-12-18 12:20:15

etc
Developer
Registered: 2010-11-11
Posts: 3,418
Website

Re: Poll: useful 'escape' transforms

phiw13 wrote #308323:

You mean escape, right? But probably yes, escape=tags is less programmer lingo. implode … hold on I need to consult my dictionaries here ;-)

Right. :-) So, let it be tags. And join for implode(), perhaps? Or gather, or any of these?

Offline

#35 2017-12-18 13:42:13

Bloke
Developer
From: Leeds, UK
Registered: 2006-01-29
Posts: 8,834
Website

Re: Poll: useful 'escape' transforms

etc wrote #308318:

Another possibility is to consider any undocumented escape value xyz as “unwrap <xyz /> tag”.

That has merit. I don’t think it’s confusing insofar as we’ve already introduced a “processing chain” in the escape attribute, so the stuff is processed in order of value anyway. Thus being able to strip specific tags from the content (in addition to being able to do the global ‘strip all’) – before or after some other built-in transforms – would be remarkably powerful.

Just bear in mind that I think we’ve sometimes advocated escape="raw" in place of escape="" (though I can’t find an example of course!) which would try to remove any <raw /> tags under the proposed patch.

How about: escape=...

  • tags for strip_tags().
  • integer for intval().
  • spaces for this particular implementation of implode().

?

In that last one, we’re not exactly ‘escaping’ spaces but we are gobbling them up. Dunno.


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

#36 2017-12-18 14:08:47

etc
Developer
Registered: 2010-11-11
Posts: 3,418
Website

Re: Poll: useful 'escape' transforms

Don’t think raw or <raw /> is used anywhere, so nothing bad should happen. Note that only self-closed tags are removed, <p>content</p> will be unwrapped as content. Well, it’s already committed, so the time will see. :-)

I’m fine with tags and integer, not sure for spaces. The most noticeable effect of this transform is removing the line breaks and indenting, to prevent Textile from wrapping the string in <p />. We could even drop it, in favor of unwrapping <p /> with escape="p", but this yields more processing.

Offline

#37 2017-12-18 14:27:44

Bloke
Developer
From: Leeds, UK
Registered: 2006-01-29
Posts: 8,834
Website

Re: Poll: useful 'escape' transforms

etc wrote #308326:

Don’t think raw or <raw /> is used anywhere, so nothing bad should happen.

Yeah, I don’t think it’s used in the code, but I think it’s mentioned in the tag docs somewhere. Maybe.

The most noticeable effect of this transform is removing the line breaks and indenting… We could even drop it, in favor of unwrapping <p /> with escape="p", but this yields more processing.

Hmm, yeah. The trouble is it’s doing two things. escape="newlines" seems to cover half of the functionality. Maybe that’s the best course of action? Single transforms that users can combine if they want, even though it’s extra proccessing: escape="newlines, textile, p". Then we gain the option of stripping newlines alone, if required.

Alternatively (or additionally), as this is specific to Textile, introduce a dedicated transform escape="textile_unwrap" (or textile_clean or something) that does the combined preparing, textiling and stripping in one attribute value.


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

#38 2017-12-18 14:44:59

etc
Developer
Registered: 2010-11-11
Posts: 3,418
Website

Re: Poll: useful 'escape' transforms

Bloke wrote #308327:

Yeah, I don’t think it’s used in the code, but I think it’s mentioned in the tag docs somewhere. Maybe.

If it is mentioned somewhere, we’d better remove the mention. Anyway, at worst it will only try to remove <raw /> tags, not find any and keep quiet.

we gain the option of stripping newlines alone, if required.

It’s possible with the current implode, ltrim too. FWIW, it’s called normalize-space in XPath, so finding a good name seems difficult. assemble, assemble, trim, assemble, textile..? Or tidy? We could also test if the string has been assembled and indent it only on a further textile, unless it’s trimmed in between.

Alternatively (or additionally), as this is specific to Textile, introduce a dedicated transform escape="textile_unwrap" (or textile_clean or something) that does the combined preparing, textiling and stripping in one attribute value.

Why not, but then we need one more name. :-|

Offline

#39 2017-12-18 15:29:35

Bloke
Developer
From: Leeds, UK
Registered: 2006-01-29
Posts: 8,834
Website

Re: Poll: useful 'escape' transforms

etc wrote #308328:

It’s possible with the current implode, ltrim too.

True.

FWIW, it’s called normalize-space in XPath, so finding a good name seems difficult.

Yes.

We could also test if the string has been assembled and indent it only on a further textile, unless it’s trimmed in between.

If there’s the possiblity of interplay between transforms, we could certainly use that to our advantage so any step that occurs immediately prior to another could modify its behaviour. It does come with the baggage of making it more difficult to understand and document.

And, fwiw, I’m not sure assemble is the right word either. It needs to work on its own, so what exactly does escape="assemble" mean? tidy is a good name, though. It’s generic enough that we could apply it to ‘prepare’ other transforms in future or it could just tidy spaces up if used on its own.


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

#40 2017-12-18 16:35:22

jakob
Admin
From: Germany
Registered: 2005-01-20
Posts: 3,588
Website

Re: Poll: useful 'escape' transforms

Bloke wrote #308327:

Alternatively (or additionally), as this is specific to Textile, introduce a dedicated transform escape="textile_unwrap" (or textile_clean or something) that does the combined preparing, textiling and stripping in one attribute value.

I like that.

Alternatively something like clean, tidy_text, scrub / scrub_spaces, strip_newlines, linearize, inline_text / inlinerize


TXP Builders – finely-crafted code, design and txp

Offline

Board footer

Powered by FluxBB