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.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