javascript - 如何像在编辑器中一样使用适当的标签颜色样式和缩进显示 html 源代码

标签 javascript html css iframe

我想显示在 iframe 中呈现的 html 文件的源代码。源代码必须以正确的标签颜色和缩进显示,就像在 sublime 等编辑器中一样。 expected result 我得到了在 iframe 中呈现的文件的源代码

    var sourceCode = '<!DOCTYPE html>\n\<html lang="en-US">\n';
    sourceCode  += $('#iFrame').contents().find("html").html();
    sourceCode += '\n</html>';
    sourceCode = sourceCode.replace(/</g, "&lt;").replace(/>/g, "&gt;");
    sourceCode = "<pre>"+sourceCode+"</pre>";

但这给了我一个预先格式化的文本作为my result 我该怎么做。

最佳答案

在 github 上创建一个要点并嵌入它?

关于javascript - 如何像在编辑器中一样使用适当的标签颜色样式和缩进显示 html 源代码,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/41299505/

相关文章:

javascript - 如何取消 HTTP fetch() 请求?

jquery - 如何添加偏移量以更快地触发 jQuery 函数?

javascript - 使用 iText 在 pdf 的某些位置上进行 Java Stamp

javascript - 使用 jquery 触发 .has-error 类的 Bootstrap

CSS 'You have no color set [...]' 警告

caching - 如何防止 Facebook 点赞按钮延迟我网站上的加载?

c# - asp.net-HTML 控件中的本地化

html - 使用宽度使两列相等

asp.net - 我如何更改 DataPager 控件中第一个和最后一个按钮的位置

javascript - 循环插件幻灯片未执行,但图像显示在彼此上方