Go to main content

Textpattern CMS support forum

You are not logged in. Register | Login | Help

#1 2007-05-10 01:26:15

e-sven
Archived Plugin Author
From: Berlin, Germany
Registered: 2004-11-12
Posts: 17
Website

[textile] Classes and List-Items

To be able to apply CSS-classes und ids to list-items instead of the whole list i’ve patched the Textile-Class from Version 4.0.4:

notextile..
// ——————————————————————————————- function fList($m) { $text = explode(“\n”, $m0); foreach($text as $line) { $nextline = next($text); if (preg_match(“/^(1+)($this->a$this->c) (.*)$/s”, $line, $m)) { list(, $tl, $atts, $content) = $m; $nl = ‘’; if (preg_match(“/^(1+)($this->a$this->c) (.*)$/s”, $nextline, $nm)) $nl = $nm1; if (!isset($lists[$tl])) { $lists[$tl] = true; $atts = $this->pba($atts); $line = “\t<” . $this->lT($tl) . “l>\n\t\t<li$atts>” . $this->graf($content); } else { $atts = $this->pba($atts); $line = “\t\t<li$atts>” . $this->graf($content); }

if(strlen($nl) <= strlen($tl)) $line .= “</li>”; foreach(array_reverse($lists) as $k => $v) { if(strlen($k) > strlen($nl)) { $line .= “\n\t</” . $this->lT($k) . “l>”; if(strlen($k) > 1) $line .= “</li>”; unset($lists[$k]); } } } $out[] = $line; } return join(“\n”, $out); } // ——————————————————————————————-

I hope this helps anybody…

Last edited by e-sven (2007-05-10 01:29:14)


Sven
<bc />

Offline

#2 2007-05-10 05:13:27

jm
Plugin Author
From: Missoula, MT
Registered: 2005-11-27
Posts: 1,746
Website

Re: [textile] Classes and List-Items

Textiled :) :


// -------------------------------------------------------------
    function fList($m)
    {
        $text = explode("\n", $m[0]);
        foreach($text as $line) {
            $nextline = next($text);
            if (preg_match("/^([#*]+)($this->a$this->c) (.*)$/s", $line, $m)) {
                list(, $tl, $atts, $content) = $m;
                $nl = '';
                if (preg_match("/^([#*]+)($this->a$this->c) (.*)$/s", $nextline, $nm))
                	$nl = $nm[1];
                if (!isset($lists[$tl])) {
                    $lists[$tl] = true;
                    $atts = $this->pba($atts);
                    $line = "\t<" . $this->lT($tl) . "l>\n\t\t<li$atts>" . $this->graf($content);
                } else {
                		$atts = $this->pba($atts);
                    $line = "\t\t<li$atts>" . $this->graf($content);
                }

                if(strlen($nl) <= strlen($tl)) $line .= "</li>";
                foreach(array_reverse($lists) as $k => $v) {
                    if(strlen($k) > strlen($nl)) {
                        $line .= "\n\t</" . $this->lT($k) . "l>";
                        if(strlen($k) > 1)
                            $line .= "</li>";
                        unset($lists[$k]);
                    }
                }
            }
            $out[] = $line;
        }
        return join("\n", $out);
    }
// -------------------------------------------------------------

Last edited by jm (2007-05-10 05:13:54)

Offline

#3 2007-05-11 00:18:58

zem
Developer Emeritus
From: Melbourne, Australia
Registered: 2004-04-08
Posts: 2,579

Re: [textile] Classes and List-Items

This breaks backwards compatibility, so it can’t be included in stable versions.

Last edited by zem (2007-05-11 00:19:16)


Alex

Offline

#4 2007-05-11 00:25:54

e-sven
Archived Plugin Author
From: Berlin, Germany
Registered: 2004-11-12
Posts: 17
Website

Re: [textile] Classes and List-Items

Well, I know. But there has to be a way to solve this. Perhaps something like this?

*(class#id). // apply to li
*(class#id)  // apply to ul or ol

Sven
<bc />

Offline

#5 2007-05-11 02:12:38

zem
Developer Emeritus
From: Melbourne, Australia
Registered: 2004-04-08
Posts: 2,579

Re: [textile] Classes and List-Items

This would be more consistent with the table syntax:

list(listclass#listid).
*(itemclass#itemid) foo
* bar

Alex

Offline

Board footer

Powered by FluxBB