Go to main content

Textpattern CMS support forum

You are not logged in. Register | Login | Help

#121 2015-09-11 01:02:51

GugUser
Member
From: Quito (Ecuador)
Registered: 2007-12-16
Posts: 1,473

Re: smd_wrap: conditionally wrap stuff with tags and labels

Nothing?

Offline

#122 2015-09-11 06:11:44

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

Re: smd_wrap: conditionally wrap stuff with tags and labels

As far as I recall, smd_wrap uses the standard full textile method (e.g. not the textile lite used in commenting), so it all looks okay. Maybe it’s something to do with txp:title escaping the quotes in your phrase when the text is output?

Does it work if you write out the content of the title tag using smd_wrap, e.g.

<txp:smd_wrap transform="textile,replace|regex|'<\/?p>'|">
  Your "title text" written out by hand
</txp:smd_wrap>

If that works, try maybe:

<txp:smd_wrap transform="textile,replace|regex|'<\/?p>'|">
  <txp:php>global $thisarticle; echo $thisarticle['title'];</txp:php>
</txp:smd_wrap>

Another idea: try with the attribute no_widow="0"? Maybe that is converting a space that textile would normally use to detect the end of a word into a non-breaking space?

Otherwise, I can’t think of anything except to try and isolate the problem:

  • Does it happen with all title tags with this formatting combination, or just one in particular? If so, is there something particular about that one?
  • Try and see if the problem phrase works with textile on its own in another context, e.g. on txstyle.org. If not, it may be different textile formatting interacting and you made need extra […] to distinguish them. Or textile thinking it’s an incomplete link? If it works on txstyle.org but not on your site, compare the textile.php versions of your installation.
  • Check the database to see how the title tag is saved to the textpattern table. Anything strange?

TXP Builders – finely-crafted code, design and txp

Offline

#123 2015-09-11 19:51:56

GugUser
Member
From: Quito (Ecuador)
Registered: 2007-12-16
Posts: 1,473

Re: smd_wrap: conditionally wrap stuff with tags and labels

Thanks jakob for your suggestions. Unfortunately nothing helps.

jakob wrote #294719:

As far as I recall, smd_wrap uses the standard full textile method (e.g. not the textile lite used in commenting), so it all looks okay. Maybe it’s something to do with txp:title escaping the quotes in your phrase when the text is output?

I don’t think so.

Does it work if you write out the content of the title tag using smd_wrap, e.g.

<txp:smd_wrap transform="textile,replace|regex|'<\/?p>'|">…

No. Nothing is shown. It seems as if it was swallowed.

If that works, try maybe:

<txp:smd_wrap transform="textile,replace|regex|'<\/?p>'|">
    <txp:php>global $thisarticle; echo $thisarticle['title'];</txp:php>
</txp:smd_wrap>

Nothing too. Or did you mean that?

<txp:php> echo title(array()); </txp:php>@

Another idea: try with the attribute no_widow="0"? Maybe that is converting a space that textile would normally use to detect the end of a word into a non-breaking space?

Doesn’t help.

Otherwise, I can’t think of anything except to try and isolate the problem:

  • Does it happen with all title tags with this formatting combination, or just one in particular? If so, is there something particular about that one?

The strange is: I have tried a “thousand” ways and combinations and <txp:smd_wrap transform="textile,replace|regex|'<\/?p>'|"><txp:title /></txp:smd_wrap> works fine, except with single and double quotes. If I wrap <txp:title />, then the double quotes are converted in &#34;, if I wrap a custom field, then the double quotes are converted in &quot;. All other things work fine with Textile.

  • Try and see if the problem phrase works with textile on its own in another context, e.g. on txstyle.org. If not, it may be different textile formatting interacting and you made need extra […] to distinguish them. Or textile thinking it’s an incomplete link? If it works on txstyle.org but not on your site, compare the textile.php versions of your installation.

It works in txstyle.org in the same manner as in the main text field, without the need for <txp:smd_wrap transform="textile,replace|regex|'<\/?p>'|">.

  • Check the database to see how the title tag is saved to the textpattern table. Anything strange?

No, nothing strange.

But, it’s a strange thing. It seems that <txp:smd_wrap transform="textile,replace|regex|'<\/?p>'|"> doesn’t work with quotes. The escape options don’t help.

Offline

#124 2015-09-11 20:24:54

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

Re: smd_wrap: conditionally wrap stuff with tags and labels

GugUser wrote #294736:

It seems that <txp:smd_wrap transform="textile,replace|regex|'<\/?p>'|"> doesn’t work with quotes.

It does, just not with <txp:title />. That’s because the title is sanitised upon save and the quotes are stored / rendered as &#34;. Textile doesn’t convert entities, only literal characters so by the time the plugin/textile parser sees it, the damage is done.

