Go to main content

Textpattern CMS support forum

You are not logged in. Register | Login | Help

#1 2012-01-29 17:24:43

alanfluff
Member
From: Ottawa, Canada
Registered: 2008-09-15
Posts: 222
Website

[textile] Is it possible to set the class of the first LI via textile?

Hi TXPers,

I’m familiar with the following textile:

*(myList) hello
*(classFor2ndLi) world

Producing this:

<ul class="myList">
    <li>hello</>
    <li class="classFor2ndLi">world</>
</ul>

But I don’t seem to be able to find a way to add a class for the first li in a list.

I’ve seen mention of putting a class in front like this (listClass)*(LiClass) hello but it does not seem to work, at least with the Textile built into TXP 4.4.1.

Does anyone know if there is a way to add a class to the first li in a list via Textile?

Thanks in advance for any comments, cheers, -Alan


At LAST I’ve cheerfully donated to the core devs at #TXP. I only wish I were able to give more. Thanks to the devs and ALL fellow TXPers. -A

Offline

#2 2012-01-29 18:01:35

uli
Moderator
From: Cologne
Registered: 2006-08-15
Posts: 4,306

Re: [textile] Is it possible to set the class of the first LI via textile?

alanfluff wrote:

I’ve seen mention of putting a class in front like this (listClass)*(LiClass) hello but it does not seem to work, at least with the Textile built into TXP 4.4.1.

Tested that for you with Textile 2.3: No joy :p


In bad weather I never leave home without wet_plugout, smd_where_used and adi_form_links

Offline

#3 2012-01-29 19:11:05

joebaich
Member
From: DC Metro Area and elsewhere
Registered: 2006-09-24
Posts: 507
Website

Re: [textile] Is it possible to set the class of the first LI via textile?

I needed something similar recently and resorted to this to get a unique style in the first list item:

*(something) %(something_else)First%
* Second

Last edited by joebaich (2012-01-29 19:17:33)

Offline

#4 2012-01-29 19:24:05

maniqui
Member
From: Buenos Aires, Argentina
Registered: 2004-10-10
Posts: 3,070
Website

Re: [textile] Is it possible to set the class of the first LI via textile?

It’s possible in latest versions of Textile (since 2.2):

#(class#id).
#(first) Item 1
#(second) Item 2
#(third) Item 3

Check it here: textile.sitemonks.com/?eg=RefGuide


La música ideas portará y siempre continuará

TXP Builders – finely-crafted code, design and txp

Offline

#5 2012-01-29 19:27:45

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

Re: [textile] Is it possible to set the class of the first LI via textile?

Yes. New syntax introduced in Textile 2.2 allows the first item to just specify the container if you add a dot:

*(myList).
*(first-item) hello
*(classFor2ndLi) world

Produces this:

<ul class="myList">
   <li class="first-item">hello</li>
   <li class="classFor2ndLi">world</li>
 </ul>

Try it

EDIT: too slow for maniqui ninja-fingers :-)

Last edited by Bloke (2012-01-29 21:02:06)


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

#6 2012-01-29 19:39:33

joebaich
Member
From: DC Metro Area and elsewhere
Registered: 2006-09-24
Posts: 507
Website

Re: [textile] Is it possible to set the class of the first LI via textile?

Missed that until now, thanks Maniqui and Bloke. Live and learn.

Offline

#7 2012-01-29 22:47:43

alanfluff
Member
From: Ottawa, Canada
Registered: 2008-09-15
Posts: 222
Website

Re: [textile] Is it possible to set the class of the first LI via textile?

Wow!

Thanks you all for the comments, I’ve certainly learnt something and I’m just glad I asked.

Just tested it — totally brilliant! And glad to have found this extra Textile resource too, in all my Googling I’ve not found http://textile.sitemonks.com/ before. Bookmarked!

Cheers one and all! -Alan


At LAST I’ve cheerfully donated to the core devs at #TXP. I only wish I were able to give more. Thanks to the devs and ALL fellow TXPers. -A

Offline

#8 2012-01-29 22:54:43

alanfluff
Member
From: Ottawa, Canada
Registered: 2008-09-15
Posts: 222
Website

Re: [textile] Is it possible to set the class of the first LI via textile?

PS: and if you don’t need a class or ID for the UL (only want them from the LIs) then as per the 2.2 spec this works AOK:

*.
*(item1) hello
*(item2) world

Excellent :)


At LAST I’ve cheerfully donated to the core devs at #TXP. I only wish I were able to give more. Thanks to the devs and ALL fellow TXPers. -A

Offline

#9 2012-01-29 23:51:47

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

Re: [textile] Is it possible to set the class of the first LI via textile?

Glad it’s useful. As a further clarification, this syntax applies to all lists in Textile: bulleted (*), numbered (#) and definition (;), though with the latter you can go a bit further because of the dt/dd:

; War
:(one) Defcon 1
:(two) Defcon 2

Renders:

<dl>
   <dt>War</dt>
   <dd class="one">Defcon 1</dd>
   <dd class="two">Defcon 2</dd>
</dl>

This one:

;.
:(one) Termless
:(two) Definitions
;;(subset) But termed and classed
::(subdef) Sub-definitions

Renders:

<dl>
   <dd class="one">Termless</dd>
   <dd class="two">Definitions
      <dl class="subset">
         <dt>But termed and classed</dt>
         <dd class="subdef">Sub-definitions</dd>
       </dl>
   </dd>
</dl>

While:

;(list).
;(term) My definition
:(one) of a boombastic jazz style
:(two) is here

Renders:

<dl class="list">
   <dt class="term">My definition</dt>
   <dd class="one">of a boombastic jazz style</dd>
   <dd class="two">is here</dd>
</dl>

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

#10 2012-01-30 01:52:44

alanfluff
Member
From: Ottawa, Canada
Registered: 2008-09-15
Posts: 222
Website

Re: [textile] Is it possible to set the class of the first LI via textile?

Thanks for the further explanation Stef, brilliant.

Do you happen to know if there is a definitive place on the web where Textile lives, in the same way as there is this for Markdown?

I’m guessing the answer is no (sad) but I thought I’d ask just in case I was missing something.

Cheers, -Alan


At LAST I’ve cheerfully donated to the core devs at #TXP. I only wish I were able to give more. Thanks to the devs and ALL fellow TXPers. -A

Offline

#11 2012-01-30 09:11:47

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

Re: [textile] Is it possible to set the class of the first LI via textile?

alanfluff wrote:

a definitive place on the web where Textile lives

Not yet. It’s been discussed and I guess it just comes down to finding someone with a bit of time to register a suitable domain, set up a (Txp) site to showcase and test the markup (like the sitemonks site does today) and make sure the site has some way to launch or host the various ports of Textile in various other programming languages.

This is one of those things that’s not rocket science, just time science :-) Maybe someone’ll offer to do it one day.


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

#12 2012-01-30 14:44:04

alanfluff
Member
From: Ottawa, Canada
Registered: 2008-09-15
Posts: 222
Website

Re: [textile] Is it possible to set the class of the first LI via textile?

I’d be interested in helping but I know I couldn’t do it now.

If you happen to bump into this thread again before I reply again feel free to kick me in the-thread to see if my circumstances have changed and I’m able to help.

Cheers, -Alan


At LAST I’ve cheerfully donated to the core devs at #TXP. I only wish I were able to give more. Thanks to the devs and ALL fellow TXPers. -A

Offline

Board footer

Powered by FluxBB