[pmwiki-users] Different Markup definitions for a section?
Américo Albuquerque
aalbuquerque at lanowar.sytes.net
Sun Apr 23 17:59:41 CDT 2006
Hello
Stirling Westrup wrote:
> Its looking like I have a need for a different set of markup notations
> in a given section. That is, I want to disable certain markups (but not
> necessarily all of them), and introduce a few extra ones for all text
> that's between special section markers.
to disable markups use "DisableMarkup('<markup name>')", to make new
ones use "Markup()". Check
http://www.pmwiki.org/wiki/PmWiki/CustomMarkup for more info
>
> For example, something like this:
>
> (:compactlist listname:)
> | alpha, beta, gamma; a, b, c; aleph, beth | one, two, three; uno, duos,
> tres
> (:endcompactlist:)
>
> Which would need to generate something like this:
> <ol id="listname">
> <li><ul>
> <li><ul><li>alpha</li><li>beta</li><li>gamma</li></ul></li>
> <li><ul><li>a</li><li>b</li><li>c</li></ul></li>
> <li><ul><li>aleph</li><li>beth</li></ul></li>
> </ul></li>
> <li><ul>
> <li><ul><li>one</li><li>two</li><li>three</li></ul></li>
> <li><ul><li>uno</li><li>duos</li><li>tres</li></ul></li>
> </ul></li>
> </ol>
>
This can be done by making a new markup just for this or by using the
Wiki default markups
> BTW, I have no idea how one would generate the above using standard
> markup (how do you create a list that's entries are lists of lists?),
> but that's beside the point.
>
The default way would be:
#
**
*** alpha
*** beta
*** gama
**
*** a
*** b
*** c
**
*** aleph
*** beth
#
**
*** one
*** two
*** three
**
*** uno
*** duos
*** tres
The '#' is the <ol> and the '*' is the <ul>. I don't know how to give
the attribute 'id=listname' to the first <ol> using this method though
The other method is using the code below on your local config or to
create a recipe with it and include it on you local config
The $CompactListLayers has the separators used to identify each block
and the html tag that will be used in each block. You can add another
layer by simply adding a new array of the form array("html tag name",
"separator"). The html tagname is just the name, no <> is to be used,
the functions will insert them as needed
----CODE----
SDV($CompactListLayers, array(array("ol", "|"), array("ul", ";"),
array("ul", ",")));
Markup("compactlist", "fulltext", "/\(:compactlist
(\w+):\)(.*?)\(:endcompactlist:\)/se", "addCompact('$1', '$2')");
function addCompact($name, $text) {
return CompactLists(0, $text, $name);
}
function CompactLists($level, $text, $name="") {
global $CompactListLayers;
$nametag = !empty($name)? " id='$name'" : "";
if(($level>=0) and ($level<count($CompactListLayers))) {
$lists = explode($CompactListLayers[$level][1], $text);
if(count($lists)==1) {
return $text;
} else {
$value = "<{$CompactListLayers[$level][0]}$nametag>";
foreach($lists as $list) {
$value .= "<li>" . CompactLists($level+1, $list) . "</li>";
}
$value .= "</{$CompactListLayers[$level][0]}>";
return $value;
}
} else {
return $text;
}
}
----CODE----
More information about the pmwiki-users
mailing list