Go to main content

Textpattern CMS support forum

You are not logged in. Register | Login | Help

#1 2021-08-24 05:09:21

Kjeld
Member
From: Tokyo, Japan
Registered: 2005-02-05
Posts: 379
Website

Can I use textile new lines in shortcodes?

I have created a shortcode for quotes that automatically adds a class around the quote. In the article I use:

<txp::quote quote=“Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat.”/>

This is the output form for quote:

<blockquote>
<div class=“some_class”><txp:yield name=“quote” escape=“tidy, textile” /></div>
</blockquote>

In reality, the output form is more complex, but I have simplified it for use here.

What I would like to do is add a new line to the quote. I can do that by adding <p>, like this:

<txp::quote quote=“Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.</p><p>Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat.”/>

Or <br />, like this:

<txp::quote quote=“Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.<br /><br />Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat.”/>

But I would really like to be able to make use of textile, like this:

<txp::quote quote=“Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.

Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat.”/>

However, when I do this, I get this output on the front page:

<txp::quote quote=“Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.

Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat.”/>

I have tried different escapes but can’t figure it out. Is this actually possible? If so, how?


JapaneseStreets.com – Japanese street fashion (mostly txp)
Old Photos of Japan – Japan between 1860 and 1940 (100% txp)
MeijiShowa – Stock photos of Japan between 1860 and 1940 (100% txp)

Offline

#2 2021-08-24 06:25:53

Vienuolis
Member
From: Vilnius, Lithuania
Registered: 2009-06-14
Posts: 271
Website GitHub GitLab Twitter

Re: Can I use textile new lines in shortcodes?

Would not be more possibilities using container form mode instead of inline self-closed forms? Like

<txp::quote> complex quote </txp::quote>

Online

#3 2021-08-24 08:29:58

Bloke
Developer
From: Leeds, UK
Registered: 2006-01-29
Posts: 10,520
Website GitHub

Re: Can I use textile new lines in shortcodes?

Yes, exactly what Vienuolis says. Use a container and drop the name="quote" in your yield. That should work a treat.


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

#4 2021-08-24 09:59:34

Kjeld
Member
From: Tokyo, Japan
Registered: 2005-02-05
Posts: 379
Website

Re: Can I use textile new lines in shortcodes?

Vienuolis wrote #331445:

Would not be more possibilities using container form mode instead of inline self-closed forms? Like

<txp::quote> complex quote </txp::quote>...

Thanks Vienuolis and Bloke.

Actually, the real output form is a bit more complex. This is what the output looks like.

<figure class="attention my-5">
<blockquote class="blockquote" cite="URL">
<div class="blockquote-text"><p>Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.</p><p>Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat.</p></div>
</blockquote>
<figcaption class="blockquote-footer">
<span>NAME</span>, JOB
</figcaption>
</figure>

And this is the shortcode:

<txp::quote quote="" name="" job="" cite_url=""/>

I want to make it as straightforward as possible for users, who most likely will be unfamiliar with html.


JapaneseStreets.com – Japanese street fashion (mostly txp)
Old Photos of Japan – Japan between 1860 and 1940 (100% txp)
MeijiShowa – Stock photos of Japan between 1860 and 1940 (100% txp)

Offline

#5 2021-08-24 10:21:29

etc
Developer
Registered: 2010-11-11
Posts: 4,515
Website GitHub

Re: Can I use textile new lines in shortcodes?

Having newlines in attributes (and their further textiling) is not a problem per se. But:

  • if the shortcode is used in an article body/excerpt, make sure it is left untouched (i.e. not textiled). Otherwise the tag will be output literally, as in your OP. This is a textile parser problem, we don’t really get our hands on it.
  • Don’t use tidy in escape, its role is the opposite of what you need.

Offline

#6 2021-08-24 10:24:45

Kjeld
Member
From: Tokyo, Japan
Registered: 2005-02-05
Posts: 379
Website

Re: Can I use textile new lines in shortcodes?

etc wrote #331448:

Having newlines in attributes (and their further textiling) is not a problem per se. But:

  • if the shortcode is used in an article body/excerpt, make sure it is left untouched (i.e. not textiled). Otherwise the tag will be output literally, as in your OP. This is a textile parser problem, we don’t really get our hands on it.
  • Don’t use tidy in escape, its role is the opposite of what you need.

