Discussion:
[tw] [TW5] Transclude first paragraph or similar
(too old to reply)
Mat
2015-05-05 21:29:36 UTC
Permalink
Things are a bit too difficult for me in the FastNewTiddler project, so I'm
hoping to make the specifications list in the "Todo (please help)
<http://fastnewtiddler.tiddlyspot.com/#Todo%20(please%20help)>" as good as
possible so it will be "easy" to at least ask for help, i.e with clear
descriptions of things. Ironically, I need a bit of help to set this up...
yes, help in asking for help... hmmm :-/

I've made a thing so it's easy to add todo-items by listing the title of
specifically prefixed tiddlers, but my hope is to have the list show the
first paragraph, or perhaps a fixed set of lines, for each item. I.e, for
each issue, I intend to write a good description of the problem which I can
then post e.g here, but the aggregated list should show the titles of all
issues and the first paragraph which will serve as a summary to the issue.

So, the question is how to transclude or "pick out" the initial paragraph
or similar?

Thanx!

<:-)
--
You received this message because you are subscribed to the Google Groups "TiddlyWiki" group.
To unsubscribe from this group and stop receiving emails from it, send an email to tiddlywiki+***@googlegroups.com.
To post to this group, send email to ***@googlegroups.com.
Visit this group at http://groups.google.com/group/tiddlywiki.
To view this discussion on the web visit https://groups.google.com/d/msgid/tiddlywiki/94aec3dd-a037-465c-8fd8-3a15801e56dc%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Jed Carty
2015-05-05 21:41:05 UTC
Permalink
I unfortunately don't have an answer for your question, I think it would
require some javascript. Everything I have seen for that sort of goal uses
a special summary field. I did make a plugin that I use for this same
purpose over on my wiki, you can see it here
<http://inmysocks.tiddlyspot.com/#Change%20Log>. It is probably overkill
for your purpose unless it becomes much more complicated than it is, but I
will see about including options to make a simpler list with it. In the
mean time you may be able to pull out the template for the list itself to
use the info popup part instead of having to pick out part of the text of a
tiddler.

And a clear list of what needs to be done is a wonderful thing to have. It
makes life so much easier, so thanks for putting it together!
--
You received this message because you are subscribed to the Google Groups "TiddlyWiki" group.
To unsubscribe from this group and stop receiving emails from it, send an email to tiddlywiki+***@googlegroups.com.
To post to this group, send email to ***@googlegroups.com.
Visit this group at http://groups.google.com/group/tiddlywiki.
To view this discussion on the web visit https://groups.google.com/d/msgid/tiddlywiki/e4d08c8d-5a82-40b3-827c-ae5c950e4d9f%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Mat
2015-05-05 22:54:04 UTC
Permalink
Thank you for answering Jed! Also non-solving answers are of value as they
indicate maybe I should look for alternatives.

I think I'll use Tobias' summary template then. Feels silly to install and
work on a lot of stuff that really have nothing to do with the actual
task... but then, I don't have the coding competence for the actual task
anyway so...


And a clear list of what needs to be done is a wonderful thing to have. It
Post by Jed Carty
makes life so much easier, so thanks for putting it together!
That is very encouraging to hear Jed (and maybe I'm overly optimistic...ok,
desperate... but it sounds like you're willing to support it a bit further).

<:-)
--
You received this message because you are subscribed to the Google Groups "TiddlyWiki" group.
To unsubscribe from this group and stop receiving emails from it, send an email to tiddlywiki+***@googlegroups.com.
To post to this group, send email to ***@googlegroups.com.
Visit this group at http://groups.google.com/group/tiddlywiki.
To view this discussion on the web visit https://groups.google.com/d/msgid/tiddlywiki/8d1ac826-6808-43e0-99e6-fa279506b253%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Jed Carty
2015-05-06 18:00:26 UTC
Permalink
I will certainly put more time into this. I am going to be packing for the
next few days so it may be a while before I can do much.
--
You received this message because you are subscribed to the Google Groups "TiddlyWiki" group.
To unsubscribe from this group and stop receiving emails from it, send an email to tiddlywiki+***@googlegroups.com.
To post to this group, send email to ***@googlegroups.com.
Visit this group at http://groups.google.com/group/tiddlywiki.
To view this discussion on the web visit https://groups.google.com/d/msgid/tiddlywiki/b9970254-5dce-4d18-bb5d-b07fb50383c9%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Michael Wiktowy
2015-05-06 20:54:24 UTC
Permalink
You can likely use the "match" filter operator for this.

