Note that there are some explanatory texts on larger screens.

plurals
  1. POKramdown Markdown written Ruby integrated in Node.js
    primarykey
    data
    text
    <p><code>Middleware in my Node.js</code></p> <pre><code> functions.editorPreview = function (req, res) { var data = req.body.text; fs.writeFile(__dirname + '/message.txt', data, function (err) { if (err) throw err; child = exec('kramdown ' + __dirname + '/message.txt', function (error, stdout, stderr) { if (error) { return res.json(500, error.message); } return res.json(200, { text: stdout }); }); }); }; </code></pre> <p><code>$.post method in index.html</code></p> <pre><code>$(function() { $('#kramdown-input').keyup(function() { $.post('/editor/preview', { text: $(this).val() }, function(data) { $('#output').html(data.text); $('pre code').each(function(i, e) { hljs.highlightBlock(e) }); MathJax.Hub.Queue(['Typeset', MathJax.Hub]); }); }); $('#kramdown-input').trigger('keyup'); }); </code></pre> <p>So I'm writing my open-source CMS in Node.js called <a href="https://github.com/alicoding/spectrum" rel="nofollow">Spectrum</a>, and I was looking for a good Markdown editor and none of them that really impress me that written in JavaScript.</p> <p>I have come across this one Kramdown and I really liked it.</p> <p>I have zero knowledge about <code>Ruby</code>, but I got it to the point where it is now working with my CMS, but one problem that I'm concern here.</p> <p>The code above I have make Kramdown to interact on the preview panel, but is this really efficient? </p> <p>Because this is like we are sending a GET/POST request to the server every single time the user time a character. </p> <p>I was trying to check if there is a better way to parse the data without having to write the file and then execute <code>Kramdown</code> to parse the file then sending data back. </p> <p>Is there a better way to do this? I don't really feel good with my solution here :(</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload