From 09f98a17661cb38b54a6392678d908bab045b645 Mon Sep 17 00:00:00 2001 From: Marcel Greter Date: Sat, 24 Sep 2016 20:08:05 +0200 Subject: [PATCH] Update sass2scss to latest version (v1.1.0) --- include/sass2scss.h | 2 +- src/sass2scss.cpp | 17 ++++++++++++++--- 2 files changed, 15 insertions(+), 4 deletions(-) diff --git a/include/sass2scss.h b/include/sass2scss.h index bea42f95ff..5ddef10063 100644 --- a/include/sass2scss.h +++ b/include/sass2scss.h @@ -37,7 +37,7 @@ #ifndef SASS2SCSS_VERSION // Hardcode once the file is copied from // https://github.com/mgreter/sass2scss -#define SASS2SCSS_VERSION "1.0.6" +#define SASS2SCSS_VERSION "1.1.0" #endif // add namespace for c++ diff --git a/src/sass2scss.cpp b/src/sass2scss.cpp index 8c3343e044..705f9b2fe1 100644 --- a/src/sass2scss.cpp +++ b/src/sass2scss.cpp @@ -574,6 +574,12 @@ namespace Sass } } + // check if we have a BEM property (one colon and no selector) + if (sass.substr(pos_left, 1) == ":" && converter.selector == true) { + size_t pos_wspace = sass.find_first_of(SASS2SCSS_FIND_WHITESPACE, pos_left); + sass = indent + sass.substr(pos_left + 1, pos_wspace) + ":"; + } + } // terminate some statements immediately @@ -584,10 +590,15 @@ namespace Sass sass.substr(pos_left, 8) == "@charset" ) { sass = indent + sass.substr(pos_left); } // replace some specific sass shorthand directives (if not fallowed by a white space character) - else if (sass.substr(pos_left, 1) == "=" && sass.find_first_of(SASS2SCSS_FIND_WHITESPACE, pos_left) != pos_left + 1) + else if (sass.substr(pos_left, 1) == "=") { sass = indent + "@mixin " + sass.substr(pos_left + 1); } - else if (sass.substr(pos_left, 1) == "+" && sass.find_first_of(SASS2SCSS_FIND_WHITESPACE, pos_left) != pos_left + 1) - { sass = indent + "@include " + sass.substr(pos_left + 1); } + else if (sass.substr(pos_left, 1) == "+") + { + // must be followed by a mixin call (no whitespace afterwards or at ending directly) + if (sass[pos_left+1] != 0 && sass[pos_left+1] != ' ' && sass[pos_left+1] != '\t') { + sass = indent + "@include " + sass.substr(pos_left + 1); + } + } // add quotes for import if needed else if (sass.substr(pos_left, 7) == "@import")