/* Calculate the CSS rules that indent title spans.
504212
function renderLevelCss(
		containerId,
		depth,
		levelOfs,
		lineOfs,
		labelOfs,
		measureUnit
	) {
		var i,
			prefix = "#" + containerId + " span.fancytree-level-",
			rules = [];

		for (i = 0; i < depth; i++) {
			rules.push(
				prefix +
					(i + 1) +
					" span.fancytree-title { padding-left: " +
					(i * levelOfs + lineOfs) +
					measureUnit +
					"; }"
			);
		}
		// Some UI animations wrap the UL inside a DIV and set position:relative on both.
		// This breaks the left:0 and padding-left:nn settings of the title
		rules.push(
			"#" +
			containerId +
			" div.ui-effects-wrapper ul li span.fancytree-title, " +
			"#" +
			containerId +
			" li.fancytree-animating span.fancytree-title " + // #716
				"{ padding-left: " +
				labelOfs +
				measureUnit +
				"; position: static; width: auto; }"
		);
		return rules.join("\n");
	}
963910
function(css) {
  css = css
    // remove comments
    .replace(/\/\*[^\0]*?\*\//g, '')
    // trim space before characters
    .replace(/\s+({|})/g, '$1')
    // trim space after characters
    .replace(/(;|,|:|{|}|^)\s+/g, '$1')
    // trim combinators
    .replace(/\s+(>|\+|~)\s+/g, '$1')
    // remove escaped newlines and spaces
    .replace(/\\\r?\n\s+/g, '')
    // remove trailing semicolons in rules
    .replace(/;(})/g, '$1');

  return css;
}
988029
function(content, pos, isBackward) {
			// possible case: editor reported that current syntax is
			// CSS, but it’s actually a HTML document (either `style` tag or attribute)
			var offset = 0;
			var subrange = this.styleTagRange(content, pos);
			if (subrange) {
				offset = subrange.start;
				pos -= subrange.start;
				content = subrange.substring(content);
			}

			var rules = this.findAllRules(content);
			var ctxRule = this.matchEnclosingRule(rules, pos);

			if (ctxRule) {
				return ctxRule.shift(offset);
			}

			for (var i = 0, il = rules.length; i < il; i++) {
				if (rules[i].start > pos) {
					return rules[isBackward && i > 0 ? i - 1 : i].shift(offset);
				}
			}
		}
248670
function endRule(event){
            if (textIndent){
                reporter.report("Negative text-indent doesn't work well with RTL. If you use text-indent for image replacement explicitly set direction for that item to ltr.", textIndent.line, textIndent.col, rule);
            }
        }
215465
function validateIndent() {
            /**
             * Check whether the line start is in template tag.
             * @param {number} line The line.
             * @returns {boolean} `true` if the line start is in template tag.
             */
            function inTemplateTag(line) {
                if (line <= 1) {
                    return false
                }
                const lineStartIndex = sourceCode.getIndexFromLoc({
                    line,
                    column: 0,
                })
                return microTemplateService.inTemplateTag(lineStartIndex - 1)
            }

            /**
             * Define the function which fixes the problem.
             * @param {number} line The number of line.
             * @param {string} actualText The actual indentation text.
             * @param {ExpectedIndent} expectedIndent The expected indentation info.
             * @returns {function} The defined function.
             */
            function defineFix(line, actualText, expectedIndent) {
                return fixer => {
                    const start = sourceCode.getIndexFromLoc({
                        line,
                        column: 0,
                    })
                    const indent = expectedIndent.indentText
                    return fixer.replaceTextRange(
                        [start, start + actualText.length],
                        indent
                    )
                }
            }

            /**
             * Validate base point indentation.
             * @param {number} line The number of line.
             * @param {string} actualText The actual indentation text.
             * @param {ExpectedIndent} expectedIndent The expected indent.
             * @returns {void}
             */
            function validateBaseIndent(line, actualText, expectedIndent) {
                const expectedBaseIndentText = expectedIndent.baseIndentText
                if (
                    expectedBaseIndentText &&
                    (actualText.length < expectedBaseIndentText.length ||
                        !actualText.startsWith(expectedBaseIndentText))
                ) {
                    context.report({
                        loc: {
                            start: { line, column: 0 },
                            end: {
                                line,
                                column: actualText.length,
                            },
                        },
                        messageId: actualText
                            ? "unexpectedBaseIndentation"
                            : "missingBaseIndentation",
                        data: {
                            expected: JSON.stringify(expectedBaseIndentText),
                            actual: actualText
                                ? JSON.stringify(
                                      actualText.slice(
                                          0,
                                          expectedBaseIndentText.length
                                      )
                                  )
                                : "",
                        },
                        fix: defineFix(line, actualText, expectedIndent),
                    })
                    return false
                }
                return true
            }

            offsets.forEach((value, line) => {
                if (!inTemplateTag(line)) {
                    return
                }
                if (!getLineText(line).trim()) {
                    // empty line
                    return
                }
                const actualText = value.actualText
                const expectedIndent = getExpectedIndent(line)
                if (!expectedIndent) {
                    return
                }
                if (!validateBaseIndent(line, actualText, expectedIndent)) {
                    return
                }
                const expectedBaseIndent = expectedIndent.baseIndentText.length

                const actualRelativeText = actualText.slice(expectedBaseIndent)

                for (let i = 0; i < actualRelativeText.length; ++i) {
                    if (actualRelativeText[i] !== options.indentChar) {
                        context.report({
                            loc: {
                                start: { line, column: expectedBaseIndent + i },
                                end: {
                                    line,
                                    column: expectedBaseIndent + i + 1,
                                },
                            },
                            messageId: "unexpectedIndentationCharacter",
                            data: {
                                expected: JSON.stringify(options.indentChar),
                                actual: JSON.stringify(actualRelativeText[i]),
                            },
                            fix: defineFix(line, actualText, expectedIndent),
                        })
                        return
                    }
                }

                const actualRelativeIndent = actualRelativeText.length

                if (actualRelativeIndent !== expectedIndent.indent) {
                    context.report({
                        loc: {
                            start: { line, column: expectedBaseIndent },
                            end: { line, column: actualText.length },
                        },
                        messageId: expectedBaseIndent
                            ? "unexpectedRelativeIndentation"
                            : "unexpectedIndentation",
                        data: {
                            expectedIndent: expectedIndent.indent,
                            actualIndent: actualRelativeIndent,
                            unit,
                            expectedIndentPlural:
                                expectedIndent.indent === 1 ? "" : "s",
                            actualIndentPlural:
                                actualRelativeIndent === 1 ? "" : "s",
                        },
                        fix: defineFix(line, actualText, expectedIndent),
                    })
                }
            })
        }
