/*
Parse the line to determine the appropriate highlighting
546850
private void applyHighlighting( String content, int line ) throws BadLocationException
  {
    int startOffset = _root.getElement( line ).getStartOffset();
    int endOffset = _root.getElement( line ).getEndOffset() - 1;
    int lineLength = endOffset - startOffset;
    int contentLength = content.length();
    if( endOffset >= contentLength )
    {
      endOffset = contentLength - 1;
    }
    // check for multi line comments
    // (always set the comment attribute for the entire line)
    if( endingMultiLineComment( content, startOffset, endOffset ) || isMultiLineComment() || startingMultiLineComment( content, startOffset, endOffset ) )
    {
      setCharacterAttributes( startOffset, endOffset - startOffset + 1, _comment, false );
      return;
    }
    // set normal attributes for the line
    setCharacterAttributes( startOffset, lineLength, _word, true );
    // check for single line comment
    int index = content.indexOf( getSingleLineDelimiter(), startOffset );
    if( (index > -1) && (index < endOffset) )
    {
      setCharacterAttributes( index, endOffset - index + 1, _comment, false );
      endOffset = index - 1;
    }
    // check for tokens
    checkForTokens( content, startOffset, endOffset );
  }
1371799
function highlightText(unhighlightedCode, languageId, partialContext) {
			var language = languages[languageId],
				analyzerContext;
			
			partialContext = partialContext || { };
			if (language === undefined) {
				//use default language if one wasn't specified or hasn't been registered
				language = languages[DEFAULT_LANGUAGE];
			}

			fireEvent("beforeHighlight", this, { code: unhighlightedCode, language: language, previousContext: partialContext });
			
			analyzerContext = createAnalyzerContext(
				tokenize.call(this, unhighlightedCode, language, partialContext, this.options),
				partialContext,
				this.options
			);
			
			analyze.call(this, analyzerContext, partialContext.index ? partialContext.index + 1 : 0);
			
			fireEvent("afterHighlight", this, { analyzerContext: analyzerContext });

			return analyzerContext;
		}
594960
def parse_line(self, line):
        """"""
        # The parser may only need to run until it has seen a specific line.
        # Once that's occurred, it can mark itself as complete, to save
        # being run against later log lines.
        if self.parser.complete:
            return

        # Perf data is stored in a json structure contained in a single line,
        # if the MAX_LINE_LENGTH is applied the data structure could be
        # truncated, preventing it from being ingested.
        if 'PERFHERDER_DATA' not in line:
            line = line[:self.MAX_LINE_LENGTH]

        self.parser.parse_line(line, self.lineno)
        self.lineno += 1
335397
protected boolean parseEmptyOrCommentLine(final ParserData parserData, final String line) {
        if (isBlankLine(line)) {
            if (parserData.getCurrentLevel().getLevelType() == LevelType.BASE) {
                parserData.getContentSpec().appendChild(new TextNode("\n"));
            } else {
                parserData.getCurrentLevel().appendChild(new TextNode("\n"));
            }
            return true;
        } else {
            if (parserData.getCurrentLevel().getLevelType() == LevelType.BASE) {
                parserData.getContentSpec().appendComment(line);
            } else {
                parserData.getCurrentLevel().appendComment(line);
            }
            return true;
        }
    }
145364
private void parseLine( List<String> names, String line )
    {
        int commentPos = line.indexOf( '#' );
        if( commentPos >= 0 )
        {
            line = line.substring( 0, commentPos );
        }
        line = line.trim();
        if( !line.isEmpty() && !names.contains( line ) )
        {
            names.add( line );
        }
    }
85347
function() {
			if (this.startLine !== Number.MAX_VALUE && this.endLine !== -1) {
				this.dispatchEvent({
					type: "Highlight",
					start: this.startLine,
					end: this.endLine
				});
			}
			this.startLine = Number.MAX_VALUE;
			this.endLine = -1;
		}
280412
function highlight(js) {
  return js
    .replace(/</g, '&lt;')
    .replace(/>/g, '&gt;')
    .replace(/\/\/(.*)/gm, '<span class="comment">//$1</span>')
    .replace(/('.*?')/gm, '<span class="string">$1</span>')
    .replace(/(\d+\.\d+)/gm, '<span class="number">$1</span>')
    .replace(/(\d+)/gm, '<span class="number">$1</span>')
    .replace(
      /\bnew[ \t]+(\w+)/gm,
      '<span class="keyword">new</span> <span class="init">$1</span>'
    )
    .replace(
      /\b(function|new|throw|return|var|if|else)\b/gm,
      '<span class="keyword">$1</span>'
    );
}
16023
function (line) {
		line = line || "";
		line = line.trim();

		if (line.charAt(0) === "#") {
			return true;
		}

		return false;
	}
1256293
function (wholeMatch, match, left, right) {
              // unescape match to prevent double escaping
              match = htmlunencode(match);
              return left + hljs.highlightAuto(match).value + right;
            }
740069
function(_content,_out){
        if (!_content) return;
        var _lines = _content.split('\n');
        if (!_lines||!_lines.length) return;
        for(var i=0,l=_lines.length,_line;i<l;i++){
            _line = _lines[i];
            if (!!_trim){
                _line = _line.trim();
                if (!_line) continue;
            } 
            _doParseSectionTextLine(_line,_out);
            if (!!_trim&&i<l-1) _out.push('__OUT.push(\'\\n\');');
        }
    }
992114
private static String highlightToken(String line, Token token)
    {
        String newLine = insertChar(line, getLastCharPositionInLine(token), ']');
        return insertChar(newLine, token.getCharPositionInLine(), '[');
    }
1016369
function highlight(code) {
  return new Promise((resolve, reject) => {
    pygmentize({ lang: 'html', format: 'html' }, code, function (err, result) {
      if (err) {
        console.log(err);
        reject(err);
      } else {
        resolve(result.toString());
      };
    });
  });
}
1278115
function LineInfoEmitter(options, rules) {
    var stdin = process.stdin,
        incompleteLine,
        self = this;

    EventEmitter.call(this);

    // prepare stdin for character processing and listen to events
    stdin.setEncoding(options.encoding);

    function processData(data) {
        var lastLineIncomplete, lines;

        if (options.debug) {
            console.log('====> incompleteLine:', incompleteLine, 'new chunk:');
            hexdumpLine(data);
        }

        if (incompleteLine) {
            // append data to not yet emitted, incomplete line
            data = incompleteLine + data;
            incompleteLine = null;
        }

        lastLineIncomplete = data && data.charAt(data.length - 1) !== '\n';
        lines = data.split('\n');

        if (lastLineIncomplete) {
            // wait to emit last line until rest of line comes in
            incompleteLine = lines.pop();
        }
        else {
            // remove last '' after newline
            lines.pop();
        }
        lines.forEach(function (line, i) {
            if (options.debug) {
                hexdumpLine(line);
            }
            var lineInfo = analyzeLine(line, rules);
            self.emit('lineInfo', lineInfo);
        });
    }

    stdin.on('data', processData);

    stdin.on('end', function () {
        if (incompleteLine) {
            processData('\n');
        }
        self.emit('end');
    });

    // stdin is paused by default, so let's start!
    stdin.resume();
}
1272927
function highlightTokens(defs: Object, text: string) {
  return text.replace(jsTokens, function(...args) {
    const type = getTokenType(args);
    const colorize = defs[type];
    if (colorize) {
      return args[0]
        .split(NEWLINE)
        .map(str => colorize(str))
        .join("\n");
    } else {
      return args[0];
    }
  });
}
286646
function parseLine(line){
  var len = line.length;
  var i = 0;
  var lineArr = [];
  var preIndex = 0;
  var isEmpty = false;
  for(; i < len; i++){
    if(/\s/.test(line[i])){
      if(!isEmpty){
        lineArr.push(line.substr(preIndex, i - preIndex));
        isEmpty = true; 
      }
    }else{
      if(isEmpty){
        if(lineArr.length === FIXED_LEN){
          lineArr.push(line.substr(i));
          break;
        }else{
          isEmpty = false;
          preIndex = i;
        }
      }
    }
  }
  return lineArr;
}
555417
function highlight() {
    $('pre code').each(function (i, block) {
      hljs.highlightBlock(block);
    });
    $('pre code[highlight-lines]').each(function (i, block) {
      if (block.innerHTML === "") return;
      var lines = block.innerHTML.split('\n');

      queryString = block.getAttribute('highlight-lines');
      if (!queryString) return;

      var ranges = queryString.split(',');
      for (var j = 0, range; range = ranges[j++];) {
        var found = range.match(/^(\d+)\-(\d+)?$/);
        if (found) {
          // consider region as `{startlinenumber}-{endlinenumber}`, in which {endlinenumber} is optional
          var start = +found[1];
          var end = +found[2];
          if (isNaN(end) || end > lines.length) {
            end = lines.length;
          }
        } else {
          // consider region as a sigine line number
          if (isNaN(range)) continue;
          var start = +range;
          var end = start;
        }
        if (start <= 0 || end <= 0 || start > end || start > lines.length) {
          // skip current region if invalid
          continue;
        }
        lines[start - 1] = '<span class="line-highlight">' + lines[start - 1];
        lines[end - 1] = lines[end - 1] + '</span>';
      }

      block.innerHTML = lines.join('\n');
    });
  }
1115670
@Override
    public void handleText(
            final char[] buffer, final int offset, final int len,
            final int line, final int col)
            throws ParseException {

        this.someSelectorsMatch = false;
        for (int i = 0; i < this.selectorsLen; i++) {

            this.selectorMatches[i] =
                    this.selectorFilters[i].matchText(false, this.markupLevel, this.markupBlocks[this.markupLevel]);
            if (this.selectorMatches[i]) {
                this.someSelectorsMatch = true;
            }

        }

        if (this.someSelectorsMatch) {
            markCurrentSelection();
            this.selectedHandler.handleText(buffer, offset, len, line, col);
            unmarkCurrentSelection();
            return;
        }

        unmarkCurrentSelection();
        this.nonSelectedHandler.handleText(buffer, offset, len, line, col);

    }