simplemde-markdown-editor
simplemde-markdown-editor copied to clipboard
How to render markdown text after saving it in database
I'm using this in my application.
This is working fine as data is saving to database with markdown syntax.
Now, I want to render this data on a separate file.
How to render the data on view?
this is not an issue of this editor, its your job to find a solution to render md-files - there are many solutions out there.
I also need to render data, and I don't want to use a separate solution that duplicates exactly what this plugin does, as that both duplicates the code and might not even support the same subset of Markdown that this does. Exposing the rendered text would be a very nice feature.
It's up to the back-end framework , for example in django I use markdown before rendering the data, so there will be a way in your language or framework.
My language or framework is vanilla JS. Why should I have to load a second library when I already have one loaded?
I don't get all this editor does is append the formatting codes(** ,#, etc ) it's up-to the back-end language to store it as it is and display it with a markdown .
The editor has a built-in markdown renderer, which it uses to display markdown as HTML. We're arguing that that renderer should be exposed so we don't have to load a whole other renderer when there is already one included in SimpleMDE.
For anyone reading this, you can currently use the built-in renderer simply by calling:
simplemde.markdown(simplemde.value)
SimpleMDE uses Marked (https://marked.js.org/) as a renderer internally, and already includes that in dependencies. So I see it pretty logical to use that library.
To follow on from the post by @KristobalJunta here is the code you need
import * as marked from "marked";
var html = marked(input);