Thank you. What escape would you suggest?


JapaneseStreets.com – Japanese street fashion (mostly txp)
Old Photos of Japan – Japan between 1860 and 1940 (100% txp)
MeijiShowa – Stock photos of Japan between 1860 and 1940 (100% txp)

Offline

#7 2021-08-24 10:28:40

etc
Developer
Registered: 2010-11-11
Posts: 4,515
Website GitHub

Re: Can I use textile new lines in shortcodes?

Kjeld wrote #331449:

Thank you. What escape would you suggest?

Just escape="textile"?

Offline

#8 2021-08-24 10:34:04

Kjeld
Member
From: Tokyo, Japan
Registered: 2005-02-05
Posts: 379
Website

Re: Can I use textile new lines in shortcodes?

etc wrote #331450:

Just escape="textile"?

Thanks.

This seems to work.

<txp::quote_copy name="NAME" job="JOB" cite_url="URL"> complex quote </txp::quote_copy>

THANKS to all!


JapaneseStreets.com – Japanese street fashion (mostly txp)
Old Photos of Japan – Japan between 1860 and 1940 (100% txp)
MeijiShowa – Stock photos of Japan between 1860 and 1940 (100% txp)

Offline

#9 2021-08-24 11:06:56

Pat64
Plugin Author
From: France
Registered: 2005-12-12
Posts: 1,483
Website GitHub Twitter

Re: Can I use textile new lines in shortcodes?

Here is a shortcode I’m using for users:

<figure class="blockquote">
	<blockquote <txp:if_yield name="source">cite="<txp:yield name="source" />" </txp:if_yield>class="<txp:yield name="style" />">
		<p><txp:yield name="texte" escape="tidy,textile,trim" /></p>
		<txp:if_yield name="author"><figcaption><cite>— <txp:yield name="author" escape="tidy,textile" /></cite></figcaption></txp:if_yield>
	</blockquote>
</figure>

Details:

The first escape="tidy,textile,trim" to remove <p> tags and allow Textile markup;
The second escape="tidy,textile" to allow Textile markup;
The extra class CSS attribute to allow different visual styling for blockquotes.

Here is a sample result (from 3 different visual choices) in Dark Mode:

Last edited by Pat64 (2021-08-24 11:12:24)


Patrick.

Github | CodePen | Codier | Simplr theme | Wait Me: a maintenance theme | [\a mi.ni.ma]: a “Low Tech” simple Blog theme.

Offline

#10 2021-08-24 11:17:31

Kjeld
Member
From: Tokyo, Japan
Registered: 2005-02-05
Posts: 379
Website

Re: Can I use textile new lines in shortcodes?

Pat64 wrote #331452:

Here is a shortcode I’m using for users:

<figure class="blockquote">...

Details:

The first escape="tidy,textile,trim" to remove <p> tags and allow Textile markup;
The second escape="tidy,textile" to allow Textile markup;
The extra class CSS attribute to allow different visual styling for blockquotes.

Thanks, Pat. Beautiful lay-out!

This is my current code:

<figure class="attention my-5">
<blockquote class="blockquote"<txp:if_yield name="cite_url">cite="<txp:yield name="cite_url" />"</txp:if_yield>>
<div<txp:if_yield name="job"> class="blockquote-text"</txp:if_yield>><p><txp:yield escape="textile" /></p></div>
</blockquote>
<figcaption class="blockquote-footer">
<span><txp:yield name="name" /></span><txp:if_yield name="job">, <txp:yield name="job" /></txp:if_yield>
</figcaption>
</figure>

And the shortcode:

<txp::quote name="" job="" cite_url=""> quote </txp::quote>

If there is no job, there is different styling (as class=“blockquote-text” is removed).

Last edited by Kjeld (2021-08-24 11:18:19)


JapaneseStreets.com – Japanese street fashion (mostly txp)
Old Photos of Japan – Japan between 1860 and 1940 (100% txp)
MeijiShowa – Stock photos of Japan between 1860 and 1940 (100% txp)

Offline

Board footer

Powered by FluxBB