Comments (5)
Hmmm. You mean you put some markdown into an editor, then you click on preview and you want to copy the HTML code that will be generated in preview somehow?
I think you can use ref to access editor instance and obtain it somehow.
But I think you better should use some plain markdown compilers instead and not an editor itself.
Maybe something here may help you, but not sure.
Editor preview behaviour override implementation in my blog
Post helper function that renders markdown to HTML
from react-simplemde-editor.
Thanks, I'll take a look at it. Basically what I am trying to do is if I have for example the following markdown
* Item1
* Item2
* Item3
I want to get its corresponding HTML -
<ul>
<li>Item1</li>
<li>Item2</li>
<li>Item3</li>
</ul>
Assuming that internally the markdown would have to be compiled to HTML for the preview tab.
from react-simplemde-editor.
@maitray16 compilers that I use in the examples and many others (google for them) is a way better approach than trying to steal HTML from the preview HTML.
At the end of the day, I assume, simplemde
has some markdown parser inside that does the same thing. That maybe makes sense, to save some bytes, of the bundle (hence not bring two parsers to the project), but if that is the case I would rather ask the author of easymde
to extract markdown parser to some module, so you can import its parser as a function and generate HTML that you are looking for. Otherwise, use one of the available markdown to HTML/JSX parsers.
I'm closing this since it's answered I think :)
from react-simplemde-editor.
@maitray16 here we go. Actually, they DO use a separate dependency for markdown parsing and it's marked
Feel free to import it and use outside of the easymde
https://github.com/markedjs/marked
Do not bring additional dependency for no reason ;)
from react-simplemde-editor.
@RIP21 Thanks a lot for the help and swift response. The helper function you posted seems to working fine for my use case, so will be using that rather than adding another dependency, but its cool to know easymde's - parsing lib.
from react-simplemde-editor.
Related Issues (20)
- Not working internal link in README.md HOT 2
- Custom toolbar button to open a separate React component (or any kind of div input from where I can accept input) HOT 3
- How can I disable markdown AutoComplete feature? HOT 1
- lost focus when using onChange with nextjs HOT 7
- lineNumbers option prevents backspace of empty line on Mobile HOT 2
- TypeError `_react.useMemo` is not a function HOT 3
- how to make this RTL ? HOT 7
- Cursor randomly jumps before first character when typing HOT 1
- can't use options when use getCodemirrorInstance to change state HOT 1
- window is not defined HOT 3
- Preview not working (showing undefined) HOT 5
- You may need an additional loader to handle the result of these loaders. HOT 4
- toolbar does not display on MacOS HOT 2
- Enforce maxLength attribute HOT 3
- Editor fetches assets from external sources HOT 1
- Multiline Code Block Highlighting in Edit Mode HOT 1
- Function components cannot be given refs. Attempts to access this ref will fail. Did you mean to use React.forwardRef()? HOT 2
- has fetching error with react query HOT 3
- How to add thin blue border upon selecting the editor?
- Tailwind Reset HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from react-simplemde-editor.