首页 文章

如何在保留非降价HTML标记的同时将HTML转换为Markdown?

提问于
浏览
14

我希望能够获取现有的HTML代码段并将其转换为markdown . 我为此尝试过pandoc:

pandoc test.html -o test.md

test.html看起来像这样:

Hello

<!-- more -->

and some more text

<h2>some heading</h2>

结果如下:

Hello and some more text

some heading
------------

因此,它不仅可以转换在降价时具有直接含义的标签 . 它还会删除我想要保留为HTML的标记(例如,HTML注释, iframe 标记等) .

  • 如何将HTML转换为markdown,使任何没有markdown等效标记的标记保留为原始HTML?

  • 更一般地说,如何控制HTML到降价转换的方式?

特别是,我对命令行程序选项感兴趣 . 例如,也许有可以提供给pandoc的选项 .

1 回答

  • 19

    经过一番搜索,我在thread on table parsing中读到了 --parse-raw 选项 .

    添加 --parse-raw 选项似乎不会删除非markdown等效的HTML标记 .

    pandoc test.html -o test.md --parse-raw
    

相关问题