twgrp

"\n----\n" means that each entry is seperated by ---- on a new line

entry1
----
entry 2
----
entry three

If the correct option is set

entry tiddler title 1
entry1
----
entry tiddler title 3
entry 2
----
entry tiddler title 3
entry three

will create three tiddlers with the specified titles and associated content.

I have also altered the script to include $1 $2 and $3 and calling it with
"when" to pre-populate some values. A Copy below to read (dont use) -
customise your own.

I noticed I needed to edit the first field after invocation to make sure it
worked.

/%
|Name|SplitTiddler|
|Source|Original http://www.TiddlyTools.com/#SplitTiddler|
|Version|1.5.0|
|Author|Eric Shulman - ELS Design Studios - Customized version Tony Muscio|
|License|http://www.TiddlyTools.com/#LegalStatements <br>and [[Creative
Commons Attribution-ShareAlike 2.5 License|
http://creativecommons.org/licenses/by-sa/2.5/]]|
|~CoreVersion|2.1|
|Type|script|
|Requires||
|Overrides||
|Description|use text pattern to split tiddler contents into separate
tiddlers|

%/{{small smallform{<html><hide linebreaks><form>
    <table class='borderless' style='border:0;margin:0;'><tr
style='border:0'>
    <td style='width:33%;border:0;'>
        source tiddler:<br>
        <input name='src' value='$1' onfocus='this.select()'
style='width:98%'
            title='title of tiddler containing source material'>
    </td><td style='width:33%;border:0;'>
        item separator:<br>
        <input name='sep' value='\n----\n' onfocus='this.select()'
style='width:98%'
            title='character sequence used to separate source items'>
    </td><td style='width:33%;border:0;'>
        add tags:<br>
        <input name='tags' value='[[$3]] $2 [[.reference]]
[[NewProjectsteps]]' style='width:98%'
            title='space-separated tags for target tiddlers'>
    </td></tr><tr style='border:0'>
    <td colspan='3'  style='border:0'>
        <table style='width:100%;border:0;margin:0;'><tr style='border:0'>
        <td style='border:0'>
        target title format:<br>
        <input type='text' name='titleformat'  value='$3 %1 step %3'
style='width:99%';
            title='format for new tiddler titles'>
        </td><td style='border:0;'>
        output format:<br>
        <input name='format' value='!!!New Project Step %3\n%4'
style='width:99%'
            title='format for target tiddler content'>
        </td></tr></table>
        <div
style='text-align:center;font-size:80%;font-style:italic;padding-bottom:.3em'>
        %0=source title, %1=first line of item, %2=first word of item,
%3=item number, %4=item content
        </div>
    </td>
    </tr><tr style='border:0'>
    <td colspan='2' style='text-align:left;border:0;'>
        <input type='checkbox' name='warn' checked>confirm overwrites
        <input type='checkbox' name='show'>show tiddlers when done
    </td><td style='text-align:right;border:0;'>
        <input type='button' value='split tiddler' style='width:100%;'
onclick="
            var f=this.form;
            if (f.src.value==f.src.defaultValue)
                { displayMessage('Please enter a tiddler title');
f.src.focus(); return false; }
            var start=new Date().getTime();
            var src=store.getTiddlerText(f.src.value);
            if (!src) { displayMessage('\u0027'+f.src.value+'\u0027 not
found'); return false; }
            var tags=f.tags.value;
            var parts=src.split(f.sep.value.unescapeLineBreaks());
            var msg='Found '+parts.length+' items in
\u0027'+f.src.value+'\u0027.  Press OK to proceed';
            if (!confirm(msg)) return false;
            if (parts.length) store.suspendNotifications();
            var tids=[];
            var warn=f.warn.checked;
            var fmt=f.format.value.unescapeLineBreaks();
            var pad=parts.length.toString().length;
            var srctitle=f.src.value;
            for (var p=0; p<parts.length; p++) {
                var txt=parts[p];
                var lines=txt.split('\n');
                var firstline=lines[0];
                var firstword=firstline.split(' ')[0];
                var itemnum=String.zeroPad(p+1,pad);
                if (f.titleformat.value.indexOf('%2')!=-1) /* if firstword
is in title */
                    lines[0]=lines[0].split(' ').shift().join(' ');
                if (f.titleformat.value.indexOf('%1')!=-1) /* if firstline
is in title */
                    lines.shift();
                var content=lines.join('\n');
                var
tid=f.titleformat.value.format([srctitle,firstline,firstword,itemnum,content]);
                txt=fmt.format([srctitle,firstline,firstword,itemnum,txt]);
                tid=tid.replace(/[\[\]\|]/g,'_');
                var exists=store.tiddlerExists(tid);
                if (exists && warn &&
!confirm(config.messages.overwriteWarning.format([tid]))) continue;
                store.saveTiddler(tid,tid,txt,config.options.txtUserName,new
Date(),tags,{});
                if (!exists) tids.push(tid);
            }
            var elapsed=(new Date().getTime()-start)/1000;
            if (parts.length) store.resumeNotifications();
            if (tids.length) {
                store.notifyAll();
                if (f.show.checked)
story.displayTiddlers(story.findContainingTiddler(this),tids);
                displayMessage('created '+tids.length+' target tiddlers in
'+elapsed+' seconds');
            }
        ">
    </td></tr></table>
</form></html>}}}

Regards Tony


TonyM

If you have not found an easy way to do it with TiddlyWiki, you have missed
something.
www.tiddlywiki.com



On Sun, Jan 24, 2010 at 20:24, Måns <humam...@gmail.com> wrote:

> Hi twgrp
> > The SplitTiddler seems great - maybe even a bit "too good" with
> > several tweaks. It's good those default values were there or I
> > wouldn't understand at all. A note, the default for used delimiter is
> > "\n----\n". I don't know what that means and the desired result wasn't
> > produced until I changed this into only "\n" (i.e "new line").
>
> I also need some more documentation for the SplitTiddler transclusion
> - maybe even a few simple userstories might help....
> So if someone is using it - please tell how.. (one step at a time,
> please)
>
> > A note regarding naming multiple tiddlers in Calc (and, I'm sure also
> > Excel). If you write, say, "Name1" into a field and "drag down", then
> > automatic sequencing occur for the number, i.e resulting in fields
> > containing "Name2", "Name3"...
> > (I comment on this only because in Måns CSV files, the suggested
> > tiddler names are only "1","2",... )
>
> As explained in my first hypothetic workflow here:
> http://groups.google.dk/group/tiddlywiki/msg/802c1ffc0f21ae6b?hl=da
>
> Eric Shulmann made some observations regarding OpenOffice csv.-files
> and corrected a few bugs - see:
> http://groups.google.dk/group/tiddlywiki/msg/27b3fe0232f14a3a?hl=da
>
> Regards Måns Mårtensson
>
> --
> You received this message because you are subscribed to the Google Groups
> "TiddlyWiki" group.
> To post to this group, send email to tiddlyw...@googlegroups.com.
> To unsubscribe from this group, send email to
> tiddlywiki+unsubscr...@googlegroups.com<tiddlywiki%2bunsubscr...@googlegroups.com>
> .
> For more options, visit this group at
> http://groups.google.com/group/tiddlywiki?hl=en.
>
>

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

Reply via email to