If in a browser console (FF and Chrome, press F12 and see the console) enter the below JavaScript code, it will work
a= "One"
b="Two"
s="\n"
y=a + s +b
then you get
a="One"
"One"
b="Two"
"Two"
s="\n"
"
"
a+s+b
"One
Two"
Note the two lines text in the output. That means the "\n" treated as a
line-break or newline.
Now, do the same in Tiddlywiki.
Create a JS macro as below:
(function(){
/*jslint node: true, browser: true */
/*global $tw: false */
"use strict";
exports.name = "jsmac";
exports.params = [
{name: "a"},
{name: "b"},
{name: "s"}
];
/*
Run the macro
*/
exports.run = function(a, b, s) {
return a + s + b;
}
})();
I have attached
jsmac tiddler above to this post
Test:
Drag and drop the below tiddler into an empty wiki. save and reload
Then create a test tiddler with the below contents
<$macrocall $name=jsmac
a="one"
b="two"
s=" \n "
/>
What you get is:
That means Twiddlywiki JavaScript macro does not work as expected. It treats "\n" literally! It does not interpret it as a newline
What is wrong here?
Note:
If you like to test on Tiddlywiki.com
Drag and drop the attached two tiddler to Tiddlywiki.com
Save and reload (a copy will saved on your system)
--Mohammad