为什么不'我的ace.js美化程序没有按预期工作吗



每当我调用beautityCode((时,代码的格式都会发生变化,但它都在一行中,带有不同的空格。。。这是怎么回事,还是我做错了什么?另外,我该如何解决这个问题?

代码:

var beautify = ace.require("ace/ext/beautify"); // get reference to extension
var editor = ace.edit("editor");
// This function is called to beautify the editor's code
function beautifyCode()
{
beautify.beautify(editor.getSession());
}

输入:

<html>
<head>
<title>Hello World</title>
</head>
<body>
<form action="shyam.php">
<input name="name" value="Shyam"/>
<input type="submit"/>
</form>
</body>
</html>

输出:

<html><head> <title>Hello World</title></head><body>  <form action="shyam.php">    <input name="name" value="Shyam"/>    <input type="submit"/>  </form></body></html>

如果需要更多信息,请告诉我。

我在尝试为编辑器实现自动完成时解决了这个问题。

您可能还需要导入其他脚本,以确保美化程序正常工作。

<script src="https://cdnjs.cloudflare.com/ajax/libs/ace/1.4.12/ext-language_tools.js"></script>

上面的脚本为我解决了这个问题。

来源:ACE编辑器中的自动完成

相关内容

最新更新