1
0
mirror of https://github.com/Jermolene/TiddlyWiki5 synced 2024-11-30 05:19:57 +00:00

lint: useless ai generated comments

This commit is contained in:
lin onetwo 2024-08-10 12:43:26 +08:00
parent 08e9312295
commit 398d7f7fe7
20 changed files with 20 additions and 77 deletions

View File

@ -38,8 +38,7 @@ exports.parse = function() {
};
exports.serialize = function(tree) {
var dash = tree.entity === "–" ? "--" : "---";
return dash;
return tree.entity === "–" ? "--" : "---";
};
})();

View File

@ -48,13 +48,7 @@ exports.parse = function() {
};
exports.serialize = function(tree, serialize) {
var serialized = "''";
// Serialize the children of the bold element
serialized += serialize(tree.children);
// Close the serialized string with the closing delimiter
serialized += "''";
// Return the complete serialized string
return serialized;
return "''" + serialize(tree.children) + "''";
};
})();

View File

@ -48,13 +48,7 @@ exports.parse = function() {
};
exports.serialize = function(tree, serialize) {
var serialized = "//";
// Serialize the children of the italic element
serialized += serialize(tree.children);
// Close the serialized string with the closing delimiter
serialized += "//";
// Return the complete serialized string
return serialized;
return "//" + serialize(tree.children) + "//";
};
})();

View File

@ -48,13 +48,7 @@ exports.parse = function() {
};
exports.serialize = function(tree, serialize) {
var serialized = "~~";
// Serialize the children of the strikethrough element
serialized += serialize(tree.children);
// Close the serialized string with the closing delimiter
serialized += "~~";
// Return the complete serialized string
return serialized;
return "~~" + serialize(tree.children) + "~~";
};
})();

View File

@ -48,13 +48,7 @@ exports.parse = function() {
};
exports.serialize = function(tree, serialize) {
var serialized = ",,";
// Serialize the children of the subscript element
serialized += serialize(tree.children);
// Close the serialized string with the closing delimiter
serialized += ",,";
// Return the complete serialized string
return serialized;
return ",," + serialize(tree.children) + ",,";
};
})();

View File

@ -48,13 +48,7 @@ exports.parse = function() {
};
exports.serialize = function(tree, serialize) {
var serialized = "^^";
// Serialize the children of the superscript element
serialized += serialize(tree.children);
// Close the serialized string with the closing delimiter
serialized += "^^";
// Return the complete serialized string
return serialized;
return "^^" + serialize(tree.children) + "^^";
};
})();

View File

@ -48,13 +48,7 @@ exports.parse = function() {
};
exports.serialize = function(tree, serialize) {
var serialized = "__";
// Serialize the children of the underscore element
serialized += serialize(tree.children);
// Close the serialized string with the closing delimiter
serialized += "__";
// Return the complete serialized string
return serialized;
return "__" + serialize(tree.children) + "__";
};
})();

View File

@ -37,7 +37,6 @@ exports.parse = function() {
return [{type: "entity", entity: this.match[0]}];
};
// Serialize method for the entity rule
exports.serialize = function(tree, serialize) {
return tree.entity;
};

View File

@ -60,15 +60,14 @@ exports.parse = function() {
};
exports.serialize = function(tree,serialize) {
// we get each of element on tree from `parse` one by one here.
var text = tree.tag === 'br' ? '\n' : tree.text;
var text = tree.tag === "br" ? "\n" : (tree.text || "");
if(tree.isRuleStart) {
return '"""\n' + text;
}
if(tree.isRuleEnd) {
return text + '"""';
}
return text;
return text + serialize(tree.children);
};
})();

View File