997319
function() {
        var style = this._element.style,
            coord = this.__coord || [0, 0, 0, 0],
            co = {
                x: coord[0],
                y: coord[1],
                w: coord[2],
                h: coord[3]
            },
            prefix = Crafty.support.prefix,
            trans = [];

        if (this._cssStyles.visibility !== this._visible) {
            this._cssStyles.visibility = this._visible;
            if (!this._visible) {
                style.visibility = "hidden";
            } else {
                style.visibility = "visible";
            }
        }

        //utilize CSS3 if supported
        if (Crafty.support.css3dtransform && !this.avoidCss3dTransforms) {
            trans.push(
                "translate3d(" + ~~this._x + "px," + ~~this._y + "px,0)"
            );
        } else {
            if (this._cssStyles.left !== this._x) {
                this._cssStyles.left = this._x;
                style.left = ~~this._x + "px";
            }
            if (this._cssStyles.top !== this._y) {
                this._cssStyles.top = this._y;
                style.top = ~~this._y + "px";
            }
        }

        if (this._cssStyles.width !== this._w) {
            this._cssStyles.width = this._w;
            style.width = ~~this._w + "px";
        }
        if (this._cssStyles.height !== this._h) {
            this._cssStyles.height = this._h;
            style.height = ~~this._h + "px";
        }
        if (this._cssStyles.zIndex !== this._z) {
            this._cssStyles.zIndex = this._z;
            style.zIndex = this._z;
        }

        if (this._cssStyles.opacity !== this._alpha) {
            this._cssStyles.opacity = this._alpha;
            style.opacity = this._alpha;
            style[prefix + "Opacity"] = this._alpha;
        }

        if (this._mbr) {
            var origin = this._origin.x + "px " + this._origin.y + "px";
            style.transformOrigin = origin;
            style[prefix + "TransformOrigin"] = origin;
            if (Crafty.support.css3dtransform)
                trans.push("rotateZ(" + this._rotation + "deg)");
            else trans.push("rotate(" + this._rotation + "deg)");
        }

        if (this._flipX) {
            trans.push("scaleX(-1)");
        }

        if (this._flipY) {
            trans.push("scaleY(-1)");
        }

        if (this._cssStyles.transform !== trans.join(" ")) {
            this._cssStyles.transform = trans.join(" ");
            style.transform = this._cssStyles.transform;
            style[prefix + "Transform"] = this._cssStyles.transform;
        }

        this.trigger("Draw", {
            style: style,
            type: "DOM",
            co: co
        });

        return this;
    }