Transclude in your first paragraph of a tiddler named "test" like this:

{{{test ||show_first }}}

Then make a template tiddler called show_first containing:

<$set name="first_paragraph" filter="[is[current]match:text/.+/]">
<$text text=<<first_paragraph>>/>
</$set>

This seems to work but I am not sure why is includes some [[...]] around
the text. Probably something stupidly simple that I'm missing.

Also, I am not sure if the match filter operator is part of the core or
some some plugin that I picked up and have been carrying around in my
tiddlywikis since I see no description of it in the official site.

/Mike
Post by Mat
Things are a bit too difficult for me in the FastNewTiddler project, so
I'm hoping to make the specifications list in the "Todo (please help)
<http://fastnewtiddler.tiddlyspot.com/#Todo%20(please%20help)>" as good
as possible so it will be "easy" to at least ask for help, i.e with clear
descriptions of things. Ironically, I need a bit of help to set this up...
yes, help in asking for help... hmmm :-/
I've made a thing so it's easy to add todo-items by listing the title of
specifically prefixed tiddlers, but my hope is to have the list show the
first paragraph, or perhaps a fixed set of lines, for each item. I.e, for
each issue, I intend to write a good description of the problem which I can
then post e.g here, but the aggregated list should show the titles of all
issues and the first paragraph which will serve as a summary to the issue.
So, the question is how to transclude or "pick out" the initial paragraph
or similar?
Thanx!
<:-)
--
You received this message because you are subscribed to the Google Groups "TiddlyWiki" group.
To unsubscribe from this group and stop receiving emails from it, send an email to tiddlywiki+***@googlegroups.com.
To post to this group, send email to ***@googlegroups.com.
Visit this group at http://groups.google.com/group/tiddlywiki.
To view this discussion on the web visit https://groups.google.com/d/msgid/tiddlywiki/6d515d4f-e0ac-4811-865a-733a89be5bbe%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Mat
2015-05-07 10:24:50 UTC
Permalink
@Jed <:-D

@Mike

Also, I am not sure if the match filter operator is part of the core or
Post by Michael Wiktowy
some some plugin that I picked up and have been carrying around in my
tiddlywikis since I see no description of it in the official site.
"match" does seem like a useful operator, but as you point out, it does not
seem to be part of core. Do you think you could post it, or some link to
it, here?

Thank you!

<:-)
--
You received this message because you are subscribed to the Google Groups "TiddlyWiki" group.
To unsubscribe from this group and stop receiving emails from it, send an email to tiddlywiki+***@googlegroups.com.
To post to this group, send email to ***@googlegroups.com.
Visit this group at http://groups.google.com/group/tiddlywiki.
To view this discussion on the web visit https://groups.google.com/d/msgid/tiddlywiki/ac1287a2-7945-4402-9868-06e34125a713%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Michael Wiktowy
2015-05-07 14:06:48 UTC
Permalink
Digging into the archives, I found that it was Richard Smith who had helped
me find this tool in the first place for a problem that I was having and it
worked great:
https://groups.google.com/d/msg/tiddlywiki/3RAobE3aXqY/hcMg09fT3TAJ

Eucaly created it. It doesn't seem to be packaged as a regular plugin and
that is why I thought that it might be part of the core.
It is called matchfilter and is found here:
http://eucaly-tw5.tiddlyspot.com/

As soon as you drag over $:/core/modules/filters/match.js ,save and
refresh, those tiddlers that I gave earlier should work. The example that I
gave is not perfect due to the way that <$text> handles content returned by
filters but you should be able to massage it to your needs.

Enjoy,
/Mike
Post by Mat
@Jed <:-D
@Mike
Also, I am not sure if the match filter operator is part of the core or
Post by Michael Wiktowy
some some plugin that I picked up and have been carrying around in my
tiddlywikis since I see no description of it in the official site.
"match" does seem like a useful operator, but as you point out, it does
not seem to be part of core. Do you think you could post it, or some link
to it, here?
Thank you!
<:-)
--
You received this message because you are subscribed to the Google Groups "TiddlyWiki" group.
To unsubscribe from this group and stop receiving emails from it, send an email to tiddlywiki+***@googlegroups.com.
To post to this group, send email to ***@googlegroups.com.
Visit this group at http://groups.google.com/group/tiddlywiki.
To view this discussion on the web visit https://groups.google.com/d/msgid/tiddlywiki/40f5b39a-c6a0-40ef-8db4-070fd4427c0e%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Mat
2015-05-08 19:39:17 UTC
Permalink
@Mike

