【问题标题】:htmlclean grunt task to not supress spaces separated by tagshtmlcleaner grunt 任务不抑制由标签分隔的空格
【发布时间】:2015-02-09 14:58:06
【问题描述】:

我正在使用 htmlclean grunt 任务 (https://github.com/anseki/grunt-htmlclean),它正在正确地完成工作。但是,删除某些空格会导致显示问题,例如:

                    <span>
                        to <a></a>
                    </span> 

被清理到:

                    <span>to<a></a></span>  

“to”前后的空格非常重要。我已经查看了任务的选项,但是我看不到如何配置任务以尊重这些空间。

【问题讨论】:

    标签: html node.js gruntjs


    【解决方案1】:

    htmlclean 任务允许使用protect 选项来防止从匹配的字符串中去除空格。您可以设置一个正则表达式匹配一个单词后跟一个开始标签,例如

    grunt.initConfig({
      htmlclean: {
        options: {
          protect: /\w(\s+)</g
        }
      }
    });
    

    有关选项,请参阅https://github.com/anseki/grunt-htmlclean#overview

    【讨论】:

      猜你喜欢
      • 2015-10-31
      • 2023-03-28
      • 1970-01-01
      • 2021-01-20
      • 1970-01-01
      • 1970-01-01
      • 2013-05-14
      • 1970-01-01
      • 2015-04-05
      相关资源
      最近更新 更多