Hi Leon
The usual way to address this would be to pass the tiddler title to the macro
call by using the macrocall widget:
<$macrocall $name="JavaC1" myText={{!!title}}/>
That way, the macro can be used with any text, not just the current tiddler
title.
Best wishes
Jeremy.
> On 11 Sep 2019, at 02:18, Leon Gomez <[email protected]> wrote:
>
> Hello,
> I'm trying to find a way to get the current {{!!title}} into an alphanumeric
> + underscores format variable, so for example "Topic: Foo Bar" would be
> converted to "topic_foo_bar"
>
> The following works to convert text as wanted:
>
> /*\
> title: JavaC1
> type: application/javascript
> module-type: macro
> \*/
> (function(){
>
> /*jslint node: true, browser: true */
> /*global $tw: false */
> "use strict";
>
> exports.name = "JavaC1";
>
> exports.params = [
> { name: "myText" }
> ];
>
> /*
> Run the macro
> */
> exports.run = function(myText) {
> if( !myText) myText = "all spaces to underscores";
> var myAlphanum = myText.replace(/[^A-Z0-9]+/ig, "_");
> var output ="1: [" + myText + "] <br>2: [" + myAlphanum+ "]";
> return output;
> };
>
> })();
> Calling:
> <<JavaC1>>
> <<JavaC1 "symbols ? disappear ! as # well">>
>
> but I can't find how to make it automatically retrieve {{!!title}} as with
> normal tiddlywiki macros.
>
> Alternatively, is there any other method to transform/user regex inside
> regular macros, or easily acquire the title on that format? Thanks
>
> --
> 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]
> <mailto:[email protected]>.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/tiddlywiki/346e7895-76fa-4d46-85a0-277504ee9b8f%40googlegroups.com
>
> <https://groups.google.com/d/msgid/tiddlywiki/346e7895-76fa-4d46-85a0-277504ee9b8f%40googlegroups.com?utm_medium=email&utm_source=footer>.
--
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 view this discussion on the web visit
https://groups.google.com/d/msgid/tiddlywiki/D32A825E-1992-4E8E-A39C-4081FDAFF630%40gmail.com.