【发布时间】:2021-10-28 16:44:37
【问题描述】:
我可以使用libxml-parse-html-region 函数解析html。
但我不知道如何将其渲染回 HTML。
shr.el 函数似乎根本没有做任何事情。
我尝试的是这个。 我写了一个 HTML 字符串
<html>
<head></head>
<body></body>
</html>
并使用libxml-parse-html-region 函数对其进行解析,并使用dom-pp 函数进行漂亮的打印。像这样
(dom-pp (libxml-parse-html-region (region-beginning) (region-end))))
这导致以下 lisp 表示
(html nil
(head nil)
(body nil))
被插入缓冲区。这没关系。
下一步不起作用。
我想渲染这个嘴唇表示
回到 HTML 表示。
我尝试将(shr-render-region) 与(region-begining) 和(region-end) 函数调用一起用作参数,就像这样
(shr-render-region (region-beginning) (region-end))
我标记一个区域并交互调用上述代码。
但是,据我所知,这并没有做任何事情。缓冲区中没有插入任何内容,shr-render-region 不返回字符串。
那么我如何将 lisp 表示返回到 HTML 代码中呢?
更新 1:
shr-render-region 将 HTML 代码呈现为格式化文本,因此无法正常工作。
更新 2:
shr.el 函数不起作用,看起来它们用于在 emacs 缓冲区中呈现 HTML,但不呈现代码(html 字符串)。
【问题讨论】: