如何使用 Nokogiri 将 HTML 转换为 Markdown?
有没有办法将 HTML 转换为 Markdown 文本?
- HTML 非常简单 - 它只是一个 div 元素,里面有几个
元素。
- 可能有图像 - 我也想保留它们。
- 另外,可能有几个“内联”图像,如下所示:
这只是一个减号 - 我想用文本替换它们。
Nokogiri::XML::Element#text
几乎是我想要的东西,但它剥夺了图像。
Is there any way to transform HTML into Markdown text?
- HTML is pretty simple - it's just a div element with several
<p>
elements inside. - There may be images - I want to preserve them as well.
- Also, there may be several "inline" images like this one:
<img src='images/symbol_minus.gif' width='9' height='3' alt='−' border='0' style='vertical-align:middle;' />
which is just a minus sign - I want to replace them with text.
Nokogiri::XML::Element#text
is almost something that I want, but it strips off images.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
正如@Konrads建议的,有一个重复的条目这里< /a>.但是,该条目的答案中给出的链接已损坏。
我用谷歌搜索了一下,发现一些分叉幸存下来: https://github.com/tomkrush/反向降价,https://gist.github.com/788039。
如果这些分叉失效了,只需谷歌搜索“反向降价”即可。你一定会找到一些有活力且有效的东西。
As @Konrads suggested, there is a duplicate entry here. However, the link which is given in the answer on that entry is broken.
I've googled a bit more and found that some forks survived: https://github.com/tomkrush/reverse-markdown, https://gist.github.com/788039.
If these forks become dead, just google for "reverse markdown". You will definitely find something that is alive and working.