private void applyHighlighting(String content, int line) throws BadLocationException {
        int startOffset = rootElement.getElement(line).getStartOffset();
        int endOffset = rootElement.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)) {
        	if (attributes.containsKey("comment"))
        		doc.setCharacterAttributes(startOffset, endOffset - startOffset + 1, attributes.get("comment"), true);
            return;
        }

        //  set default attributes for the line
        if (attributes.containsKey("default"))
        	doc.setCharacterAttributes(startOffset, lineLength, attributes.get("default"), true);

        //  check for single line comment

        int index = content.indexOf(';', startOffset);

        if ((index > -1) && (index < endOffset)) {
        	if (attributes.containsKey("comment"))
        		doc.setCharacterAttributes(index, endOffset - index + 1, attributes.get("comment"), true);
            endOffset = index - 1;
        }

        //  check for tokens

        checkForTokens(content, startOffset, endOffset);
    }