I want to convert [[Abc dEf 123]]
to [Abc dEf 123](post/abc-def-123)
. I have written a Javascript code for it. I am wondering if the same could e done with the templater plugin.
Can this be done using templater ?
I have written a javascript code. You can run it directly here.
Run
Code
function convertInput(input) {
// Extract the text between the brackets
const text = input.replace(/\[\[(.*?)\]\]/, '$1');
// Remove any whitespace and replace spaces with hyphens
const slug = text.replace(/\s/g, '-').toLowerCase();
// Create the desired output format
const output = `[${text}](/post/${slug})`;
return output;
}
// Prompt the user to enter the input
const userInput = prompt("Enter the input in the format [[ABC 123]]:");
// Call the function with user input
const result = convertInput(userInput);
console.log(result);