Markdown textarea

Is it possible to make a <textarea> tag and have it to be compatible with markdown

What you should do is convert the markdown to html first and then show it.
If your using node.js, some good solutions for this are markdown.it (https://www.npmjs.com/package/markdown-it) which is exactly what I use.

3 Likes

@bruhdude1209, you can use a library like Marked which you can use in your browser.

<script src="https://cdn.jsdelivr.net/npm/marked/marked.min.js"></script>

Then, in your code, you can call the marked() function which converts Markdown to HTML.

function convert() {
   let md = document.querySelector('textarea').value;
   let html = marked(md);

   console.log(html) // logs the markdown to HTML converted result
}

See https://markme.glitch.me for a working demo.

1 Like

Thats really cool! I should take note of that!

1 Like