如何在保留非降价HTML标签的同时将HTML转换为Markdown? [英] How to convert HTML to Markdown while retaining non-markdown HTML tags?

查看:85
本文介绍了如何在保留非降价HTML标签的同时将HTML转换为Markdown?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

I'd like to be able to take an existing HTML snippet and convert it to markdown. I've tried pandoc for this purpose:

pandoc test.html -o test.md

其中test.html看起来像这样:

where test.html looked like this:

Hello

<!-- more -->

and some more text

<h2>some heading</h2>       

结果是这样的:

Hello and some more text

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

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

Thus, it not only converts tags that have a direct meaning in markdown. It also removes tags that I would like to retain as HTML (e.g., HTML comments, iframe tags, and so on).

  • 如何将HTML中没有等价标记的所有标签保留为原始HTML,将HTML转换为Markdown?
  • 更一般而言,我如何控制HTML到降价转换的完成方式?

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

In particular, I'd be interested in command-line program options. For example, perhaps there are options that can be supplied to pandoc.

推荐答案

经过更多搜索后,我在

After a bit more searching, I read about the --parse-raw option in a thread on table parsing.

添加--parse-raw选项似乎并不会剥离非降价等效的HTML标签.

Adding the --parse-raw option seemed to not strip the non-markdown equivalent HTML tags.

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

这篇关于如何在保留非降价HTML标签的同时将HTML转换为Markdown?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