Hello,
My friend gave me a code to try a bit. What it does is that it gets a text and format it. Here it is:
function boldAndItalicize(text) {
return text.replace(/&/g, '&').replace(/</g, '<')
.replace(/(\*+)([^*]{1,1024})(\*+)/g,
function (whole, open, content, close) {
if (open.length === close.length) {
switch (open.length) {
case 1: return '<i>' + content + '</i>';
case 2: return '<b>' + content + '</b>';
}
}
return whole;
});
}
But I want to know how I could input a plain text file(like test.txt
, that is on the same folder as the script) in the text
parameter?
Best Regards,
Nathan Paulino Campos