Textpattern CMS support forum
You are not logged in. Register | Login | Help
- Topics: Active | Unanswered
Cannot get escaping "tidy, textile" working
<txp:body escape="tidy, textile"/>
Should give me the content of the body field without the surrounding <p>, correct?
In my case it seems not to work at all and I still get surrounding <p> and I am wondering why.
This works fine though:
<txp:body escape="tidy, p"/>
Offline
Re: Cannot get escaping "tidy, textile" working
demoncleaner wrote #331650:
<txp:body escape="tidy, textile"/>...Should give me the content of the body field without the surrounding <p>, correct?
No, it should textile the output of <txp:body /> (without wrapping it with <p>) after some whitespace normalization (tidy). But <txp:body /> output is already textiled, so escape has no effect here.
Offline
Re: Cannot get escaping "tidy, textile" working
OK. Thanks, I almost understand.
But shouldn´t
<txp:variable name="test" value='<txp:body/>' escape="tidy, textile" output/>
work than?
But that gives me still surounding <p>.
What am I missing?
Or let me ask in a different way:
What would I have to do when I want the contents of the body field output without any surounding <p>.
(Changing the format in the backend cannot be an option unfortunately.)
Last edited by demoncleaner (2021-09-23 13:01:44)
Offline
Re: Cannot get escaping "tidy, textile" working
The Body field (and Excerpt) already has Textile applied, and already has the surrounding ‘p’ tags.
Telling escape to tidy it (remove newlines and add a preceding space) and then pass it through Textile is a waste of time, since it’s already been passed through Textile. The <txp:body> tag actually outputs the Body_html field (at least, if it doesn’t, it should!). It applies Textile on save, not on output, for performance reasons. Additionally, you might get odd results if it encounters something in the HTML that it doesn’t quite understand.
In your <txp:variable> example, the same applies. You’re populating the variable with HTML from the article body, and then asking the variable to pass its content through Textile. That’ll have no effect.
The smd plugin menagerie — for when you need one more gribble of power from Textpattern. Bleeding-edge code available on GitHub.
Hire Txp Builders – finely-crafted code, design and Txp
Offline
Re: Cannot get escaping "tidy, textile" working
demoncleaner wrote #331655:
What would I have to do when I want the contents of the body field output without any surounding <p>.
<txp:custom_field name="body" escape="tidy, textile" />
:)
(though that’ll have a performance impact on your pages as it re-Textile’s the entire article on the fly)
Last edited by Bloke (2021-09-23 14:13:38)
The smd plugin menagerie — for when you need one more gribble of power from Textpattern. Bleeding-edge code available on GitHub.
Hire Txp Builders – finely-crafted code, design and Txp
Offline
Re: Cannot get escaping "tidy, textile" working
OK. I see =). Thank you.
Maybe then that´s a bit misleading here for somebody that has no clue how exactly it works in the background.
https://docs.textpattern.com/tags/learning/#available-escape-values
Remove spaces/newlines, prepend a single space to remove the surrounding <p> tag, then Textile the content.
I thought I can use it in a situation where I just use the body field for just one sentence or so and do not want it to be wrapped in <p>. Get rid of it and textile it again.
Of course changing the format in the backend is an option as well. But I normally try to avoid it because this can easily be overseen by somebody who is not so much into textpattern.
At least I know now why it is not working. Think I change my idea of how to use the body field in those cases and better make use of a custom_field. Thanks again!
Last edited by demoncleaner (2021-09-23 15:10:53)
Offline
Re: Cannot get escaping "tidy, textile" working
demoncleaner wrote #331658:
Maybe then that´s a bit misleading here for somebody that has no clue how exactly it works in the background.
The docs are a bit long, but they do state that
global attributes cannot intervene in a tag’s internal processing and are applied only to the tag’s output.
So, when the global escape="textile" is applied to <txp:body />, it is too late, it will just be textiled a second time.
Offline
Re: Cannot get escaping "tidy, textile" working
OK. Got it. So as far as I can see then in my scenario escape="tidy, p" or better just using a custom_field instead of body would be the weapon of choice. Thanks guys.
Offline
Re: Cannot get escaping "tidy, textile" working
actually are there not plenty of situations where a designer would want content output to be free of any <p> tags. The person inputing text may not toggle the text in the Body and Excerpt fields to NOT use Textile so the code could force the striping of the <P> tags: So would this be correct?
<txp:body escape="tidy, p"/>
<txp:excerpt escape="tidy, p"/>
…. texted postive
Offline
Re: Cannot get escaping "tidy, textile" working
bici wrote #342005:
actually are there not plenty of situations where a designer would want content output to be free of any
<p>tags. The person inputing text may not toggle the text in the Body and Excerpt fields to NOT use Textile so the code could force the striping of the<P>tags: So would this be correct?
<txp:body escape="tidy, p"/>...
I’m not sure if I fully understand your situation. Are you just trying to strip the surrounding p tag or all tags created as a result of textiling. If the latter, you can do:
<txp:excerpt escape="tags" />
You’ll still get the benefits of character conversions from textiling but any formatting added that produces html tags will be stripped.
If it’s just the surrounding beginning and ending p tag you want to remove, I thought the tidy option did that, though in the other thread I found it was necessary to use p as well.
TXP Builders – finely-crafted code, design and txp
Offline
Re: Cannot get escaping "tidy, textile" working
I can foresee being able to do both. Yesterday I have used the <txp:body escape="tidy, p"/> option on a new site where I am outputting short blocks of text, as quotes to a footer area. Those Body and Excerpts texts are to be textile free, so that the user cannot cause a css fail on output. Your excape tags example is new to me. and I can also see where that might be useful where I wish to have long strings of texts used in “quotes” to be textile free no matter what the user does. Thank-you
…. texted postive
Offline
Re: Cannot get escaping "tidy, textile" working
The wrapping behavior appears to have been changed upgrading 4.8.8 to 4.9.0. However, if you only want to avoid excess ‹p› when transferring from small input fields while retaining the Textile transformation, simply insert a space at the beginning of the field. Start an entry with a space! E. g.
<figcaption><p>Some description</p></figcaption>
would be wrapped in ‹p› by Textile from Images: Edit: Caption, and
<figcaption> Some description </figcaption>
will not.
Last edited by Vienuolis (2025-12-28 18:01:57)
Offline
#13 Today 16:43:00
Re: Cannot get escaping "tidy, textile" working
I think this the right thread to enquire about this:
Is it kosher to use a mixture of html code and text in the Body and Excerpt fields?
for example I want to use 2-3 paragraphs of text that have a different css classes applied to each paragraph? I might also need to apply code to the Excerpt field.. although less likely.
what issues should one be aware of?
(In another CMS where we can have many custom fields this issue is moot).
…. texted postive
Offline
#14 Today 16:58:57
Re: Cannot get escaping "tidy, textile" working
You can mix and match whatever you like, with the caveat that sometimes textile might get in the way depending on how complex your html and attributes are. You can mitigate that on a case-by-case basis by indenting your html and ensuring you leave a blank line above and below it.
The other option is to switch it around. Set the processing to Leave Text Alone and then wrap any code you do want to be textiled in <txp:evaluate escape="textile">.
That said, you might be better off creating a shortcode, e.g.
<txp::aside>
Your content here.
...
Paragraphs, _textiled content_ and whatever...
...
...
</txp::aside>
And then your asideform can contain the markup and textile processing code:
<txp:evaluate escape="textile">
<div class="wrapper">
<txp:yield />
</div>
</txp:evaluate>
That way, if you ever want to alter the markup, you only need to do it once in the aside form.
The smd plugin menagerie — for when you need one more gribble of power from Textpattern. Bleeding-edge code available on GitHub.
Hire Txp Builders – finely-crafted code, design and Txp
Offline