@ -66,7 +66,7 @@ exports.parse = function() {
}
tag.end = this.parser.pos;
tag.closeTagEnd = tag.end;
if(tag.closeTagEnd === tag.openTagEnd || this.parser.source[tag.closeTagEnd - 1] !== '>') {
if(tag.closeTagEnd === tag.openTagEnd || this.parser.source[tag.closeTagEnd - 1] !== ">") {
tag.closeTagStart = tag.end;
} else {
tag.closeTagStart = tag.closeTagEnd - 2;
@ -74,11 +74,11 @@ exports.parse = function() {
if(!Number.isSafeInteger(closeTagMinPos)) closeTagMinPos = tag.openTagEnd;
while(tag.closeTagStart >= closeTagMinPos) {
var char = this.parser.source[tag.closeTagStart];
if(char === '>') {
if(char === ">") {
tag.closeTagStart = -1;
break;
}
if(char === '<') break;
if(char === "<") break;
tag.closeTagStart -= 1;
}
if(tag.closeTagStart < closeTagMinPos) {
@ -199,9 +199,9 @@ exports.serialize = function(tree, serialize) {
var tag = tree.tag;
var attributes = Object.keys(tree.attributes).map(function(key) {
return key + '="' + tree.attributes[key].value + '"';
}).join('');
}).join("");
// Children
var children = tree.children ? serialize(tree.children) : '';
var children = tree.children ? serialize(tree.children) : "";
// Self-closing tag
if(tree.isSelfClosing) {
return "<" + tag + (attributes ? " " + attributes : "") + " />";

View File

@ -52,9 +52,8 @@ exports.parse = function() {
};
exports.serialize = function(tree,serialize) {
// Filter attribute
var filter = tree.attributes.filter.value;
// Construct the serialized string with children that is actually the sibling below the pragma.
// Sibling below the pragma become children, so we append the serialized children to the end..
return "\\import " + filter + "\n" + serialize(tree.children);
};

View File

@ -57,16 +57,16 @@ exports.parse = function() {
Serialize a macro call node to wikitext
*/
exports.serialize = function (node) {
// Start with macro opener
var result = "<<";
// Macro name
if(node.attributes && node.attributes["$variable"]) {
result += node.attributes["$variable"].value; // Add macro name
result += node.attributes["$variable"].value;
}
// Append ordered arguments if any
if(node.orderedAttributes) {
node.orderedAttributes.forEach(function (attr) {
if(attr.name !== "$variable") {
result += " " + '"' + attr.value + '"'; // Add each additional value
result += " " + '"' + attr.value + '"';
}
});
}

View File

@ -90,15 +90,11 @@ exports.parse = function() {
};
exports.serialize = function(tree,serialize) {
// Macro name
var name = tree.attributes.name.value;
// Parameters
var params = tree.params.map(function(param) {
return param.name + (param.default ? ":" + param.default : "");
}).join(",");
// Definition text
var definition = tree.attributes.value.value;
// Construct the serialized string
return "\\define " + name + "(" + params + ")\n" + definition + "\n\\end\n\n" + serialize(tree.children);
};

View File

@ -58,11 +58,9 @@ exports.parse = function() {
};
exports.serialize = function(tree,serialize) {
// Parameters
var params = tree.orderedAttributes.map(function(param) {
return param.name + (param.value ? ":" + param.value : "");
}).join(",");
// Construct the serialized string
return "\\parameters(" + params + ")\n\n" + serialize(tree.children);
};

View File

@ -118,11 +118,8 @@ exports.parseLink = function(source,pos) {
};
exports.serialize = function(tree) {
// Tooltip text
var tooltip = tree.children[0].text;
// URL
var url = tree.attributes.href.value;
// Construct the serialized string
return "[ext[" + (tooltip !== url ? tooltip + "|" : "") + url + "]]";
};

View File

@ -68,11 +68,8 @@ exports.parse = function() {
};
exports.serialize = function(tree) {
// Link text
var text = tree.children[0].text;
// Link target
var target = tree.attributes.to ? tree.attributes.to.value : tree.attributes.href.value;
// Construct the serialized string
return "[[" + text + (text !== target ? "|" + target : "") + "]]";
};

View File

@ -53,11 +53,9 @@ exports.parse = function() {
exports.serialize = function(tree, serialize) {
// Check if the link is suppressed
var isSuppressed = tree.children[0].text.substr(0,1) === "~";
var serialized = isSuppressed ? "~" : "";
// Append the link value
// Append the link text
serialized += tree.attributes.to.value;
// Return the complete serialized string
return serialized;
};

View File

@ -130,9 +130,7 @@ exports.serialize = function(tree, serialize) {
} else if(tree.type === "transclude") {
handleTransclude(tree);
}
// Close the result string
result += "}}\n\n";
// Return the complete result string
return result;
};

View File

@ -78,6 +78,7 @@ exports.parse = function() {
container = $tw.fakeDocument.createElement("div");
widgetNode.render(container,null);
var renderResult = renderType === "text/html" ? container.innerHTML : container.textContent;
// Use void node to carry important info for typedblock
return [{
type: "void",
children: [{
@ -99,7 +100,6 @@ exports.parse = function() {
exports.serialize = function (tree, serialize) {
if(tree.type === "void") {
// Directly process the tree's text content
return "$$$" + tree.parseType + (tree.renderType ? " > " + tree.renderType : "") + "\n" + tree.text + "\n$$$\n\n";
}
return "";

View File

@ -66,7 +66,6 @@ exports.parse = function() {
};
exports.serialize = function(tree, serialize) {
// Check if the link is suppressed
var isSuppressed = tree.children[0].text.substr(0,1) === $tw.config.textPrimitives.unWikiLink;
var serialized = isSuppressed ? $tw.config.textPrimitives.unWikiLink : "";