表单: RailsNotes
用户: dreamable
创建日期: 2021-04-07 05:30:37 UTC
更新日期: 2021-04-07 05:42:27 UTC
引用:(Table ID 3, Record ID 34)

标题 :
Convert HTML to Markdown
笔记 :

guide

  1. html2markdown: pretty old, don't know how to use
  2. reverse_markdown

    input  = '<strong>feelings</strong>'
    result = ReverseMarkdown.convert input
    result.inspect # " **feelings** "
    
  3. kramdown

    html = 'How to convert <b>HTML</b> to <i>Markdown</i> on <a href="http://stackoverflow.com">Stack Overflow</a>.'
    document = Kramdown::Document.new(html, :html_to_native => true)
    document.to_kramdown
    # "How to convert **HTML** to *Markdown* on [Stack Overflow][1].\n\n\n\n[1]: http://stackoverflow.com\n"
    

    The result is :
    How to convert HTML to Markdown on Stack Overflow.

标签: