Squeeze the contents by removing blank lines between definition and example
    and remove duplicate blank lines except between sections.
492798
def get_squeezed_contents(contents):
    
    line_between_example_code = substitute.Substitution(
        '\n\n    ',
        '\n    ',
        True
    )
    lines_between_examples = substitute.Substitution('\n\n\n', '\n\n', True)
    lines_between_sections = substitute.Substitution(
        '\n\n\n\n', '\n\n\n', True
    )

    result = contents
    result = line_between_example_code.apply_and_get_result(result)
    result = lines_between_examples.apply_and_get_result(result)
    result = lines_between_sections.apply_and_get_result(result)
    return result
1170664
def remove_all_gap_columns( components ):
            
    seqs = [ list( c.text ) for c in components ]
    i = 0
    text_size = len( seqs[0] )
    while i < text_size:
        all_gap = True
        for seq in seqs:
            if seq[i] != '-': all_gap = False
        if all_gap:
            for seq in seqs: del seq[i]
            text_size -= 1
        else:
            i += 1
    for i in range( len( components ) ):
        components[i].text = ''.join( seqs[i] )
777270
function trimLines(text) {
    let linebreak = determineLinebreaks(text);
    if (linebreak === "") return text;

    let lines = [];
    lines = text.split(linebreak);
    text = "";

    for (let i = 0; i < lines.length; i++) {
        let line = lines[i];

        while (true) {
            let lastChar = line.slice(line.length-1, line.length);
            let repeat = false;

            switch (lastChar) {
                case " ":
                case "\t":
                    line = line.slice(0, -1)
                    repeat = true;
            }

            if (!repeat) break;
        }

        text += line + linebreak;
    }

    return text;
}
526369
def __remove_trailing_empty_lines(lines):
        
        lines.reverse()
        tmp = DocBlockReflection.__remove_leading_empty_lines(lines)
        lines.reverse()
        tmp.reverse()

        return tmp
638512
protected void trimLeadingWhiteSpaces()
    {
        if (shouldRemoveWhiteSpaces() && getContent().length() > 0) {
            String result = trimLeadingWhiteSpaces(getContent());
            getContent().setLength(0);
            getContent().append(result);
        }
    }
355856
def clean_text(text):
    """"""
    new_text = re.sub(ur'\p{P}+', ' ', text)

    new_text = [stem(i) for i in new_text.lower().split() if not
                re.findall(r'[0-9]', i)]

    new_text = ' '.join(new_text)

    return new_text
1158236
def clean_strict(text, boundary=WS):
    """"""
    # transliterate to ascii
    text = ascii_text(text)
    # replace punctuation and symbols
    text = CHARACTERS_REMOVE_RE.sub('', text)
    text = category_replace(text)
    # pad out for company type replacements
    text = ''.join((boundary, collapse_spaces(text), boundary))
    return text
879102
def tidy_blank_lines
      (@fragments.size - 1).times do |i|
        if @fragments[i].kind_of?(BlankLine) and 
            @fragments[i+1].kind_of?(ListEnd)
          @fragments[i], @fragments[i+1] = @fragments[i+1], @fragments[i] 
        end
      end

      # remove leading blanks
      @fragments.each_with_index do |f, i|
        break unless f.kind_of? BlankLine
        @fragments[i] = nil
      end

      @fragments.compact!
    end
48315
private void compress() {
        if (sample.size() < 2) {
            return;
        }

        ListIterator<Item> it = sample.listIterator();
        int removed = 0;

        Item prev = null;
        Item next = it.next();

        while (it.hasNext()) {
            prev = next;
            next = it.next();

            if (prev.g + next.g + next.delta <= allowableError(it.previousIndex())) {
                next.g += prev.g;
                // Remove prev. it.remove() kills the last thing returned.
                it.previous();
                it.previous();
                it.remove();
                // it.next() is now equal to next, skip it back forward again
                it.next();
                removed++;
            }
        }
    }
1333082
def _remove_boring_lines(text):
  
  lines = text.split("\n")
  filtered = [line for line in lines if re.match("[a-zA-z\"\']", line)]
  return "\n".join(filtered)
