无法在SASS中编译评论

时间:2012-11-24 16:21:16

标签: sass

我正在使用Mac 10.7.2,Ruby 1.9.3和SASS 3.2.1。我正在尝试在多级CSS之间获得多行评论和评论。我知道我们可以在SASS中实现多行注释,如下所示:

SASS

/*
 Multiline
 comments
 goes here

CSS

/* Multiline
 * comments
 * goes here */

但我在我的样式表中使用不同的评论来突出/识别我的CSS中的多个级别和不同类型的东西,其中两个是:

我的样式表从下面的评论开始:

/***************************************************************

Theme Name: Theme name goes here
Theme URI: Theme URL goes here
Description: Discription related to theme will goes here
Version: 1.1
Author: Author name goes here
Author URI: Authour url goes here

***************************************************************/

我的申请索引评论如下:

/*
---------------------------------------
---------------------------------------
--- Table of Contents:              ---
---                                 ---
--- 1. HEADER                       ---
--- -1.1 Navigation Bar             ---
---                                 ---
---                                 ---
--- 2. MAIN SECTION                 ---
--- -2.1 Home page                  ---
--- --2.1.1 Sections                ---
--- ---2.1.1.1 sub section          ---
---                                 ---
---                                 ---
--- 3. FOOTER                       ---
---------------------------------------
---------------------------------------
*/

我可以找到更接近它的评论但是,不能完全按照编译的CSS评论

SASS

/*
  ---------------------------------------
  ---------------------------------------
  --- Table of Contents:              ---
  ---                                 ---
  --- 1. DEFAULT ELEMENTS             ---
  --- 2. LINKS                        ---
  --- 3. TABLE                        ---
  --- 4. FORM                         ---
  --- 5. GLOBAL CLASSES               ---
  ---------------------------------------
  ---------------------------------------

CSS

/*  ---------------------------------------
 *  ---------------------------------------
 *  --- Table of Contents:              ---
 *  ---                                 ---
 *  --- 1. DEFAULT ELEMENTS             ---
 *  --- 2. LINKS                        ---
 *  --- 3. TABLE                        ---
 *  --- 4. FORM                         ---
 *  --- 5. GLOBAL CLASSES               ---
 *  ---------------------------------------
 *  --------------------------------------- */

还有一段时间我们需要多层次的评论

.firstLavel
  background: #f00
  /* comeent goes here before second level */
  .secondLavel
    font-size:  20
    color:  #ddd
  /* comeent goes here before third level
  .secondLavel
    font-size:  70
    color:  #ded

但我得到了结果:

  background: red;
  /* comeent goes here before second level */
  /* comeent goes here before third level */ }
  .firstLavel .secondLavel {
    font-size: 20;
    color: #dddddd; }
  .firstLavel .secondLavel {
    font-size: 70;
    color: #ddeedd; }

应该是:

.firstLavel {
  background: red; }

  /* comment goes here before second level */
  .firstLavel .secondLavel {
    font-size: 20;
    color: #dddddd; }

  /* comment goes here before third level */ 
  .firstLavel .secondLavel {
    font-size: 70;
    color: #ddeedd; }

1 个答案:

答案 0 :(得分:1)

Sass使用一种算法进行编译,该算法递归渲染CSS树的所有子节点,从端点开始(没有更深层次的端点)。 由于这种算法,当孩子不是终点时,不可能在孩子面前设置评论:评论永远不会有更深层次。设置评论的唯一方法是将评论设置为节点的子项。

澄清一下,请考虑这棵树:

root
  child1 
    child1.1
      /* comment on 1.1*/
      child1.1.1
    child1.2
  child2
  /* comment on 2 */
  child3
    /* comment on 3*/
    child3.1
  child4

渲染它将首先导致没有子节点的条目,然后是更深入的条目。 CSS的顺序是:

root
  child2
  /* comment on 2 */
  child4
  child1
    child1.2
    child1.1
      /* comment on 1.1 */
      child1.1.1
  child3
    /* comment on 3 */
    child3.1

使用的算法是BSF,其队列将端点放在第一位

相关问题