[英]How to format XML code in Ace Editor?
I am using ACE Editor to display xml content on my web page. 我正在使用ACE Editor在我的网页上显示xml内容。 I want to format the xml code in Editor.
我想在Editor中格式化xml代码。
Can Any one tell me how to do this ? 可以任何人告诉我该怎么做?
XML Code formatting is not specified in Ace itself, as it's just an editor. Ace本身没有指定XML代码格式,因为它只是一个编辑器。 Use any of the answers in this question to prettify the code.
使用此问题中的任何答案来美化代码。
var code = ace.getSession().getValue();
// prettify
ace.getSession().setValue(code);
There are numerous modes included in the package and the Wiki at github will tell you how to implement it. 包中包含许多模式,github上的Wiki将告诉您如何实现它。 Something like this:
像这样的东西:
var Mode = require('ace/mode/xml').Mode;
editor.getSession().setMode(new Mode());
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.