Convert HTML back to Markdown for editing in wmd

前端 未结 5 2012
抹茶落季
抹茶落季 2020-12-05 15:04

I am curious to do what happens when you edit a post on this site.

I am using wmd for my markdown editor, of course when I goto edit, I get the HTML it generated not

相关标签:
5条回答
  • 2020-12-05 15:22

    I have just know Markdownify (formerly html2text.php) that "writes texts in Markdown and save them in HTML. You won’t need a copy of the original Markdown input, since Markdownify can convert the saved HTML back to Markdown. And because page impressions are far more often than write actions, this gives you a simple way to increase your page’s performance. Another benefit for a CMS or similar software is that now only one format of text is saved — HTML. The user can now choose wether to write texts in plain HTML or use a full fledged Wysiwyg editor. And of course he can write in Markdown!"

    0 讨论(0)
  • 2020-12-05 15:23

    Open source html to markdown converters written in JavaScript:

    • domchristie/to-markdown

      MarkItDown: retro-convert rich text to Markdown. Online Try.

    • bambax/MarkItDown

      An HTML to Markdown converter written in JavaScript. Online Try.

    0 讨论(0)
  • 2020-12-05 15:31

    Look at the optionsExample.html in your WMD distribution. There's an option to send the result to the server as Markdown.

    0 讨论(0)
  • 2020-12-05 15:32

    If you want to convert HTML to Markdown in batch, I can recommend Aaron Swartz’s html2text.py Python script with which you can just:

    cat my.html | python html2text.py # outputs markdown
    

    Edit 05/11/12: Nowadays I use Pandoc which is like a swiss-knife for text documents. Can convert html<>textile<>markdown<>epub<>pdf<>latex, etc.

    0 讨论(0)
  • 2020-12-05 15:40

    As Chris notes, you can send Markdown to the server so you can store it there as such. I started trying to use MarkdownJ to convert on the server-side, but it doesn't (at the time of this writing) convert images to HTML correctly and so I ended up going with Java 6 Scripting: Rhino engine + showdown.js. Since WMD uses showdown.js you get the same Markdown-to-HTML transformation. Works like a charm (for Java 6, anyway).

    0 讨论(0)
提交回复
热议问题