Skip to content

refactor formatter to provide format() method and strip comments when format=compressed#61

Closed
robocoder wants to merge 1 commit intoleafo:masterfrom
robocoder:formatter
Closed

refactor formatter to provide format() method and strip comments when format=compressed#61
robocoder wants to merge 1 commit intoleafo:masterfrom
robocoder:formatter

Conversation

@robocoder
Copy link
Collaborator

No description provided.

…shall format(); let's also strip comments when output format=compressed (see issue #60)
@clue
Copy link
Contributor

clue commented Mar 17, 2013

Thanks for the PR, but I'd like to vote against using regular expressions to remove comments.

My current compress working branch is a bit of a mess, but I'd rather go for a similar approach that introduces a new additional API to the formatter to remove comments from the output.

I'll see if I can send in some dedicated PRs as well.

@robocoder
Copy link
Collaborator Author

I'll revert my change for issue 60 given that scssphp isn't compatible with the ruby version to begin with:

/* comment */
a {
    /* comment */
    color: red; /* comment */
    /* comment */
}
/* comment */

/*! comment */
b {
    /*! comment */
    color: red; /*! comment */
    /*! comment */
}
/*! comment */

/*
 * multi-line comment
 */
c {
    /*
     * multi-line comment
     */
    color: red; /*
                 * multi-line comment
                 */
    /*
     * multi-line comment
     */
}
/*
 * multi-line comment
 */

/*!
 * multi-line comment
 */
d {
    /*!
     * multi-line comment
     */
    color: red; /*!
                 * multi-line comment
                 */
    /*!
     * multi-line comment
     */
}
/*!
 * multi-line comment
 */

// comment
e {
    // comment
    color: red; // comment
    // comment
}
// comment

scss produces:

/* comment */a{/* comment *//* comment */color:red;/* comment *//*! comment */}b{/*! comment *//*! comment */color:red;/*! comment *//*
 * multi-line comment
 */}c{/*
                 * multi-line comment
                 *//*
     * multi-line comment
     */color:red;/*
 * multi-line comment
 *//*!
 * multi-line comment
 */}d{/*!
                 * multi-line comment
                 *//*!
     * multi-line comment
     */color:red;/*!
 * multi-line comment
 */}e{color:red;}

ruby scss (3.1.15 and 3.2.7):

a{color:red}/* comment */b{/* comment */;color:red;/* comment */;/* comment */}/* comment */c{color:red}/*
 * multi-line comment
 */d{/*
 * multi-line comment
 */;color:red;/*
 * multi-line comment
 */;/*
 * multi-line comment
 */}/*
 * multi-line comment
 */e{color:red}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants