remove any trailing and preceding newline characters. Modified from PARSERS.parse_description. @see https://github.com/yavorskiy/comment-parser/blob/master/parser.js
162643
function parse_description(str, data) {
        if (data.errors && data.errors.length) { return null; }

        var result = str.match(/^\s+([\s\S]+)?/);

        if (result) {
          return {
            source: result[0],
            data: {description: result[1] === undefined ? '' : result[1].replace(trimNewlineRegex, '')}
          };
        }

        return null;
      }
449858
def clean_description desc
      strip_stopwords(
        desc.gsub(XML_TAG_FILTER,' ')
            .gsub(EMAIL_FILTER,'')
            .gsub(URL_FILTER,'')
            .gsub(GENDER_FILTER,'')
            .gsub(NEW_LINES,'')
            .gsub(SYMBOL_FILTER,' ')
            .gsub(WHITESPACE,' ')
            .gsub(WORDS_IN_BRACKETS, '\1')
            .gsub(CODE_TOKEN_FILTER,'')
            .downcase
            .strip
        )
    end
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);
            }
619304
def shorten(original_chars, chars, length_without_trailing)
      truncated = []
      char_width = display_width(chars[0])
      while length_without_trailing - char_width > 0
        orig_char = original_chars.shift
        char = chars.shift
        break unless char
        while orig_char != char # consume ansi
          ansi = true
          truncated << orig_char
          orig_char = original_chars.shift
        end
        truncated << char
        char_width = display_width(char)
        length_without_trailing -= char_width
      end
      truncated << ["\e[0m"] if ansi
      truncated
    end
400241
function purify(input) {
    var result = [], indent = null, codeBlock = false;
    
    // We can have two types of lines:
    // - those beginning with *
    // - and those without it
    input.split("\n").forEach(function(line) {
        // chomp !
        line = line.replace(/(\n|\r)+$/, '');

        if (!codeBlock && /^\s*\*\s*```/.test(line))
          codeBlock = true;
        else if (codeBlock && /^\s*\*\s*```/.test(line))
          codeBlock = false;

        var m;
        if ( ( m = line.match(/^\s*\*\s?(.*)$/)) ) {
            // When comment contains *-lines, switch indent-trimming off
            indent = 0;
            
            if (codeBlock)
              result.push(m[1]);
            else
              result.push(m[1].replace(/^\s+/,""));
        }
        else if (/^\s*$/.test(line)) {
            // pass-through empty lines
            result.push(line);
        }
        else if (indent === undefined && (m = line.match(/^(\s*)(.*?$)/) ) ) {
            // When indent not measured, measure it and remember
            indent = m[1];
            result.push(m[2]);
        }
        else {
            // Trim away indent if available
            //result.push(line.replace(new RegExp("^\s{0," + indent + "}"), ""));
            result.push(line.replace(/^\s+/,""));
        }
    });

    return result.join("\n");
}
982863
function commentStrip(string) {
  // Remove commented lines
  string = string.replace(RE_COMMENT_SINGLE_LINE, '');
  string = string.replace(RE_COMMENT_MULTI_LINES, '');
  return string;
}
455715
function removeLeftMargin( code ) {
  var margin = 999;
  var lines = code.split("\n");
  lines.forEach(function (line) {
    var s = line.length;
    var m = 0;
    while( m < s && line.charAt(m) == ' ' ) m++;
    margin = Math.min( m, margin );
  });
  return lines.map(function(line) {
    return line.substr( margin );
  }).join("\n");
}
801433
private void skipToEndOfLine() {
		for (; this.pos < this.in.length(); this.pos++) {
			char c = this.in.charAt(this.pos);
			if (c == '\r' || c == '\n') {
				this.pos++;
				break;
			}
		}
	}
133251
def removecomment(astr, cphrase):
    
    # linesep = mylib3.getlinesep(astr)
    alist = astr.splitlines()
    for i in range(len(alist)):
        alist1 = alist[i].split(cphrase)
        alist[i] = alist1[0]

    # return string.join(alist, linesep)
    return '\n'.join(alist)
