【问题标题】:Indentation in emacs for html with inline javascript带有内联javascript的html在emacs中的缩进
【发布时间】:2017-01-30 14:40:01
【问题描述】:

这大概是我拥有的那种代码。

<body>
<p>
...
</p>

<script>
function func()
{
...
for(...)
{
...
}
}
</script>

<p> ... </p>

</body>

HTML 本身可以正确缩进,但是当我放入 javascript 时,一切都搞砸了。

我该如何处理?

【问题讨论】:

    标签: javascript html emacs formatting indentation


    【解决方案1】:

    您可以尝试多种模式中的一种:

    他们的目标是在同一个缓冲区中同时拥有多个模式,特别是 html 和 javascript。

    【讨论】:

      【解决方案2】:

      我倾向于在我的脚本标签之间添加空行,然后切换到 javascript 模式。带有空白行填充的 html 看起来像这样

      <script type="text/javascript">
      
         //some javascript
      
      </script>
      

      这似乎允许正确的着色和缩进。我个人也喜欢使用js3-mode,因为它比 emacs 的默认 javascript 样式添加了更多功能。

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2016-08-08
        • 2013-06-08
        • 1970-01-01
        • 1970-01-01
        • 2015-01-14
        • 1970-01-01
        相关资源
        最近更新 更多