Giter Club home page Giter Club logo

Comments (5)

RIP21 avatar RIP21 commented on July 29, 2024

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.

maitray16 avatar maitray16 commented on July 29, 2024

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.

RIP21 avatar RIP21 commented on July 29, 2024

@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.

RIP21 avatar RIP21 commented on July 29, 2024

@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.

maitray16 avatar maitray16 commented on July 29, 2024

@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)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.