http://eucaly-tw5.tiddlyspot.com/
Post by Michael Wiktowy
As soon as you drag over $:/core/modules/filters/match.js ,save and
refresh, those tiddlers that I gave earlier should work.
Can't get this to work. I set up http://match.tiddlyspot.com/ if you could
perhaps tell if I'm misunderstanding something. BTW, are you using the
lastest TW version? I believe that this plugin was written before they
implemented change in some parameter(?) name from "tw-" to "tc-", "tv-" or
whatever it is (anyone who knows what I'm talking about? I don't.) Anyway,
that change made many plugins not work in the updated TW's so is your TW
using the match filter perhaps also not updated?

Thank you!

<:-)
--
You received this message because you are subscribed to the Google Groups "TiddlyWiki" group.
To unsubscribe from this group and stop receiving emails from it, send an email to tiddlywiki+***@googlegroups.com.
To post to this group, send email to ***@googlegroups.com.
Visit this group at http://groups.google.com/group/tiddlywiki.
To view this discussion on the web visit https://groups.google.com/d/msgid/tiddlywiki/c74a3900-443e-4cd6-a4b4-ce7868bd7b76%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Michael Wiktowy
2015-05-08 20:13:49 UTC
Permalink
Post by Michael Wiktowy
@Mike
http://eucaly-tw5.tiddlyspot.com/
<http://www.google.com/url?q=http%3A%2F%2Feucaly-tw5.tiddlyspot.com%2F&sa=D&sntz=1&usg=AFQjCNGQxnHJamYuy0-LASNO_OuvD1YBMw>
As soon as you drag over $:/core/modules/filters/match.js ,save and
refresh, those tiddlers that I gave earlier should work.
Can't get this to work. I set up http://match.tiddlyspot.com/ if you
could perhaps tell if I'm misunderstanding something. BTW, are you using
the lastest TW version? I believe that this plugin was written before they
implemented change in some parameter(?) name from "tw-" to "tc-", "tv-" or
whatever it is (anyone who knows what I'm talking about? I don't.) Anyway,
that change made many plugins not work in the updated TW's so is your TW
using the match filter perhaps also not updated?
Thank you!
<:-)
I looked at the version of match.js that you have and it didn't match mine
... there appears to be two floating around. The one that I have has the
line "140823: reloaded for 5.0.15-beta" in the header.
It can be found attached to a message here:

https://groups.google.com/forum/#%21topic/tiddlywikidev/4ciJxJVAsY8

pointed to by the thread here:

https://groups.google.com/forum/#!topic/tiddlywiki/et79cGcwFLk

I have no idea why the one on eucaly's site doesn't work but it is
significantly different and looks like an earlier version. Sorry for the
wrong pointer. I thought that I confirmed to see if it worked in a new
empty tiddlywiki but I guess my check was flawed in some way.

I just cut and pasted the version pointed to above into your example
tiddler and it works. Here is the match.js that works for me from the links
above.

