我有一个小型的web应用程序,在最后输出html和css代码,但是有必要重新创建输出,特别是css。我找到了一个库:https://github.com/beautify-web/js-beautify,但它似乎不起作用。例如,其中一个文件说:
Usage:
style_html(html_source);
style_html(html_source, options);但我得到的只是一个错误: style_html没有定义。我已经包含了一组脚本标记,正如它在用法部分中所说的那样。
示例:
<script src="https://cdnjs.cloudflare.com/ajax/libs/js-beautify/1.6.8/beautify.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/js-beautify/1.6.8/beautify-css.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/js-beautify/1.6.8/beautify-html.min.js"></script>
<script> style_html("asdf");</script>有什么想法吗?
发布于 2017-02-10 10:26:37
请参阅源代码
//如果我们正在运行一个网页,并且没有上述任何一个,那么添加我们的一个全局window.html_beautify =函数(html_source,options) {返回style_html(html_source,options,window.js_beautify,window.css_beautify);};
全局名为html_beautify,而不是style_html (这是一个仅在内部使用的函数)。
https://stackoverflow.com/questions/42156756
复制相似问题