func (self *jsbeautifier) print_token_line_indentation(current_token tokenizer.Token) { if self.output.just_added_newline() { line := self.output.current_line if self.options["keep_array_indentation"].(bool) && self.is_array(self.flags.mode) && current_token.WantedNewLine() { line.push(current_token.WhitespaceBefore()) self.output.space_before_token = false } else if self.output.set_indent(self.flags.indentation_level) { self.flags.line_indent_level = self.flags.indentation_level } } }
func (self *jsbeautifier) handle_block_comment(current_token *tokenizer.Token) { lines := strings.Split(strings.Replace(current_token.Text(), "\x0d", "", -1), "\x0a") javadoc := true starless := true last_indent := current_token.WhitespaceBefore() last_indent_length := len(last_indent) self.print_newline(false, true) if len(lines) > 1 { for _, l := range lines[1:] { trims := strings.TrimSpace(l) if trims == "" || trims[0] != '*' { javadoc = false break } } if !javadoc { for _, l := range lines[1:] { trims := strings.TrimSpace(l) if trims != "" && !strings.HasPrefix(l, last_indent) { starless = false break } } } } else { javadoc = false starless = false } self.print_token(*current_token, lines[0]) for _, l := range lines[1:] { self.print_newline(false, true) if javadoc { self.print_token(*current_token, " "+strings.TrimSpace(l)) } else if starless && len(l) > last_indent_length { self.print_token(*current_token, l[last_indent_length:]) } else { self.output.add_token(l) } } self.print_newline(false, true) }