/*\
title: $:/core/modules/filters/match.js
type: application/javascript
module-type: filteroperator

Filter operator for picking parts out of fields using regular expressions

140823: reloaded for 5.0.15-beta

\*/
(function(){

/*jslint node: true, browser: true */
/*global $tw: false */
"use strict";

/*
Export our filter function
*/
exports.match = function(source,operator,options) {
var results = [],
fieldname = (operator.suffix || operator.operator || "title").toLowerCase();
if(operator.prefix === "!") {
if(operator.regexp) {
source(function(tiddler,title) {
if(tiddler) {
var text = tiddler.getFieldString(fieldname);
if(text !== null && !operator.regexp.exec(text)) {
results.push(title);
}
}
});
} else {
source(function(tiddler,title) {
if(tiddler) {
var text = tiddler.getFieldString(fieldname);
if(text !== null && text !== operator.operand) {
results.push(title);
}
}
});
}
} else {
if(operator.regexp) {
source(function(tiddler,title) {
if(tiddler) {
var text = tiddler.getFieldString(fieldname);
if(text !== null) {
var matches = [],
execresult = operator.regexp.exec(text);
while(execresult) {
if(execresult.length > 1) { // there were brackets
matches= matches.concat(execresult.slice(1));
}
else { // no brackets - take the full match
matches.push(execresult[0]);
}
if(operator.regexp.lastIndex === 0) { // no g-switch
break;
}
execresult = operator.regexp.exec(text);
}
if(matches) {
$tw.utils.pushTop(results,matches);
}
}
}
});
} else {
source(function(tiddler,title) {
if(tiddler) {
var text = tiddler.getFieldString(fieldname);
if(text !== null){
var incr = operator.operand.length;
if(incr === 0) { // empty operand
return;
}
var matches = [],
pos = text.indexOf(operator.operand);
while(pos >= 0) {
matches.push(operator.operand);
pos = text.indexOf(operator.operand, pos+incr);
}
if(matches) {
$tw.utils.pushTop(results,matches);
}
}
}
});
}
}
return results;
};

})();
--
You received this message because you are subscribed to the Google Groups "TiddlyWiki" group.
To unsubscribe from this group and stop receiving emails from it, send an email to tiddlywiki+***@googlegroups.com.
To post to this group, send email to ***@googlegroups.com.
Visit this group at http://groups.google.com/group/tiddlywiki.
To view this discussion on the web visit https://groups.google.com/d/msgid/tiddlywiki/58424aee-0c6d-470f-a644-aea1bb98bcd8%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Michael Wiktowy
2015-05-08 20:42:07 UTC
Permalink
Post by Michael Wiktowy
@Mike
http://eucaly-tw5.tiddlyspot.com/
Post by Michael Wiktowy
As soon as you drag over $:/core/modules/filters/match.js ,save and
refresh, those tiddlers that I gave earlier should work.
Can't get this to work. I set up http://match.tiddlyspot.com/ if you
could perhaps tell if I'm misunderstanding something. BTW, are you using
the lastest TW version? I believe that this plugin was written before they
implemented change in some parameter(?) name from "tw-" to "tc-", "tv-" or
whatever it is (anyone who knows what I'm talking about? I don't.) Anyway,
that change made many plugins not work in the updated TW's so is your TW
using the match filter perhaps also not updated?
Thank you!
<:-)
In poking around, it looks like the version that I am using is is the same
as the version called matcha.js on Eucaly site and was originally adopted
from Stephan Hradek's version

http://eucaly-tw5.tiddlyspot.com/#%24%3A%2Fplugins%2Feucaly%2Fmatchfilter5b15%2Freadme


A bit of a confusing version tree, heritage and applicability if you ask me.

/Mike
--
You received this message because you are subscribed to the Google Groups "TiddlyWiki" group.
To unsubscribe from this group and stop receiving emails from it, send an email to tiddlywiki+***@googlegroups.com.
To post to this group, send email to ***@googlegroups.com.
Visit this group at http://groups.google.com/group/tiddlywiki.
To view this discussion on the web visit https://groups.google.com/d/msgid/tiddlywiki/d0fc601d-a0b0-4f07-a6d0-0d12a7194200%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Mat
2015-05-12 11:41:39 UTC
Permalink
@Mike - thank you for your input and sorry for late reply.

With your pointers it does work now; http://match.tiddlyspot.com/

But I do suspect the use of $tw is inappropriate and he also comments that "/*global
$tw: false */" which may be an indiction of this? I also get the
surrounding brackets, which I'm guessing is a failed attempt att creating a
link from the output?

It seems like a very useful "Filter operator for picking parts out of
fields using regular expressions" so hopefully someone will create a fully
satisfying version eventually.

FYI, I intended to use it to transclude the first paragraph for the ToDo
list <http://fastnewtiddler.tiddlyspot.com/#Todo%20(please%20help)> in
fastnewtiddler but instead went with using a solution from Tobias to
transclude a field into the text that then appears to be the first
paragraph in the tiddler text and is reused in the ToDo-list. A bit
backward but...

<:-)
Post by Michael Wiktowy
Post by Michael Wiktowy
@Mike
http://eucaly-tw5.tiddlyspot.com/
Post by Michael Wiktowy
As soon as you drag over $:/core/modules/filters/match.js ,save and
refresh, those tiddlers that I gave earlier should work.
Can't get this to work. I set up http://match.tiddlyspot.com/ if you
could perhaps tell if I'm misunderstanding something. BTW, are you using
the lastest TW version? I believe that this plugin was written before they
implemented change in some parameter(?) name from "tw-" to "tc-", "tv-" or
whatever it is (anyone who knows what I'm talking about? I don't.) Anyway,
that change made many plugins not work in the updated TW's so is your TW
using the match filter perhaps also not updated?
Thank you!
<:-)
In poking around, it looks like the version that I am using is is the same
as the version called matcha.js on Eucaly site and was originally adopted
from Stephan Hradek's version
http://eucaly-tw5.tiddlyspot.com/#%24%3A%2Fplugins%2Feucaly%2Fmatchfilter5b15%2Freadme
A bit of a confusing version tree, heritage and applicability if you ask me.
/Mike
--
You received this message because you are subscribed to the Google Groups "TiddlyWiki" group.
To unsubscribe from this group and stop receiving emails from it, send an email to tiddlywiki+***@googlegroups.com.
To post to this group, send email to ***@googlegroups.com.
Visit this group at http://groups.google.com/group/tiddlywiki.
To view this discussion on the web visit https://groups.google.com/d/msgid/tiddlywiki/6d8d44a2-a504-4da4-b007-d483dcb156e3%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Rustem
2015-06-03 21:17:17 UTC
Permalink
This is a bit late, but here’s my solution that returns the first line (not
paragraph), using nothing but core functionality. Copy it literally
(including new line as splitbefore’s parameter) into a test tiddler.

