Actually, what I think you see is
Mr.
Test
What's happening is that the macro is being returned as [[Mr. Test]] and
then stripped of the brackets at the WikifyWidget. One work-around is to
add additional brackets back in your macro.
Also, this
var regex = /\[.*?\]\]/g;
Should be this
var regex = /\[\[.*?\]\]/g;
So then we end up with:
/*\
title: $:/core/modules/macros/roles.js
type: application/javascript
module-type: macro
Making some replacements in Textinputs
\*/
(function(){
/*jslint node: true, browser: true */
/*global $tw: false */
"use strict";
/*
Information about this macro
*/
exports.name
= 'roles';
exports.params = [{ name: 'text' }];
/*
Run the macro
*/
exports.run = function(text) {
var regex = /\[\[.*?\]\]/g;
var found = text.match(regex);
var remove = "[[" + found.join("]] [[") + "]]";
//var result = remove.replace(/,/g, ' ');
var result = remove ;
return result
} ;
})();
Now you get the links listed one after another. However, they're not listed
AS links because they're viewed as text strings. You
can probably use <$link> widget to turn them back into links, if that's
what you want.
Good luck
On Monday, July 15, 2019 at 12:45:42 PM UTC-7, Jan wrote:
>
> Hi Mark, that looks great, is this already available?
> Meanwhile I created a solution which is working quit good but has one flaw
> which I would like to eliminate:
> [[Mr. Test]] Gets parsed [[Mr.]] and [[Test]].
>
> Here comes the approach it is a Widget and a macro in combination:
> Widget
>
> /*\
> title: $:/core/modules/macros/roles.js
> type: application/javascript
> module-type: macro
> Making some replacements in Textinputs
> \*/
>
> (function(){
> /*jslint node: true, browser: true */
> /*global $tw: false */
> "use strict";
>
> /*
> Information about this macro
> */
> exports.name = 'roles';
> exports.params = [{ name: 'text' }];
> /*
> Run the macro
> */
> exports.run = function(text) {
> var regex = /\[.*?\]\]/g;
> var found = text.match(regex);
> var remove = found.join();
> var result = remove.replace(/,/g, ' ');
> return result
> } ;
>
> Macro
>
> \define preroll()
>
> <$macrocall $name="roles" text={{!!dialogue}}/>
>
> \end
> \define rollen()
> <$wikify name=rollo text=<<preroll>> output="text">
> <$list filter=<<rollo>> >
> {{!!title}} <br>
> </$list>
> </$wikify>
> \end
>
> How can I handle that?
>
> Jan
>
>
>
>
> Am 15.07.2019 um 16:51 schrieb 'Mark S.' via TiddlyWiki:
>
> With the reg expression text previously mentioned, and the regexps (reg
> expression string extractor) in PR 2963
> <https://github.com/Jermolene/TiddlyWiki5/pull/2963>
> it should be possible to extract links designated with [[ and ]] .
>
> On Monday, July 15, 2019 at 4:06:31 AM UTC-7, Jan wrote:
>>
>> Hi,
>> alas the Find-Macro and also the Extract-Macro fail in this job. This
>> really seems to be an issue for a widget which can escape the
>> square-bracket-problem.
>>
>> I made a quick attempt to solve this problem with a widget matching for
>> the css, with no success so far.
>>
>> /*\
>> title: $:/core/modules/macros/roles.js
>> type: application/javascript
>> module-type: macro
>> Making some replacements in Textinputs
>> \*/
>>
>> (function(){
>> /*jslint node: true, browser: true */
>> /*global $tw: false */
>> "use strict";
>>
>> /*
>> Information about this macro
>> */
>> exports.name = 'roles';
>> exports.params = [{ name: 'text' }];
>> /*
>> Run the macro
>> */
>> exports.run = function(text) {
>> text = text.match("/\[.*?\]/g");
>> return text
>> } ;
>> })();
>>
>>
>> Seeing how complicated this problem is in wikitext, I think it would be
>> usefull, to have such a thing as "Extract Links Widget".
>>
>> Jan
>>
>>
>>
>>
>>
>>
>> Jan
>>
>> Am 15.07.2019 um 10:01 schrieb Jan:
>>
>> Hi Mark!
>> I have tried out your proposition but alas, the filter is not working the
>> way I would like it to work:
>> So far it looks for Tiddlers that have the field "myfield", it should
>> look for Links in this field.
>>
>> I have tired several variations with get[] and list[] to have the
>> dialoguebut it nearly seems impossible to filter the result for [[square
>> brackets.
>>
>> Jan
>>
>>
>>
>>
>>
>>
>> Am 14.07.2019 um 22:51 schrieb Jan Johannpeter:
>>
>> Hi Mark,
>> thanks, again you saved my day!
>> I will implement this at once!
>> Jan
>>
>> Mohammad <[email protected]> schrieb am So. 14. Juli 2019 um 19:18:
>>
>>> Hi Mark,
>>> I was surprised with this simple and elegant solution you proposed
>>> albeit the regxp is behind my knowledge! :-)
>>>
>>> Added to TW-Scripts.
>>>
>>> Cheers
>>> Mohammad
>>>
>>>
>>> On Sunday, July 14, 2019 at 9:21:42 PM UTC+4:30, Mark S. wrote:
>>>>
>>>> You need to put your expression in a separate variable:
>>>>
>>>> <$vars reg="(?g)\[\[.*?\]\]">
>>>> <$list filter="[!is[system]regexp:myfield<reg>]"/>
>>>> </$vars>
>>>>
>>>> I tested using field "myfield". I was surprised to find that there
>>>> actually is a matching field at tiddlywiki.com.
>>>>
>>>> Note that the regexp filter has its own notation for indicating a
>>>> global search. I put it in, but don't really understand what use it has,
>>>> since it is the tiddler that gets returned, not the field. So finding one
>>>> match should be good enough.
>>>>
>>>>
>>>> On Sunday, July 14, 2019 at 3:51:37 AM UTC-7, Jan wrote:
>>>>>
>>>>> Hi Mat,
>>>>> Unfortunately filtersyntax gets so terribly complicated when the param
>>>>> contains squarebrackets.
>>>>> This here causes a syntax error: [!is[system]regexp[/\[.*?\]/g]]
>>>>>
>>>>> And how do I enter the suffix for the field?
>>>>> -Jan
>>>>>
>>>>>
>>>>>
>>>>>
>>>>> Am 14.07.2019 um 12:03 schrieb Mat:
>>>>>
>>>>> >or else it would probably be veeery tricky to find them.
>>>>>
>>>>> Pah! I'm exaggerating. It is "just" a matter of creating the right
>>>>> regexp for it. Not that I could do it.
>>>>>
>>>>> <:-)
>>>>> --
>>>>> 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 [email protected].
>>>>> To post to this group, send email to [email protected].
>>>>> Visit this group at https://groups.google.com/group/tiddlywiki.
>>>>> To view this discussion on the web visit
>>>>> https://groups.google.com/d/msgid/tiddlywiki/ebad32fa-60c1-4434-a943-350812eb47d7%40googlegroups.com
>>>>>
>>>>> <https://groups.google.com/d/msgid/tiddlywiki/ebad32fa-60c1-4434-a943-350812eb47d7%40googlegroups.com?utm_medium=email&utm_source=footer>
>>>>> .
>>>>> For more options, visit https://groups.google.com/d/optout.
>>>>>
>>>>>
>>>>> --
>>> 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 [email protected].
>>> To post to this group, send email to [email protected].
>>> Visit this group at https://groups.google.com/group/tiddlywiki.
>>> To view this discussion on the web visit
>>> https://groups.google.com/d/msgid/tiddlywiki/3989d192-3218-4d29-8eef-114071e5fcc4%40googlegroups.com
>>>
>>> <https://groups.google.com/d/msgid/tiddlywiki/3989d192-3218-4d29-8eef-114071e5fcc4%40googlegroups.com?utm_medium=email&utm_source=footer>
>>> .
>>> For more options, visit https://groups.google.com/d/optout.
>>>
>>
>>
>> --
> 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 [email protected] <javascript:>.
> To post to this group, send email to [email protected]
> <javascript:>.
> Visit this group at https://groups.google.com/group/tiddlywiki.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/tiddlywiki/7ea4f8ae-889d-4664-a6f5-5c49ba5d14a9%40googlegroups.com
>
> <https://groups.google.com/d/msgid/tiddlywiki/7ea4f8ae-889d-4664-a6f5-5c49ba5d14a9%40googlegroups.com?utm_medium=email&utm_source=footer>
> .
> For more options, visit https://groups.google.com/d/optout.
>
>
>
--
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 [email protected].
To post to this group, send email to [email protected].
Visit this group at https://groups.google.com/group/tiddlywiki.
To view this discussion on the web visit
https://groups.google.com/d/msgid/tiddlywiki/85a2bf4f-58e3-4d63-ad4c-4e1df9567dee%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.