` to the end of it.Here is the bulk of the code.function newsSubmit(){ let title = document.getElementById('news-title').value; let date = document.getElementById('news-date').value; let author = document.getElementById('news-author').value; let body = document.getElementById('news-body').value; printToText(title, date, author, body); } function printToText(title, date, author, body) { var header = ''+'\n'+'
'+'\n'+' '+'\n'+''+'\n'+''; var footer = ''+'\n'+''; var codeTitle = ''+title+'
'; var codeDate = ''+date+'
'; var codeAuthor = ''+author+'
'; var content = header+'\n'+codeTitle + '\n' + codeDate + '\n' + codeAuthor+'\n'+footer; fs.writeFile('/path/to/the/news.html', content, function(err) { if (err) { return console.log(err); } }); } I have no issue pulling the data and saving it to an html file but trying to parse the `body` variable, for new paragraphs just isn't something I can wrap my head around at the moment.Yes I do also know that my code isn't the greatest looking or most efficient, cleaning will come later (maybe).Does anyone have an idea how I'd parse the `body` and turn line breaks into paragraphs?Submitted March 03, 2020 at 08:02PM by akblais
No comments:
Post a Comment