|
Main sidebar
|
PITS /
00887Summary: Ability to nest WikiStyle blocks.
Created: 2007-02-14 13:40
Status: Awaiting feedback
Category: CoreCandidate
From: Feral
Assigned:
Priority: 3
Version: 2.2.0-beta31
OS: WinXP-sp2/Microsoft-IIS-5.1/PHPv5.0.4
Description: Note: (2007-04-11) Votes for various options related to this proposal are now being taken at VoteOnNestedDivMarkup -- please cast a vote there! This is meant to illustrate how to allow nesting of WikiStyle blocks, something I have often needed/wanted and feel should be a part of the core as it's use is not specific to any task, but in my opinion useful in many. Our 'Proof'
Proposed markup:
Implementation:This is based on the existing >><< WikiStyle Block markup found at roughly line 390 of stdmarkup.php.
(:source lang=php:)
// [Feral:043/07@14:54] Adapted from stdmarkup.php, line 390 or so.
Markup('^>>>', '<^<<',
'/^(\\d*?)>>(.+?)<<(.*)$/',
'(:div$1:)%div $2 apply=div%$3 ');
Markup('^>>><<<', '<^>>>',
'/^(\\d*?)>><</',
'(:div$1end:)');
(:sourcend:)
My personal wish is for this (or similar) to be included in the core. Cute WikiStylesPlus trick:NOTE: This needs WikiStylesPlus activated to work.
Proposal #2Proposed markup:
Implementation:
(:source lang=php:)
$DepthCounter = 10;
function FeralDivCounter($attr, $extra)
{
global $DepthCounter;
$DepthCounter++;
$out = "(:div{$DepthCounter}:)%div {$attr} apply=div%{$extra} \n";
return $out;
}
function FeralDivCounterEnd()
{
global $DepthCounter;
$out = "(:div{$DepthCounter}end:)";
$DepthCounter--;
return $out;
}
Markup('^>>>>', '<^<<',
'/^>>>(.+?)<<<(.*)$/e',
"FeralDivCounter(PSS('$1'),PSS('$2'))");
Markup('^>>>><<<<', '<^>>>>',
'/^>>><<<$/e',
"FeralDivCounterEnd()");
(:sourceend:)
CommentsNote Although this works (well it seems), I am not sure if this is the best way to go about this idea. Regardless, this method uses the three less/greater than signs to denote a smart style block; In essence the wiki will take care of figuring out what number should be assigned to the div. This makes the >>><<< very easy to use as you do not have to worry what number to assign the div, and as an added bonus collisions when including a desperate page should not exist, albeit I have not tried that as of this writing. It is also nice how >>><<< relates to the existing >><< style block; I presume this will be a easy conceptual leap for users. However, I am unsure if the initial presented style 1>><< still has value. Do we need specific layer control with the newer automatic numbering scheme? Also please note that $DepthCounter is initially set to 10; This should allow for space for existing numbered divs, I presume. The entire premise of this method is to increment a counter each time we are triggered by the >>><<< markup, and decrement same counter when we are triggered by the end style; This counter is used for the div layer number and is passed to the (:div:) directive. Proposal #2 addendum.Idea:Something like our For markup perhaps In essence:>>>frame<<< In frame >>>quote<<< In quote >>>>quotefrom<<<< in quote from; >>><<< Back to frame. >>><<< ExampleThis is perfect for and inspired by Cookbook:ToDo-Comments
Implementation:Placed directly under the implementation of proposal #2 in my setup.
(:source lang=php:)
function FeralDiv($attr, $extra)
{
global $DepthCounter;
$out = "(:div{$DepthCounter}:)%div {$attr} apply=div%{$extra} \n";
return $out;
}
Markup('^>>>>', '<^>>>',
'/^>>>>(.+?)<<<<(.*)$/e',
"FeralDiv(PSS('$1'),PSS('$2'))");
(:sourceend:)
CommentsThis is the same idea as the I am not keen on the implemented markup up but *shrug* It works. 00887 Comments...Very interesting approach. I had been thinking of using multiple '>>>'s to differentiate nested divs, as in >>color=black bgcolor=red<< Some text, black on red. >>>color=silver bgcolor=blue<<< A nested div that is silver on blue. >>><<< Back to our black on red style. >><< Perhaps the use of explicit digits is easier to distinguish than trying to count angle brackets.
It also resolves the issue of trying to figure out the relationship between the angle brackets and the corresponding I'll definitely think about this one -- I'd really like to hear any other opinions on this one. Pm Pm - I prefer your
>>1<<, >>2<< suggestion to 1>><<, 2>><<. That said, it does make the connection clearer and it is slightly easier to read, though I don't think >>><<< >>>><<<< is all that hard to read. - JonHaupt
|