2016-04-22 19 views
0

我試圖通過prettyprint的blockly自定義安裝生成的一些代碼。生成的代碼將是xml,但問題是有一次,我嘗試使用谷歌美化代碼(而不是唯一一個,與higlight.js相同的問題)的代碼突出顯示代碼不是higlighted,我試圖谷歌,但所有的解決方案doesn似乎不適用於我的問題。Prettyprint XML不higlighting

這是我的導入美化庫:

這是代碼:

<script language="javascript"> 
    function showCode() { 
     var code = Blockly.JavaScript.workspaceToCode(workspace); 
     var element = document.getElementById("codeview"); 
     var pre_element = document.createElement("pre"); 
     pre_element.setAttribute("class", "prettyprint"); 
     pre_element.setAttribute("id", "code_container"); 
     pre_element.textContent = Blockly.JavaScript.workspaceToCode(workspace); 
     //pre_element.appendChild(code_element); 
     element.appendChild(pre_element); 
     //alert(code); 
     } 
</script> 

的生成的代碼的示例之一是:

<property name='default' /> 
<property name='default' /> 
<property name='default' /> 

現在我不'不知道問題是我需要在我正在優化的代碼片段中指定文檔類型,或者它只是其他內容,例如我可能編輯逃脫它?都?

應用程序託管在一個Spring應用程序啓動。 Blockly正常工作,但問題似乎只有語法更高。

有什麼想法?

回答

0

我想你不叫prettyprint()功能在你的HTML的<body>

撥打prettyprint()後追加pre_element

相關問題