798525
function _makeNodeTitleMatcher(s) {
		s = s.toLowerCase();
		return function(node) {
			return node.title.toLowerCase().indexOf(s) >= 0;
		};
	}
307965
def _get_indent(marker, s, tab_width=8):
    """"""
    # Figure out how much the marker is indented.
    INDENT_CHARS = tuple(' \t')
    start = s.index(marker)
    i = start
    while i > 0:
        if s[i - 1] not in INDENT_CHARS:
            break
        i -= 1
    indent = s[i:start]
    indent_width = 0
    for ch in indent:
        if ch == ' ':
            indent_width += 1
        elif ch == '\t':
            indent_width += tab_width - (indent_width % tab_width)
    return indent, indent_width
1364085
float indentLeft() {
        if (isRTL) {
            switch (alignment) {
                case Element.ALIGN_LEFT:
                    return left + width;
                case Element.ALIGN_CENTER:
                    return left + (width / 2f);
                default:
                    return left;
            }
        }
        else if (this.getSeparatorCount() == 0) {
            switch (alignment) {
                case Element.ALIGN_RIGHT:
                    return left + width;
                case Element.ALIGN_CENTER:
                    return left + (width / 2f);
            }
        }
        return left;
    }
563972
private void parseBoldAndItalicSpans(SpanManager sm, Span line,
			List<Span> boldSpans, List<Span> italicSpans)
	{
		// Das suchen nach BOLD und ITALIC muss in den Jeweiligen
		// Zeilen geschenhen, da ein LineSeparator immer BOLD und
		// Italic Tags schliesst.

		// Bold Spans
		parseQuotedSpans(sm, line, boldSpans, "'''");

		// Italic Spans
		parseQuotedSpans(sm, line, italicSpans, "''");

		// Maybe there is ONE SINGLE OPEN TAG left... handel these...
		int openTag = sm.indexOf("''", line);
		if (openTag != -1)
		{
			// build a Span from this Tag.
			Span qs = new Span(openTag, line.getEnd());

			// calculate the original src positions.
			if (calculateSrcSpans)
			{
				qs.setSrcSpan(new SrcSpan(sm.getSrcPos(openTag), sm
						.getSrcPos(line.getEnd())));
			}

			// is it a Bold or an Italic tag ?
			if (sm.indexOf("'''", openTag, openTag + 3) != -1)
			{
				// --> BOLD
				boldSpans.add(qs);
				sm.delete(openTag, openTag + 3);
			}
			else
			{
				// --> ITALIC
				italicSpans.add(qs);
				sm.delete(openTag, openTag + 2);
			}
		}
	}
