I am now building a simple application, which includes editing the content such as blog. I have a few options such as tinymc, a good html editor, which I planned to use it. but then I find something about markdown, which is easy to use and popular as well nowadays. among the markdown supported editors, EpicEditor is a good choice.For some reasons, WYSIWYGs sucks and complicated. so I decided to use markdown editor.
Then on the node.js server side, I have two choices to store the content, either in markdown or html, as in the cod, it firstly parse the markdown into html, then save it to the database.
app.post('/post', function(req, res){
var currentUser = req.session.user,
html = markdown.makeHtml(req.body.post),
post = new Post(currentUser.name, req.body.title, html);
post.save(function(err){
if(err){
req.flash('error', err);
return res.redirect('/');
}
req.flash('success', 'scc!');
res.redirect('/');
});
});
the advantage of saving html to database is, the app doesn't need to parse from markdown to html when loading the content. while the advantage of saving markdown to database is, when the user want to edit the content again, it is easier for the client to edit the markdown content.