<$list filter="[{$:/ControlPanel}splitbefore[
]]" variable="firstLine"><$text text=<<firstLine>>/></$list>

—R

On Tuesday, May 12, 2015 at 4:41:40 AM UTC-7, Mat wrote:

@Mike - thank you for your input and sorry for late reply.
Post by Mat
With your pointers it does work now; http://match.tiddlyspot.com/
But I do suspect the use of $tw is inappropriate and he also comments that
"/*global $tw: false */" which may be an indiction of this? I also get
the surrounding brackets, which I'm guessing is a failed attempt att
creating a link from the output?
It seems like a very useful "Filter operator for picking parts out of
fields using regular expressions" so hopefully someone will create a
fully satisfying version eventually.
FYI, I intended to use it to transclude the first paragraph for the ToDo
list <http://fastnewtiddler.tiddlyspot.com/#Todo%20(please%20help)> in
fastnewtiddler but instead went with using a solution from Tobias to
transclude a field into the text that then appears to be the first
paragraph in the tiddler text and is reused in the ToDo-list. A bit
backward but...
<:-)
​
--
You received this message because you are subscribed to the Google Groups "TiddlyWiki" group.
To unsubscribe from this group and stop receiving emails from it, send an email to tiddlywiki+***@googlegroups.com.
To post to this group, send email to ***@googlegroups.com.
Visit this group at http://groups.google.com/group/tiddlywiki.
To view this discussion on the web visit https://groups.google.com/d/msgid/tiddlywiki/a87302d3-ef37-452b-8596-9a78d83f0d99%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Mat
2015-06-04 08:29:48 UTC
Permalink
@Rustem - while I solved the original problem in another way, I really
appreciate your reply and know(!) that I'll use this later on so thank you!

FYI, this made me post a new issue
<https://github.com/Jermolene/TiddlyWiki5/issues/1769> asking to extend
splitbefore to allow for specified number of characters to split at.


@anyone else; Just for the record, if you instead use the following, it'll
give the first sentence.

<$list filter="[{SomeTextyTiddler}splitbefore[. ]]"
variable="firstLine"><$text text=<<firstLine>>/></$list>


<:-)
Post by Rustem
This is a bit late, but here’s my solution that returns the first line
(not paragraph), using nothing but core functionality. Copy it literally
(including new line as splitbefore’s parameter) into a test tiddler.
<$list filter="[{$:/ControlPanel}splitbefore[
]]" variable="firstLine"><$text text=<<firstLine>>/></$list>
—R
@Mike - thank you for your input and sorry for late reply.
Post by Mat
With your pointers it does work now; http://match.tiddlyspot.com/
But I do suspect the use of $tw is inappropriate and he also comments
that "/*global $tw: false */" which may be an indiction of this? I also
get the surrounding brackets, which I'm guessing is a failed attempt att
creating a link from the output?
It seems like a very useful "Filter operator for picking parts out of
fields using regular expressions" so hopefully someone will create a
fully satisfying version eventually.
FYI, I intended to use it to transclude the first paragraph for the ToDo
list <http://fastnewtiddler.tiddlyspot.com/#Todo%20(please%20help)> in
fastnewtiddler but instead went with using a solution from Tobias to
transclude a field into the text that then appears to be the first
paragraph in the tiddler text and is reused in the ToDo-list. A bit
backward but...
<:-)
​
--
You received this message because you are subscribed to the Google Groups "TiddlyWiki" group.
To unsubscribe from this group and stop receiving emails from it, send an email to tiddlywiki+***@googlegroups.com.
To post to this group, send email to ***@googlegroups.com.
Visit this group at http://groups.google.com/group/tiddlywiki.
To view this discussion on the web visit https://groups.google.com/d/msgid/tiddlywiki/ed65119a-d870-49e3-a1b8-02514ebc9341%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Continue reading on narkive:
Loading...