(refs #310)Convert all CRLF to LF

This commit is contained in:
Naoki Takezoe
2014-06-29 04:16:37 +09:00
parent 1c99b57709
commit fd09058a7d
37 changed files with 93251 additions and 57107 deletions

View File

@@ -59,6 +59,8 @@ var TextHighlightRules = require("./text_highlight_rules").TextHighlightRules;
var DiffHighlightRules = function() {
this.$rules = {
"start" : [{
regex: "^(?:\\*{15}|={67}|-{3}|\\+{3})$",

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@@ -2128,12 +2128,14 @@ function isSelectScopeMarker(node) {
return !(node.namespaceURI === "http://www.w3.org/1999/xhtml" && node.localName === 'optgroup')
&& !(node.namespaceURI === "http://www.w3.org/1999/xhtml" && node.localName === 'option');
}
function ElementStack() {
this.elements = [];
this.rootNode = null;
this.headElement = null;
this.bodyElement = null;
}
ElementStack.prototype._inScope = function(localName, isMarker) {
for (var i = this.elements.length - 1; i >= 0; i--) {
var node = this.elements[i];
@@ -2334,8 +2336,14 @@ EntityParser.consumeEntity = function(buffer, tokenizer, additionalAllowedCharac
code = replacement;
}
if (code > 0xFFFF && code <= 0x10FFFF) {
code -= 0x10000;
var first = ((0xffc00 & code) >> 10) + 0xD800;
var second = (0x3ff & code) + 0xDC00;
decodedCharacter = String.fromCharCode(first, second);
} else
@@ -2663,6 +2671,7 @@ function StackItem(namespaceURI, localName, attributes, node) {
this.attributes = attributes;
this.node = node;
}
StackItem.prototype.isSpecial = function() {
return this.namespaceURI in SpecialElements &&
SpecialElements[this.namespaceURI].indexOf(this.localName) > -1;
@@ -4388,11 +4397,16 @@ function TreeBuilder() {
tree.parseError('expected-closing-tag-but-got-eof');
} else if (tree.openElements.length == 2 &&
tree.openElements.item(1).localName != 'body') {
tree.parseError('expected-closing-tag-but-got-eof');
} else if (tree.context && tree.openElements.length > 1) {
}
},
processComment: function(data) {
tree.insertComment(data, tree.currentStackItem().node);
},
processDoctype: function(name, publicId, systemId, forceQuirks) {
@@ -4535,6 +4549,8 @@ function TreeBuilder() {
|| (publicId == "-//W3C//DTD XHTML 1.0 Strict//EN" && (systemId == "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"))
|| (publicId == "-//W3C//DTD XHTML 1.1//EN" && (systemId == "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd"))
) {
} else if (!((systemId == null || systemId == "about:legacy-compat") && publicId == null)) {
tree.parseError("unknown-doctype");
}
@@ -4663,6 +4679,8 @@ function TreeBuilder() {
};
modes.afterBody.processComment = function(data) {
tree.insertComment(data, tree.openElements.rootNode);
};
@@ -4685,6 +4703,11 @@ function TreeBuilder() {
if (tree.context) {
tree.parseError('end-html-in-innerhtml');
} else {
tree.setInsertionMode('afterAfterBody');
}
};
@@ -4855,6 +4878,7 @@ function TreeBuilder() {
};
modes.inHead.startTagNoFramesStyle = function(name, attributes) {
tree.processGenericRawTextStartTag(name, attributes);
};
@@ -4871,6 +4895,7 @@ function TreeBuilder() {
modes.inHead.startTagMeta = function(name, attributes) {
tree.insertSelfClosingElement(name, attributes);
};
modes.inHead.startTagOther = function(name, attributes, selfClosing) {
@@ -4911,6 +4936,7 @@ function TreeBuilder() {
link: 'startTagFromHead',
meta: 'startTagFromHead',
script: 'startTagFromHead',
style: 'startTagFromHead',
title: 'startTagFromHead',
"-default": 'startTagOther'
@@ -4955,6 +4981,7 @@ function TreeBuilder() {
modes.afterHead.startTagFromHead = function(name, attributes, selfClosing) {
tree.parseError("unexpected-start-tag-out-of-my-head", {name: name});
tree.openElements.push(tree.head);
modes.inHead.processStartTag(name, attributes, selfClosing);
tree.openElements.remove(tree.head);
@@ -5161,6 +5188,7 @@ function TreeBuilder() {
tree.reconstructActiveFormattingElements();
var characters = buffer.takeRemaining();
characters = characters.replace(/\u0000/g, function(match, index){
tree.parseError("invalid-codepoint");
return '';
});
@@ -5241,6 +5269,7 @@ function TreeBuilder() {
};
modes.inBody.startTagListItem = function(name, attributes) {
var stopNames = {li: ['li'], dd: ['dd', 'dt'], dt: ['dd', 'dt']};
var stopName = stopNames[name];
@@ -5251,11 +5280,13 @@ function TreeBuilder() {
tree.insertionMode.processEndTag(node.localName);
break;
}
if (node.isSpecial() && node.localName !== 'p' && node.localName !== 'address' && node.localName !== 'div')
break;
}
if (tree.openElements.inButtonScope('p'))
this.endTagP('p');
tree.insertElement(name, attributes);
tree.framesetOk = false;
};
@@ -5300,6 +5331,7 @@ function TreeBuilder() {
if (tree.openElements.inScope('nobr')) {
tree.parseError("unexpected-start-tag-implies-end-tag", {startName: 'nobr', endName: 'nobr'});
this.processEndTag('nobr');
tree.reconstructActiveFormattingElements();
}
tree.insertFormattingElement(name, attributes);
@@ -5372,6 +5404,7 @@ function TreeBuilder() {
};
modes.inBody.startTagImage = function(name, attributes) {
tree.parseError('unexpected-start-tag-treated-as', {originalName: 'image', newName: 'img'});
this.processStartTag('img', attributes);
};
@@ -5380,6 +5413,7 @@ function TreeBuilder() {
var currentFramesetOk = tree.framesetOk;
this.startTagVoidFormatting(name, attributes);
for (var key in attributes) {
if (attributes[key].nodeName == 'type') {
if (attributes[key].nodeValue.toLowerCase() == 'hidden')
tree.framesetOk = currentFramesetOk;
@@ -5424,6 +5458,7 @@ function TreeBuilder() {
};
modes.inBody.startTagTextarea = function(name, attributes) {
tree.insertElement(name, attributes);
tree.tokenizer.setState(Tokenizer.RCDATA);
tree.originalInsertionMode = tree.insertionModeName;
@@ -5463,6 +5498,7 @@ function TreeBuilder() {
};
modes.inBody.endTagMisplaced = function(name) {
tree.parseError("unexpected-end-tag", {name: name});
};
@@ -5493,6 +5529,7 @@ function TreeBuilder() {
tree.generateImpliedEndTags(name);
if (tree.currentStackItem().localName != name)
tree.parseError('unexpected-end-tag', {name: name});
tree.openElements.remove_openElements_until(function(x) {return x === node;});
break;
}
@@ -5508,6 +5545,8 @@ function TreeBuilder() {
attributes = tree.adjustMathMLAttributes(attributes);
attributes = tree.adjustForeignAttributes(attributes);
tree.insertForeignElement(name, attributes, "http://www.w3.org/1998/Math/MathML", selfClosing);
};
modes.inBody.startTagSVG = function(name, attributes, selfClosing) {
@@ -5515,6 +5554,8 @@ function TreeBuilder() {
attributes = tree.adjustSVGAttributes(attributes);
attributes = tree.adjustForeignAttributes(attributes);
tree.insertForeignElement(name, attributes, "http://www.w3.org/2000/svg", selfClosing);
};
modes.inBody.endTagP = function(name) {
@@ -5535,6 +5576,8 @@ function TreeBuilder() {
tree.parseError('unexpected-end-tag', {name: name});
return;
}
if (tree.currentStackItem().localName != 'body') {
tree.parseError('expected-one-end-tag-but-got-another', {
expectedName: tree.currentStackItem().localName,
@@ -5549,6 +5592,8 @@ function TreeBuilder() {
tree.parseError('unexpected-end-tag', {name: name});
return;
}
if (tree.currentStackItem().localName != 'body') {
tree.parseError('expected-one-end-tag-but-got-another', {
expectedName: tree.currentStackItem().localName,
@@ -5662,11 +5707,14 @@ function TreeBuilder() {
modes.inCaption.endTagCaption = function(name) {
if (!tree.openElements.inTableScope('caption')) {
assert.ok(tree.context);
tree.parseError('unexpected-end-tag', {name: name});
} else {
tree.generateImpliedEndTags();
if (tree.currentStackItem().localName != 'caption') {
tree.parseError('expected-one-end-tag-but-got-another', {
gotName: "caption",
expectedName: tree.currentStackItem().localName
@@ -5734,6 +5782,7 @@ function TreeBuilder() {
this.closeCell();
tree.insertionMode.processStartTag(name, attributes, selfClosing);
} else {
tree.parseError('unexpected-start-tag', {name: name});
}
};
@@ -5767,6 +5816,7 @@ function TreeBuilder() {
this.closeCell();
tree.insertionMode.processEndTag(name);
} else {
tree.parseError('unexpected-end-tag', {name: name});
}
};
@@ -5825,6 +5875,7 @@ function TreeBuilder() {
modes.inColumnGroup.endTagColgroup = function(name) {
if (this.ignoreEndTagColgroup()) {
assert.ok(tree.context);
tree.parseError('unexpected-end-tag', {name: name});
} else {
@@ -5895,6 +5946,7 @@ function TreeBuilder() {
modes.inForeignContent.processCharacters = function(buffer) {
var characters = buffer.takeRemaining();
characters = characters.replace(/\u0000/g, function(match, index){
tree.parseError('invalid-codepoint');
return '\uFFFD';
});
@@ -5930,6 +5982,7 @@ function TreeBuilder() {
tree.insertText(leadingWhitespace);
if (!buffer.length)
return;
tree.parseError("unexpected-char-in-frameset");
this.anythingElse();
tree.insertionMode.processCharacters(buffer);
@@ -5944,16 +5997,19 @@ function TreeBuilder() {
};
modes.inHeadNoscript.startTagHeadNoscript = function(name, attributes) {
tree.parseError("unexpected-start-tag-in-frameset", {name: name});
};
modes.inHeadNoscript.startTagOther = function(name, attributes) {
tree.parseError("unexpected-start-tag-in-frameset", {name: name});
this.anythingElse();
tree.insertionMode.processStartTag(name, attributes);
};
modes.inHeadNoscript.endTagBr = function(name, attributes) {
tree.parseError("unexpected-end-tag-in-frameset", {name: name});
this.anythingElse();
tree.insertionMode.processEndTag(name, attributes);
@@ -5965,6 +6021,7 @@ function TreeBuilder() {
};
modes.inHeadNoscript.endTagOther = function(name, attributes) {
tree.parseError("unexpected-end-tag-in-frameset", {name: name});
};
@@ -6012,12 +6069,14 @@ function TreeBuilder() {
modes.inFrameset.endTagFrameset = function(name, attributes) {
if (tree.currentStackItem().localName == 'html') {
tree.parseError("unexpected-frameset-in-frameset-innerhtml");
} else {
tree.popElement();
}
if (!tree.context && tree.currentStackItem().localName != 'frameset') {
tree.setInsertionMode('afterFrameset');
}
};
@@ -6126,6 +6185,7 @@ function TreeBuilder() {
if (attributes[key].nodeValue.toLowerCase() == 'hidden') {
tree.parseError("unexpected-hidden-input-in-table");
tree.insertElement(name, attributes);
tree.openElements.pop();
return;
}
@@ -6172,7 +6232,9 @@ function TreeBuilder() {
modes.inTable.endTagOther = function(name) {
tree.parseError("unexpected-end-tag-implies-table-voodoo", {name: name});
tree.redirectAttachToFosterParent = true;
modes.inBody.processEndTag(name);
tree.redirectAttachToFosterParent = false;
};
@@ -6208,6 +6270,7 @@ function TreeBuilder() {
modes.inTableText.processCharacters = function(buffer) {
var characters = buffer.takeRemaining();
characters = characters.replace(/\u0000/g, function(match, index){
tree.parseError("invalid-codepoint");
return '';
});
@@ -6277,11 +6340,13 @@ function TreeBuilder() {
};
modes.inTableBody.startTagTableOther = function(name, attributes) {
if (tree.openElements.inTableScope('tbody') || tree.openElements.inTableScope('thead') || tree.openElements.inTableScope('tfoot')) {
tree.openElements.popUntilTableBodyScopeMarker();
this.endTagTableRowGroup(tree.currentStackItem().localName);
tree.insertionMode.processStartTag(name, attributes);
} else {
tree.parseError('unexpected-start-tag', {name: name});
}
};
@@ -6306,6 +6371,7 @@ function TreeBuilder() {
this.endTagTableRowGroup(tree.currentStackItem().localName);
tree.insertionMode.processEndTag(name);
} else {
tree.parseError('unexpected-end-tag', {name: name});
}
};
@@ -6350,6 +6416,7 @@ function TreeBuilder() {
modes.inSelect.processCharacters = function(buffer) {
var data = buffer.takeRemaining();
data = data.replace(/\u0000/g, function(match, index){
tree.parseError("invalid-codepoint");
return '';
});
@@ -6359,6 +6426,7 @@ function TreeBuilder() {
};
modes.inSelect.startTagOption = function(name, attributes) {
if (tree.currentStackItem().localName == 'option')
tree.popElement();
tree.insertElement(name, attributes);
@@ -6381,12 +6449,15 @@ function TreeBuilder() {
};
modes.inSelect.endTagOptgroup = function(name) {
if (tree.currentStackItem().localName == 'option' && tree.openElements.item(tree.openElements.length - 2).localName == 'optgroup') {
tree.popElement();
}
if (tree.currentStackItem().localName == 'optgroup') {
tree.popElement();
} else {
tree.parseError('unexpected-end-tag-in-select', {name: 'optgroup'});
}
};
@@ -6401,6 +6472,7 @@ function TreeBuilder() {
tree.openElements.popUntilPopped('select');
tree.resetInsertionMode();
} else {
tree.parseError('unexpected-end-tag', {name: name});
}
};
@@ -6531,6 +6603,7 @@ function TreeBuilder() {
modes.inRow.startTagTableOther = function(name, attributes) {
var ignoreEndTag = this.ignoreEndTagTr();
this.endTagTr('tr');
if (!ignoreEndTag) tree.insertionMode.processStartTag(name, attributes);
};
@@ -6552,6 +6625,8 @@ function TreeBuilder() {
modes.inRow.endTagTable = function(name) {
var ignoreEndTag = this.ignoreEndTagTr();
this.endTagTr('tr');
if (!ignoreEndTag) tree.insertionMode.processEndTag(name);
};
@@ -6560,6 +6635,7 @@ function TreeBuilder() {
this.endTagTr('tr');
tree.insertionMode.processEndTag(name);
} else {
tree.parseError('unexpected-end-tag', {name: name});
}
};
@@ -6680,6 +6756,7 @@ TreeBuilder.prototype.adoptionAgencyEndTag = function(name) {
var outerLoopCounter = 0;
while (outerLoopCounter++ < outerIterationLimit) {
formattingElement = this.elementInActiveFormattingElements(name);
if (!formattingElement || (this.openElements.contains(formattingElement) && !this.openElements.inScope(formattingElement.localName))) {
@@ -6698,6 +6775,8 @@ TreeBuilder.prototype.adoptionAgencyEndTag = function(name) {
if (formattingElement != this.currentStackItem()) {
this.parseError('adoption-agency-1.3', {name: name});
}
var furthestBlock = this.openElements.furthestBlockForFormattingElement(formattingElement.node);
if (!furthestBlock) {
@@ -6802,6 +6881,7 @@ TreeBuilder.prototype.startTokenization = function(tokenizer) {
}
this.insertHtmlElement();
this.resetInsertionMode();
} else {
this.setInsertionMode('initial');
}
@@ -6959,6 +7039,7 @@ TreeBuilder.prototype.shouldFosterParent = function() {
return this.redirectAttachToFosterParent && this.currentStackItem().isFosterParenting();
};
TreeBuilder.prototype.generateImpliedEndTags = function(exclude) {
var name = this.openElements.top.localName;
if (['dd', 'dt', 'li', 'option', 'optgroup', 'p', 'rp', 'rt'].indexOf(name) != -1 && name != exclude) {
this.popElement();
@@ -6966,8 +7047,13 @@ TreeBuilder.prototype.generateImpliedEndTags = function(exclude) {
}
};
TreeBuilder.prototype.reconstructActiveFormattingElements = function() {
if (this.activeFormattingElements.length === 0)
return;
var i = this.activeFormattingElements.length - 1;
var entry = this.activeFormattingElements[i];
if (entry == Marker || this.openElements.contains(entry))
@@ -7026,6 +7112,9 @@ TreeBuilder.prototype.ensureNoahsArkCondition = function(item) {
candidates = remainingCandidates;
remainingCandidates = [];
}
for (var i = kNoahsArkCapacity - 1; i < candidates.length; i++)
this.removeElementFromActiveFormattingElements(candidates[i]);
};
@@ -7056,9 +7145,15 @@ TreeBuilder.prototype.reparentChildren = function(oldParent, newParent) {
throw new Error("Not implemented");
};
TreeBuilder.prototype.setFragmentContext = function(context) {
this.context = context;
};
TreeBuilder.prototype.parseError = function(code, args) {
if (!this.errorHandler)
return;
var message = formatMessage(messages[code], args);
@@ -7076,7 +7171,9 @@ TreeBuilder.prototype.resetInsertionMode = function() {
}
if (node.namespaceURI === "http://www.w3.org/1999/xhtml") {
if (node.localName === 'select')
return this.setInsertionMode('inSelect');
if (node.localName === 'td' || node.localName === 'th')
return this.setInsertionMode('inCell');
@@ -7712,16 +7809,27 @@ SAXTreeBuilder.prototype.addAttributesToElement = function(element, attributes)
};
var NodeType = {
CDATA: 1,
CHARACTERS: 2,
COMMENT: 3,
DOCUMENT: 4,
DOCUMENT_FRAGMENT: 5,
DTD: 6,
ELEMENT: 7,
ENTITY: 8,
IGNORABLE_WHITESPACE: 9,
PROCESSING_INSTRUCTION: 10,
SKIPPED_ENTITY: 11
};
function Node(locator) {
@@ -7736,12 +7844,16 @@ function Node(locator) {
this.nextSibling = null;
this.firstChild = null;
}
Node.prototype.visit = function(treeParser) {
throw new Error("Not Implemented");
};
Node.prototype.revisit = function(treeParser) {
return;
};
Node.prototype.detach = function() {
if (this.parentNode !== null) {
this.parentNode.removeChild(this);
@@ -7772,6 +7884,7 @@ function ParentNode(locator) {
ParentNode.prototype = Object.create(Node.prototype);
ParentNode.prototype.insertBefore = function(child, sibling) {
if (!sibling) {
return this.appendChild(child);
}
@@ -7794,6 +7907,11 @@ ParentNode.prototype.insertBefore = function(child, sibling) {
};
ParentNode.prototype.insertBetween = function(child, prev, next) {
if (!next) {
return this.appendChild(child);
}
@@ -7837,6 +7955,7 @@ ParentNode.prototype.appendChildren = function(parent) {
another.lastChild = null;
};
ParentNode.prototype.removeChild = function(node) {
if (this.firstChild == node) {
this.firstChild = node.nextSibling;
if (this.lastChild == node) {
@@ -7881,6 +8000,7 @@ Document.prototype.visit = function(treeParser) {
Document.prototype.revisit = function(treeParser) {
treeParser.endDocument(this.endLocator);
};
function DocumentFragment() {
ParentNode.call(this, new Locator());
this.nodeType = NodeType.DOCUMENT_FRAGMENT;
@@ -7888,6 +8008,7 @@ function DocumentFragment() {
DocumentFragment.prototype = Object.create(ParentNode.prototype);
DocumentFragment.prototype.visit = function(treeParser) {
};
function Element(locator, uri, localName, qName, atts, prefixMappings) {
ParentNode.call(this, locator);
@@ -7939,6 +8060,7 @@ IgnorableWhitespace.prototype = Object.create(Node.prototype);
IgnorableWhitespace.prototype.visit = function(treeParser) {
treeParser.ignorableWhitespace(this.data, 0, this.data.length, this);
};
function Comment(locator, data) {
Node.call(this, locator);
this.data = data;
@@ -7949,6 +8071,7 @@ Comment.prototype = Object.create(Node.prototype);
Comment.prototype.visit = function(treeParser) {
treeParser.comment(this.data, 0, this.data.length, this);
};
function CDATA(locator) {
ParentNode.call(this, locator);
this.nodeType = NodeType.CDATA;
@@ -7961,6 +8084,7 @@ CDATA.prototype.visit = function(treeParser) {
CDATA.prototype.revisit = function(treeParser) {
treeParser.endCDATA(this.endLocator);
};
function Entity(name) {
ParentNode.call(this);
this.name = name;
@@ -7975,6 +8099,7 @@ Entity.prototype.revisit = function(treeParser) {
treeParser.endEntity(this.name);
};
function SkippedEntity(name) {
Node.call(this);
this.name = name;
@@ -7985,6 +8110,11 @@ SkippedEntity.prototype = Object.create(Node.prototype);
SkippedEntity.prototype.visit = function(treeParser) {
treeParser.skippedEntity(this.name, this);
};
function ProcessingInstruction(target, data) {
Node.call(this);
this.target = target;
@@ -8019,7 +8149,9 @@ exports.SAXTreeBuilder = SAXTreeBuilder;
},
{"../TreeBuilder":6,"util":20}],
11:[function(_dereq_,module,exports){
function TreeParser(contentHandler, lexicalHandler){
this.contentHandler;
this.lexicalHandler;
this.locatorDelegate;
@@ -8034,6 +8166,7 @@ function TreeParser(contentHandler, lexicalHandler){
this.lexicalHandler = lexicalHandler;
}
}
TreeParser.prototype.parse = function(node) {
this.contentHandler.documentLocator = this;
var current = node;
@@ -8143,6 +8276,7 @@ Object.defineProperty(TreeParser.prototype, 'lineNumber', {
return this.locatorDelegate.lineNumber;
}
});
function NullLexicalHandler() {
}

File diff suppressed because one or more lines are too long