Hi w,
Happy New Year, and thank you so much for solving this. I've hoped for this
to come true for quite a while! And shame on me not even thought of using
just simple comparison to get the ranged data! Ha!
Here is what's working now:
<<forEachTiddler
where 'tiddler.tags.contains("myTag") &&
(tiddler.title.replace(/(CC§)([\d]+)(\-?)([\d]?)/, "$2.$4") >= X) &&
(tiddler.title.replace(/(CC§)([\d]+)(\-?)([\d]?)/, "$2.$4") <= Y)'
sortBy 'tiddler.title' ascending
write '"\+\+\+["+tiddler.title.replace(/CC§/,"")+"]...<<tiddler
"+tiddler.title+">\>===\n"'>>
so I can specify X and Y as the start and the end directly~ And also the
hyphen of inserted articles are replaced as decimal dots, so that numeric
comparison works all the time. (For example, I can specify X as a decimal
"156.3" to refer to §156-3, so that this article can be used as a start
point)
Thanks for this New Year present! Wish you get plenty of blessings too!
whatever於 2012年12月30日星期日UTC+8上午7時34分12秒寫道:
>
> Hey!
>
> There's no need for scripts, just expand the write part like this:
> <<forEachTiddler where 'tiddler.tags.contains("yourTag") &&
> (tiddler.title.replace(/CC§|-[\d]+?/, "") > XX) &&
> (tiddler.title.replace(/CC§|-[\d]+?/, "") < XX)'
>
> Just replace both XX with your numbers and you should get only the
> tiddlers whose main number is between the first and the second XX,
> excluding the XX.
> Note that I didn't test this, so it might need some tweaking. Possibly
> the dash might need escaping.
>
> w
>
> On 29 dec., 00:39, "G.J.Robert" <[email protected]> wrote:
> > Hi!
> >
> > Thank you so much for your suggestion! I'll work on it.
> >
> > Meanwhile what remains is that if I want to specify a range of tiddlers
> > among the articles to quote, for example I want to refer to Article X to
> > Article Y, how should I tell forEachTiddler to grab the specified range?
> >
> > I would imagine to use the "script" clause in forEachTiddler to get the
> > start point X and final article Y into the function, and maybe a loop of
> > "for (n=x; n>y; n++)..." to process each one, and return the whole bunch
> of
> > tiddlers to be written in the output, but I have difficulty to figure
> out
> > the right code...
> >
> > whatever於 2012年12月28日星期五UTC+8下午11時11分44秒寫道:
> >
> >
> >
> >
> >
> > > Hi!
> >
> > > <<forEachTiddler where 'tiddler.tags.contains("yourTag")' sortBy
> > > 'tiddler.title' ascending write '"\+\+\+["+tiddler.title.replace(/
> > > CC§/, "")+"]...<<tiddler "+tiddler.title+">\>===\n"'>>
> >
> > > That should do it, I think. You'll have to check how the TW sorts the
> > > XX-1 tiddlers. You might also have to potentially escape "") like
> > > \"\").
> > > w
> >
> > > On 27 dec., 15:48, "G.J.Robert" <[email protected]> wrote:
> > > > Hi, I'm editing a wiki for my legal study notebook. I have copied
> > > various
> > > > statutes and separate them into tiddlers by each article/clause. And
> I
> > > > often use AliasPlugin, NestedSlidersPlugin and <<tiddler>>
> transclusion
> > > to
> > > > make inline popups to refer to relevant articles in my notes. Here
> is a
> > > > problem I hope to resolve: how to refer to a range of articles in
> just
> > > one
> > > > macro call?
> >
> > > > ex. For a certain issue I would like to refer to §73 to §85 of our
> Civil
> > > > Code, and I have all the articles with numbers as tiddler titles in
> > > place,
> > > > from CC§1 to CC§XXXX. Now, how do I write a ForEachTiddler macro
> call to
> > > > transclude §73 to §85 at once? i.e. I hope to have the generated
> output
> > > > written as sth. like
> >
> > > > +++[73]...<<tiddler CC§73>>===
> > > > +++[74]...<<tiddler CC§74>>===
> > > > +++[75]...<<tiddler CC§75>>===
> > > > +++[76]...<<tiddler CC§76>>===
> > > > ...
> > > > +++[85]...<<tiddler CC§85>>===
> >
> > > > to get all the sliders as references.
> >
> > > > Mind if I ask, because I'm very bad at coding and not sure how to
> get
> > > the
> > > > right array from the titles of tiddlers to make an array and use
> some
> > > kind
> > > > of loop to grab the range I want. I have tried a couple of times in
> vain
> > > so
> > > > decided to seek for help. And also, I may not be able to understand
> and
> > > use
> > > > the syntax of ForEachTiddler macro correctly.
> >
> > > > Any hints/tips? Thanks!
> >
> > > > ----
> > > > More advanced scenario: if there are certain newly inserted articles
> > > named
> > > > as sth like CC§75-1, CC§75-2 after §75 and before §76, can these be
> > > sorted
> > > > correctly and included in the range too?
> >
> > > > +++[73]...<<tiddler CC§73>>===
> > > > +++[74]...<<tiddler CC§74>>===
> > > > +++[75]...<<tiddler CC§75>>===
> > > > +++[73]...<<tiddler CC§75-1>>===
> > > > +++[73]...<<tiddler CC§75-2>>===
> > > > +++[76]...<<tiddler CC§76>>===
> > > > ...
> > > > +++[85]...<<tiddler CC§85>>===
> >
> > > > I've heard that in Germany or other countries inserted articles are
> > > > numbered using alphabets like 75a, 75b, but unfortunately we use -1,
> -2,
> > > -3
> > > > in our country...
>
--
You received this message because you are subscribed to the Google Groups
"TiddlyWiki" group.
To view this discussion on the web visit
https://groups.google.com/d/msg/tiddlywiki/-/-fBd-GCXliEJ.
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.