You can get round it by running a transform before textile to swap the sanitised quotes for real quotes. Just watch that you use apostrophes around the transform attribute:

<txp:smd_wrap transform='replace|regex|/&#34;/|", textile'><txp:title no_widow="0" /></txp:smd_wrap>

However, if you do that, your second replace won’t work as the < and > are treated as tags by the Textpattern parser! So maybe you need to escape the " in the first regex somehow. A tough one.


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

#125 2015-09-11 21:14:44

GugUser
Member
From: Quito (Ecuador)
Registered: 2007-12-16
Posts: 1,473

Re: smd_wrap: conditionally wrap stuff with tags and labels

Thanks Bloke, that’s a great solution. And the two replaces don’t interfere with each other. This works fine:

<txp:smd_wrap transform='replace|regex|/&#34;/|", textile, replace|regex|"<\/?p>"|'><txp:title /></txp:smd_wrap>

I had also thought about a replace solution, but I had no idea how to separate opening and closing quotes. And it’s so easy, because is doing by Textile. I hadn’t realized this simplicity.

Thanks.

Offline

#126 2015-09-11 21:18:38

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

Re: smd_wrap: conditionally wrap stuff with tags and labels

Would nesting two smd_wraps work?

<txp:smd_wrap transform="textile,replace|regex|'<\/?p>'|">
    <txp:smd_wrap transform='replace||&#34;|"'><txp:title no_widow="0" /></txp:smd_wrap>
</txp:smd_wrap>

or wrapping the smd_wrap around rah_replace or a php function? Or does that not work due to parse ordering?

BTW: Is there a reason why the &#34; needs to be a regex replace?

EDIT: Ah well, it works normally. Good to know.


TXP Builders – finely-crafted code, design and txp

Offline

#127 2015-09-11 21:24:52

GugUser
Member
From: Quito (Ecuador)
Registered: 2007-12-16
Posts: 1,473

Re: smd_wrap: conditionally wrap stuff with tags and labels

jakob wrote #294739:

BTW: Is there a reason why the &#34; needs to be a regex replace?

I don’t know the reason, but the replace didn’t work as string without the regex.

Last edited by GugUser (2015-09-11 21:25:31)

Offline

#128 2015-10-30 00:02:48

CeBe
Plugin Author
From: Caen - Fr
Registered: 2010-06-25
Posts: 345
Website

Re: smd_wrap: conditionally wrap stuff with tags and labels

I have the same problem with a simple custom field named lien which contains "$":link.php:

<txp:smd_wrap transform="textile"><txp:custom_field name="lien" /></txp:smd_wrap>

outputs

&quot;$&quot;:link.php

The solution above didn’t work for me.
Any clue?

Offline

#129 2015-10-30 00:18:16

GugUser
Member
From: Quito (Ecuador)
Registered: 2007-12-16
Posts: 1,473

Re: smd_wrap: conditionally wrap stuff with tags and labels

In the case that the custom field is only for links (I conclude lien = link), so you can change your code (in the case that they are internal links):

<txp:if_custom_field name="lien"><a href="/<txp:custom_field name="lien" />"><txp:custom_field name="lien" /></a></txp:if_custom_field>

Offline

#130 2015-10-30 00:40:36

CeBe
Plugin Author
From: Caen - Fr
Registered: 2010-06-25
Posts: 345
Website

Re: smd_wrap: conditionally wrap stuff with tags and labels

My example was too simple :) I really need to have the link properly generated because I also have things like "Click here":link.php.

Offline

#131 2015-10-30 01:20:45

GugUser
Member
From: Quito (Ecuador)
Registered: 2007-12-16
Posts: 1,473

Re: smd_wrap: conditionally wrap stuff with tags and labels

In a experiment on one of my real site that worked with your examples:

<txp:smd_wrap transform='replace|regex|/&quot;/|", textile, replace|regex|"<\/?p>"|'><txp:custom_field name="lien" /></txp:smd_wrap>

Last edited by GugUser (2015-10-30 01:21:11)

Offline

#132 2015-10-30 07:29:44

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

Re: smd_wrap: conditionally wrap stuff with tags and labels

CeBe wrote #296315:

I have the same problem with a simple custom field named lien which contains "$":link.php:

<txp:smd_wrap transform="textile"><txp:custom_field name="lien" /></txp:smd_wrap>...

outputs

&quot;$&quot;:link.php...

Have you tried not to escape the value?

<txp:smd_wrap transform="textile"><txp:custom_field name="lien" escape="0" /></txp:smd_wrap>

Offline

Board footer

Powered by FluxBB