In this case I think you're probably better off not using wikify() at all.

The last bit of your macro handler (from the "var pbstring=..." line)
could be something like this:

var wrapperDiv = createTiddlyElement(place,"div");
wrapperDiv.style = config.macros.progressbar.containerDivStyle;
var wrapperSpan = createTiddlyElement(wrapperDiv,"span",null,null,caption);
wrapperSpan.style = config.macros.progressbar.containerSpanStyle;
var progressDiv = createTiddlyElement(wrapperSpan,"div");
progressDiv.style.width = pct + "%";

Best wishes

Jeremy


On Wed, Sep 22, 2010 at 12:52 PM, Carrasco <[email protected]> wrote:
>> That's correct. You'll have to manually migrate the content nodes from
>> inside the <span> up into the parent node. Can you show the context so that
>> I can advise more specifically?
>
> Well, here is full my code. It's not finished and a lot ugly!
>
> //code start
> //{{{
> version.extensions.ProgressBarMacro = { major: 0, minor: 1, revision:
> 0, date: new Date(2010, 09, 21),
>        source: "http://simonbaird.com/mptw/#HelloWorldMacro";
> };
>
> config.macros.progressbar = {};
>
> config.macros.progressbar.defaultContainerDivStyle =
>        "width: 200px; border: 1px solid #0044bb; margin: 2px 0.5em 2px
> 0.5em; padding: 1px; background: white; position: static; float: none;
> display: inline-block;";
>
> config.macros.progressbar.defaultContainerSpanStyle =
>        "width: 200px; text-align: center; display: inline-block;";
>
> config.macros.progressbar.defaultBarStyle =
>        "background-color: #ACE97C; height: 1.4em;float:left;";
>
> config.macros.progressbar.init = function() {
>        if (!config.macros.progressbar.containerDivStyle ||
> config.macros.progressbar.containerDivStyle == ""){
>                config.macros.progressbar.containerDivStyle =
> config.macros.progressbar.defaultContainerDivStyle;
>        }
>        if (!config.macros.progressbar.containerSpanStyle ||
> config.macros.progressbar.containerSpanStyle == ""){
>                config.macros.progressbar.containerSpanStyle =
> config.macros.progressbar.defaultContainerSpanStyle;
>        }
>        if (!config.macros.progressbar.barStyle ||
> config.macros.progressbar.barStyle == ""){
>                config.macros.progressbar.barStyle =
> config.macros.progressbar.defaultBarStyle;
>        }
>        config.macros.progressbar.defaultShowVal = true;
>        config.macros.progressbar.defaultShowPct = true;
> };
>
> config.macros.progressbar.buildCaption = function (curr, maxv, pct,
> showVal, showPct){
>        var valCaption = curr + " / " + maxv;
>        var pctCaption = pct + "%";
>        var finalCaption = "" ;
>
>        if (showVal == true && showPct == true)
>                finalCaption = valCaption + " (" + pctCaption + ")";
>
>        else if (showVal == true)
>                finalCaption = valCaption;
>
>        else if (showPct == true)
>                finalCaption = pctCaption;
>
>        return finalCaption;
> }
>
> config.macros.progressbar.handler = function (place, macroName,
> params, wikifier, paramString, tiddler) {
>        var curr = Math.abs(params[0]);
>        var maxv = Math.abs(params[1]);
>        var showVal = config.macros.progressbar.defaultShowVal;
>        if (params.length> 2) showVal = eval(params[2]);
>
>        var showPct = config.macros.progressbar.defaultShowPct;
>        if (params.length> 3) showPct = eval(params[3]);
>
>        if (curr > maxv) {
>                var temp = curr;
>                curr = maxv;
>                maxv = temp;
>        }
>
>        var pct = Math.round((curr/maxv)*100);
>        var caption = config.macros.progressbar.buildCaption(curr, maxv, pct,
> showVal, showPct);
>
>
>        var pbstring = "<html>";
>        pbstring = pbstring + "<div style = '" +
> config.macros.progressbar.containerDivStyle + "'>";
>        pbstring = pbstring + "<span style = '" +
> config.macros.progressbar.containerSpanStyle + "'>";
>        pbstring = pbstring + caption;
>        pbstring = pbstring + "<div style = '" +
> config.macros.progressbar.barStyle + "width: " + pct + "%;'>"
>        pbstring = pbstring + "</span></div></html>";
>        wikify(pbstring, place);
> };
>
> //}}}
> //code ends
>
> Usage: <<progressbar val1 val2 showvalues showpercentage>> val1 and 2
> can be any number, even negative, and the greatest will be used asthe
> maximum. The other two values have true as default.
>
>
>
> --
> You received this message because you are subscribed to the Google Groups 
> "TiddlyWiki" group.
> To post to this group, send email to [email protected].
> To unsubscribe from this group, send email to 
> [email protected].
> For more options, visit this group at 
> http://groups.google.com/group/tiddlywiki?hl=en.
>
>



-- 
Jeremy Ruston
mailto:[email protected]
http://www.tiddlywiki.com

-- 
You received this message because you are subscribed to the Google Groups 
"TiddlyWiki" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/tiddlywiki?hl=en.

Reply via email to