Beispiel #1
0
  void Inspect::operator()(Import* import)
  {
    if (!import->urls().empty()) {
      append_token("@import", import);
      append_mandatory_space();

      if (String_Quoted* strq = dynamic_cast<String_Quoted*>(import->urls().front())) {
        strq->is_delayed(false);
      }

      import->urls().front()->perform(this);
      if (import->media_queries()) {
        append_mandatory_space();
        import->media_queries()->perform(this);
      }
      append_delimiter();
      for (size_t i = 1, S = import->urls().size(); i < S; ++i) {
        append_mandatory_linefeed();
        append_token("@import", import);
        append_mandatory_space();

        if (String_Quoted* strq = dynamic_cast<String_Quoted*>(import->urls()[i])) {
          strq->is_delayed(false);
        }

        import->urls()[i]->perform(this);
        if (import->media_queries()) {
          append_mandatory_space();
          import->media_queries()->perform(this);
        }
        append_delimiter();
      }
    }
  }
Beispiel #2
0
 void Emitter::append_special_linefeed()
 {
   if (output_style() == COMPACT) {
     append_mandatory_linefeed();
     for (size_t p = 0; p < indentation; p++)
       append_string(ctx ? ctx->indent : "  ");
   }
 }
Beispiel #3
0
 // append some white-space only text
 void Emitter::append_wspace(const std::string& text)
 {
   if (text.empty()) return;
   if (peek_linefeed(text.c_str())) {
     scheduled_space = 0;
     append_mandatory_linefeed();
   }
 }
Beispiel #4
0
 void Emitter::append_optional_linefeed()
 {
   if (in_declaration && in_comma_array) return;
   if (output_style() == COMPACT) {
     append_mandatory_space();
   } else {
     append_mandatory_linefeed();
   }
 }
Beispiel #5
0
 void Emitter::append_delimiter()
 {
   scheduled_delimiter = true;
   if (output_style() == COMPACT) {
     if (indentation == 0) {
       append_mandatory_linefeed();
     } else {
       append_mandatory_space();
     }
   } else if (output_style() != COMPRESSED) {
     append_optional_linefeed();
   }
 }
Beispiel #6
0
 void Output::operator()(Comment* c)
 {
   std::string txt = c->text()->to_string(opt);
   // if (indentation && txt == "/**/") return;
   bool important = c->is_important();
   if (output_style() != COMPRESSED || important) {
     if (buffer().size() == 0) {
       top_nodes.push_back(c);
     } else {
       in_comment = true;
       append_indentation();
       c->text()->perform(this);
       in_comment = false;
       if (indentation == 0) {
         append_mandatory_linefeed();
       } else {
         append_optional_linefeed();
       }
     }
   }
 }