1356379
def newline_before_nonwhitespace(string)
      offset = -2
      while /\S/.match(string[offset]).nil?
        return true if string[offset] == "\n"
        offset -= 1
      end
      false
    end
852212
function(text, removeEmpty) {
			// IE fails to split string by regexp, 
			// need to normalize newlines first
			// Also, Mozilla's Rhiho JS engine has a weird newline bug
			var nl = '\n';
			var lines = (text || '')
				.replace(/\r\n/g, '\n')
				.replace(/\n\r/g, '\n')
				.replace(/\r/g, '\n')
				.replace(/\n/g, nl)
				.split(nl);
			
			if (removeEmpty) {
				lines = lines.filter(function(line) {
					return line.length && !!this.trim(line);
				}, this);
			}
			
			return lines;
		}
875374
function split_newlines(s) {
            //return s.split(/\x0d\x0a|\x0a/);

            s = s.replace(/\x0d/g, '');
            var out = [],
                idx = s.indexOf("\n");
            while (idx !== -1) {
                out.push(s.substring(0, idx));
                s = s.substring(idx + 1);
                idx = s.indexOf("\n");
            }
            if (s.length) {
                out.push(s);
            }
            return out;
        }
1090530
public static String removeEmptyLine(String str) {
        assertStringNotNull(str);
        final StringBuilder sb = new StringBuilder();
        final List<String> lineList = splitList(str, "\n");
        for (String line : lineList) {
            if (is_Null_or_TrimmedEmpty(line)) {
                continue; // skip
            }
            sb.append(removeCR(line)).append("\n");
        }
        final String filtered = sb.toString();
        return filtered.substring(0, filtered.length() - "\n".length());
    }
1038115
def remove_trailing_stars(self, new_path=None, in_place=True, check=False):
        """"""
        # Optional check #
        if check and int(sh.grep('-c', '\*', self.path, _ok_code=[0,1])) == 0: return self
        # Faster with bash utilities #
        if in_place is True:
            sh.sed('-i', 's/\*$//g', self.path)
            return self
        # Standard way #
        if new_path is None: new_fasta = self.__class__(new_temp_path())
        else:                new_fasta = self.__class__(new_path)
        new_fasta.create()
        for seq in self: new_fasta.add_str(str(seq.seq).rstrip('*'), seq.id)
        new_fasta.close()
        return new_fasta
11182
def strip_frontmatter(source)
      frontmatter = /
        # From the start of the string
        \A
        # First-capture match --- followed by optional whitespace up
        # to a newline then 0 or more chars followed by an optional newline.
        # This matches the --- and the contents of the frontmatter
        (---\s*\n.*?\n?)
        # From the start of the line
        ^
        # Second capture match --- or ... followed by optional whitespace
        # and newline. This matches the closing --- for the frontmatter.
        (---|\.\.\.)\s*$\n?/mx

      if config['skip_frontmatter'] && match = source.match(frontmatter)
        newlines = match[0].count("\n")
        source.sub!(frontmatter, "\n" * newlines)
      end

      source
    end
1173173
function removeComplete(regex, lines, start) {
  var matches = lines[start].match(regex);
  var i = 0;
  var s = lines[start];
  matches = s.match(regex);

  while (!matches) {
    i++;
    if ((start + i) > lines.length) return;
    s += lines[start + i];
    matches = s.match(regex);
  }
  lines.splice(start, i + 1);
}
833954
def markup(str, remove_para = false)
      return '' unless str

      # Convert leading comment markers to spaces, but only if all non-blank
      # lines have them
      if str =~ /^(?>\s*)[^\#]/ then
        content = str
      else
        content = str.gsub(/^\s*(#+)/) { $1.tr '#', ' ' }
      end

      res = formatter.convert content

      if remove_para then
        res.sub!(/^<p>/, '')
        res.sub!(/<\/p>$/, '')
      end

      res
    end