378793
protected void cleanContentExtraWhiteSpaces()
    {
        if (getContent().length() > 0) {
            if (shouldRemoveWhiteSpaces()) {
                Matcher matcher = HTML_WHITESPACE_DUPLICATES_PATTERN
                    .matcher(getContent());
                String result = matcher.replaceAll(" ");
                getContent().setLength(0);
                getContent().append(result);
            }
        }
    }
281642
def ProcessContent(self, strip_expansion=False):
    """"""
    self._ParseFile()
    if strip_expansion:
      # Without a collection the expansions become blank, removing them.
      collection = None
    else:
      collection = MacroCollection()
    for section in self._sections:
      section.BindMacroCollection(collection)
    result = ''
    for section in self._sections:
      result += section.text
    self._processed_content = result
1057755
function trimTrailingWhitespacesForRemainingRange() {
                var startPosition = previousRange ? previousRange.end : originalRange.pos;
                var startLine = sourceFile.getLineAndCharacterOfPosition(startPosition).line;
                var endLine = sourceFile.getLineAndCharacterOfPosition(originalRange.end).line;
                trimTrailingWhitespacesForLines(startLine, endLine + 1, previousRange);
            }
169439
public void newLineIfNotEmpty() {
		for (int i = segments.size() - 1; i >= 0; i--) {
			String segment = segments.get(i);
			if (lineDelimiter.equals(segment)) {
				segments.subList(i + 1, segments.size()).clear();
				cachedToString = null;
				return;
			}
			for (int j = 0; j < segment.length(); j++) {
				if (!WhitespaceMatcher.isWhitespace(segment.charAt(j))) {
					newLine();
					return;
				}
			}
		}
		segments.clear();
		cachedToString = null;
	}
1209005
function splitCleanup(input, text) {
                var li = input.closest('li'),
                    subTags = text ? text.replace(/ +/, ' ').split(o.dregex) : input.val().replace(/ +/, ' ').split(o.dregex),
                    oldTag = input.data('old_tag'),
                    oldTags = tagList.slice(0),
                    exceeded = false,
                    cbVal; // copy tagList

                for (var i = 0 ; i < subTags.length ; i++) {
                    var tag = $.trim(subTags[i]).slice(0, o.maxLength);
                    if (o.forceLowercase) {
                        tag = tag.toLowerCase();
                    }

                    cbVal = o.beforeTagSave(el, ed, oldTags, oldTag, tag);
                    tag = cbVal || tag;

                    if (cbVal === false || !tag) {
                        continue;
                    }

                    var tagObject = validate(tag);
                    
                    if (tagObject) {
                        var $tagEditorTag =
                            $('<div class="json-tag-editor-tag"' +
                                  (tag.length > o.maxTagLength ? ' title="' + escape(tagObject.value) + '"' : '') + '>' + escape(ellipsify(tagObject.value, o.maxTagLength)) +
                              '</div>');

                        var tagProperties = Object.keys(tagObject);
                        for (var j = 0 ; j < tagProperties.length ; j++) {
                            $tagEditorTag.get(0).dataset[tagProperties[j]] = tagObject[tagProperties[j]];
                        }

                        oldTags.push(tagObject);
                        li.before(
                            $('<li></li>')
                                .append('<div class="json-tag-editor-spacer">&nbsp;' + o.delimiter[0] + '</div>')
                                .append($tagEditorTag)
                                .append('<div class="json-tag-editor-delete"><i></i></div>')
                        );

                        if (o.maxTags && oldTags.length >= o.maxTags) {
                            exceeded = true;
                            break;
                        }
                    }
                }

                input.closest('li').remove();
                updateGlobals();
            }
1129995
private void tidy() {
        nonPermanent.entrySet().stream()
                .map(entry -> {
                    List<WeakReference<IzouSoundLineBaseClass>> collect = entry.getValue().stream()
                            .filter(izouSoundLineWeakReference -> izouSoundLineWeakReference.get() != null)
                            .collect(Collectors.toList());
                    if (!collect.isEmpty()) {
                        nonPermanent.put(entry.getKey(), collect);
                        return null;
                    } else {
                        return entry;
                    }
                })
                .filter(Objects::nonNull)
                .forEach(entry -> nonPermanent.remove(entry.getKey()));
    }
322630
def remove_blank_lines(string):
    
    return "\n".join(line
                     for line in string.split("\n")
                     if len(line.strip()))