1131887
function styleBlockHandler(element) {
    const {property, value} = element
    let result = []
    const styleContent = value && value.children ? value.children : []
    const defaultUnit = "px"
    styleContent.forEach(e => {
        switch (e.type) {
            case "Identifier":
                result.push(e.name);
                break
            case "Dimension":
                result.push(e.value + defaultUnit);
                break
            case 'Function': {
                //function case need '()' container,such as rgb(255,0,0)
                let name = e.name + "("
                e.children.forEach(e => name += e.value + queryUnit(e.unit))
                result.push(name + ")")
                break
            }
            case "HexColor": {
                result.push("#" + e.value)
                break
            }
            case "String": {
                const str = e.value
                result.push(str)
                break
            }
            case "Number": {
                result.push(e.value)
                break
            }
            case "Percentage": {
                result.push(e.value + "%")
                break
            }
            case "WhiteSpace": {
                break
            }
            case "Operator": {
                break
            }
            case "Url": {
                break
            }
            default:
                // console.log("unknown,", property, e)
                break
        }
    })
    //padding modification
    if (result.length > 0)
        return paddingElementForTransform(property, result)
    return []
}
343310
function css_beautify(source_text, options) {
    options = options || {};
    var indentSize = options.indent_size || 4;
    var indentCharacter = options.indent_char || ' ';

    // compatibility
    if (typeof indentSize == "string")
        indentSize = parseInt(indentSize);


    // tokenizer
    var whiteRe = /^\s+$/;
    var wordRe = /[\w$\-_]/;

    var pos = -1, ch;
    function next() {
        return ch = source_text.charAt(++pos)
    }
    function peek() {
        return source_text.charAt(pos+1)
    }
    function eatString(comma) {
        var start = pos;
        while(next()){
            if (ch=="\\"){
                next();
                next();
            } else if (ch == comma) {
                break;
            } else if (ch == "\n") {
                break;
            }
        }
        return source_text.substring(start, pos + 1);
    }

    function eatWhitespace() {
        var start = pos;
        while (whiteRe.test(peek()))
            pos++;
        return pos != start;
    }

    function skipWhitespace() {
        var start = pos;
        do{
        }while (whiteRe.test(next()))
        return pos != start + 1;
    }

    function eatComment() {
        var start = pos;
        next();
        while (next()) {
            if (ch == "*" && peek() == "/") {
                pos ++;
                break;
            }
        }

        return source_text.substring(start, pos + 1);
    }


    function lookBack(str) {
        return source_text.substring(pos-str.length, pos).toLowerCase() == str;
    }

    // printer
    var indentString = source_text.match(/^[\r\n]*[\t ]*/)[0];
    var singleIndent = Array(indentSize + 1).join(indentCharacter);
    var indentLevel = 0;
    function indent() {
        indentLevel++;
        indentString += singleIndent;
    }
    function outdent() {
        indentLevel--;
        indentString = indentString.slice(0, -indentSize);
    }

    var print = {}
    print["{"] = function(ch) {
        print.singleSpace();
        output.push(ch);
        print.newLine();
    }
    print["}"] = function(ch) {
        print.newLine();
        output.push(ch);
        print.newLine();
    }

    print.newLine = function(keepWhitespace) {
        if (!keepWhitespace)
            while (whiteRe.test(output[output.length - 1]))
                output.pop();

        if (output.length)
            output.push('\n');
        if (indentString)
            output.push(indentString);
    }
    print.singleSpace = function() {
        if (output.length && !whiteRe.test(output[output.length - 1]))
            output.push(' ');
    }
    var output = [];
    if (indentString)
        output.push(indentString);
    /*_____________________--------------------_____________________*/

    while(true) {
        var isAfterSpace = skipWhitespace();

        if (!ch)
            break;

        if (ch == '{') {
            indent();
            print["{"](ch);
        } else if (ch == '}') {
            outdent();
            print["}"](ch);
        } else if (ch == '"' || ch == '\'') {
            output.push(eatString(ch))
        } else if (ch == ';') {
            output.push(ch, '\n', indentString);
        } else if (ch == '/' && peek() == '*') { // comment
            print.newLine();
            output.push(eatComment(), "\n", indentString);
        } else if (ch == '(') { // may be a url
            if (lookBack("url")) {
              output.push(ch);
              eatWhitespace();
              if (next()) {
                if (ch != ')' && ch != '"' && ch != '\'')
                    output.push(eatString(')'));
                else
                    pos--;
              }
            } else {
              if (isAfterSpace)
                  print.singleSpace();
              output.push(ch);
              eatWhitespace();
            }
        } else if (ch == ')') {
            output.push(ch);
        } else if (ch == ',') {
            eatWhitespace();
            output.push(ch);
            print.singleSpace();
        } else if (ch == ']') {
            output.push(ch);
        }  else if (ch == '[' || ch == '=') { // no whitespace before or after
            eatWhitespace();
            output.push(ch);
        } else {
            if (isAfterSpace)
                print.singleSpace();

            output.push(ch);
        }
    }


    var sweetCode = output.join('').replace(/[\n ]+$/, '');
    return sweetCode;
}
1362151
def get_block_indentation(self, block_nb):
        """"""
        text = to_text_string(self.document().findBlockByNumber(block_nb).text())
        text = text.replace("\t", " "*self.tab_stop_width_spaces)
        return len(text)-len(text.lstrip())
