2017-02-10 65 views
0

我有一個小型web應用程序,最終輸出html和css代碼,但它需要重新輸入,尤其是css。我發現這個庫:https://github.com/beautify-web/js-beautify 但它似乎並沒有工作。例如,其中一個文件說:使用Javascript縮進HTML和CSScode

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> 

什麼想法?

+0

請提供一個最小,完整和可驗證的示例:http://stackoverflow.com/help/mcve – Connum

回答

0

the source code

// If we're running a web page and don't have either of the above, add our one global 
window.html_beautify = function(html_source, options) { 
    return style_html(html_source, options, window.js_beautify, window.css_beautify); 
}; 

全球叫html_beautify,不style_html(這是僅在內部使用的功能)。

+0

我仍然在調用該函數時遇到與以前相同的錯誤。 – user1563232

+0

@ user1563232 - 我沒有:http://jsbin.com/fiquvu/1/edit?html,console,output – Quentin