1747
function indent(string, nchars, prefix) {
    "use strict";
    return string.split('\n').map(function(line) {
        return (prefix || '') + new Array(nchars).join(' ') + line;
    }).join('\n');
}
119559
function inlineMargins ($) {
  $('table[style*=margin]').toNodes().forEach(($el) => {
    const { left, right } = getSideMargins($el.attr('style'))

    if (left === 'auto' && right === 'auto') {
      $el.attr('align', 'center')
    } else if (left === 'auto' && right !== 'auto') {
      $el.attr('align', 'right')
    } else if (left !== 'auto') {
      $el.attr('align', 'left')
    }
  })
}
1184598
private void ruleset( String[] sel, CssFormatter formatter ) {
        formatter = formatter.startBlock( sel );
        appendPropertiesTo( formatter );

        for( Formattable prop : properties ) {
            if( prop instanceof Mixin ) {
                ((Mixin)prop).appendSubRules( null, formatter );
            }
        }

        for( Rule rule : subrules ) {
            rule.appendTo( formatter );
        }
        formatter.endBlock();
    }
130691
function indentElement( element, classes, dir ) {
		if ( element.getCustomData( 'indent_processed' ) )
			return;

		var editor = this.editor,
			isIndent = this.isIndent;

		if ( classes ) {
			// Transform current class f to indent step index.
			var indentClass = element.$.className.match( this.classNameRegex ),
				indentStep = 0;

			if ( indentClass ) {
				indentClass = indentClass[ 1 ];
				indentStep = CKEDITOR.tools.indexOf( classes, indentClass ) + 1;
			}

			// Operate on indent step index, transform indent step index
			// back to class name.
			if ( ( indentStep += isIndent ? 1 : -1 ) < 0 )
				return;

			indentStep = Math.min( indentStep, classes.length );
			indentStep = Math.max( indentStep, 0 );
			element.$.className = CKEDITOR.tools.ltrim( element.$.className.replace( this.classNameRegex, '' ) );

			if ( indentStep > 0 )
				element.addClass( classes[ indentStep - 1 ] );
		} else {
			var indentCssProperty = getIndentCss( element, dir ),
				currentOffset = parseInt( element.getStyle( indentCssProperty ), 10 ),
				indentOffset = editor.config.indentOffset || 40;

			if ( isNaN( currentOffset ) )
				currentOffset = 0;

			currentOffset += ( isIndent ? 1 : -1 ) * indentOffset;

			if ( currentOffset < 0 )
				return;

			currentOffset = Math.max( currentOffset, 0 );
			currentOffset = Math.ceil( currentOffset / indentOffset ) * indentOffset;

			element.setStyle( indentCssProperty, currentOffset ?
					currentOffset + ( editor.config.indentUnit || 'px' )
				:
					'' );

			if ( element.getAttribute( 'style' ) === '' )
				element.removeAttribute( 'style' );
		}

		CKEDITOR.dom.element.setMarker( this.database, element, 'indent_processed', 1 );

		return;
	}