1
0
mirror of https://github.com/Jermolene/TiddlyWiki5 synced 2024-11-10 20:09:57 +00:00

Fix whitespace in all plugins for v5.3.6 (#8285)

* Fix whitespace in all plugins for v5.3.5

* remove const to var chanes
This commit is contained in:
Mario Pietsch 2024-08-20 17:33:07 +02:00 committed by GitHub
parent 014f302af3
commit 231a39e743
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
14 changed files with 58 additions and 58 deletions

View File

@ -68,11 +68,11 @@ exports.startup = function() {
persistPermissionRequested = false, persistPermissionRequested = false,
requestPersistenceOnFirstSave = function() { requestPersistenceOnFirstSave = function() {
$tw.hooks.addHook("th-saving-tiddler", function(tiddler) { $tw.hooks.addHook("th-saving-tiddler", function(tiddler) {
if (!persistPermissionRequested) { if(!persistPermissionRequested) {
var filteredChanges = filterFn.call($tw.wiki, function(iterator) { var filteredChanges = filterFn.call($tw.wiki, function(iterator) {
iterator(tiddler,tiddler.getFieldString("title")); iterator(tiddler,tiddler.getFieldString("title"));
}); });
if (filteredChanges.length > 0) { if(filteredChanges.length > 0) {
// The tiddler will be saved to local storage, so request persistence // The tiddler will be saved to local storage, so request persistence
requestPersistence(); requestPersistence();
persistPermissionRequested = true; persistPermissionRequested = true;
@ -84,9 +84,9 @@ exports.startup = function() {
// Request the browser to never evict the localstorage. Some browsers such as firefox // Request the browser to never evict the localstorage. Some browsers such as firefox
// will prompt the user. To make the decision easier for the user only prompt them // will prompt the user. To make the decision easier for the user only prompt them
// when they click the save button on a tiddler which will be stored to localstorage. // when they click the save button on a tiddler which will be stored to localstorage.
if (navigator.storage && navigator.storage.persist) { if(navigator.storage && navigator.storage.persist) {
navigator.storage.persisted().then(function(isPersisted) { navigator.storage.persisted().then(function(isPersisted) {
if (!isPersisted) { if(!isPersisted) {
setPersistedState("not requested yet"); setPersistedState("not requested yet");
requestPersistenceOnFirstSave(); requestPersistenceOnFirstSave();
} else { } else {

View File

@ -53,7 +53,7 @@ BrowserStorageUtil.prototype.saveTiddlerToLocalStorage = function(title) {
// Get the tiddler // Get the tiddler
var tiddler = $tw.wiki.getTiddler(title); var tiddler = $tw.wiki.getTiddler(title);
if(tiddler) { if(tiddler) {
if (this.wiki.tiddlerExists(title)) { if(this.wiki.tiddlerExists(title)) {
// This is not a shadow tiddler // This is not a shadow tiddler
console.log("browser-storage: Saving",title); console.log("browser-storage: Saving",title);
// Get the JSON of the tiddler // Get the JSON of the tiddler

View File

@ -122,7 +122,7 @@ BarWidget.prototype.createChart = function(parent,nextSibling) {
return { return {
domNode: svgElement[0][0], domNode: svgElement[0][0],
updateChart: function() { updateChart: function() {
if (self.barGrouped !== "no") { if(self.barGrouped !== "no") {
transitionGrouped(); transitionGrouped();
} else { } else {
transitionStacked(); transitionStacked();
@ -160,14 +160,14 @@ BarWidget.prototype.createChart = function(parent,nextSibling) {
var x = 1 / (0.1 + Math.random()), var x = 1 / (0.1 + Math.random()),
y = 2 * Math.random() - 0.5, y = 2 * Math.random() - 0.5,
z = 10 / (0.1 + Math.random()); z = 10 / (0.1 + Math.random());
for (var i = 0; i < n; i++) { for(var i = 0; i < n; i++) {
var w = (i / n - y) * z; var w = (i / n - y) * z;
a[i] += x * Math.exp(-w * w); a[i] += x * Math.exp(-w * w);
} }
} }
var a = [], i; var a = [], i;
for (i = 0; i < n; ++i) a[i] = o + o * Math.random(); for(i = 0; i < n; ++i) a[i] = o + o * Math.random();
for (i = 0; i < 5; ++i) bump(a); for(i = 0; i < 5; ++i) bump(a);
return a.map(function(d, i) { return {x: i, y: Math.max(0, d)}; }); return a.map(function(d, i) { return {x: i, y: Math.max(0, d)}; });
} }
}; };

View File

@ -84,7 +84,7 @@ FileSystemAdaptor.prototype.saveTiddler = function(tiddler,callback,options) {
} }
$tw.utils.saveTiddlerToFile(tiddler,fileInfo,function(err,fileInfo) { $tw.utils.saveTiddlerToFile(tiddler,fileInfo,function(err,fileInfo) {
if(err) { if(err) {
if ((err.code == "EPERM" || err.code == "EACCES") && err.syscall == "open") { if((err.code == "EPERM" || err.code == "EACCES") && err.syscall == "open") {
fileInfo = fileInfo || self.boot.files[tiddler.fields.title]; fileInfo = fileInfo || self.boot.files[tiddler.fields.title];
fileInfo.writeError = true; fileInfo.writeError = true;
self.boot.files[tiddler.fields.title] = fileInfo; self.boot.files[tiddler.fields.title] = fileInfo;
@ -131,7 +131,7 @@ FileSystemAdaptor.prototype.deleteTiddler = function(title,callback,options) {
if(fileInfo) { if(fileInfo) {
$tw.utils.deleteTiddlerFile(fileInfo,function(err,fileInfo) { $tw.utils.deleteTiddlerFile(fileInfo,function(err,fileInfo) {
if(err) { if(err) {
if ((err.code == "EPERM" || err.code == "EACCES") && err.syscall == "unlink") { if((err.code == "EPERM" || err.code == "EACCES") && err.syscall == "unlink") {
// Error deleting the file on disk, should fail gracefully // Error deleting the file on disk, should fail gracefully
$tw.syncer.displayError("Server desynchronized. Error deleting file for deleted tiddler \"" + title + "\"",err); $tw.syncer.displayError("Server desynchronized. Error deleting file for deleted tiddler \"" + title + "\"",err);
return callback(null,fileInfo); return callback(null,fileInfo);

View File

@ -21,7 +21,7 @@ katex.updateMacros = function() {
var tiddlers = $tw.wiki.getTiddlersWithTag("$:/tags/KaTeX/Macro"), var tiddlers = $tw.wiki.getTiddlersWithTag("$:/tags/KaTeX/Macro"),
regex = /#\d/g, // Remove the arguments like #1#2 regex = /#\d/g, // Remove the arguments like #1#2
tid, macro, cmd; tid, macro, cmd;
for (var i=0; i < tiddlers.length; i++) { for(var i=0; i < tiddlers.length; i++) {
tid = $tw.wiki.getTiddler(tiddlers[i]); tid = $tw.wiki.getTiddler(tiddlers[i]);
try { try {
macro = tid.fields["caption"]; macro = tid.fields["caption"];

View File

@ -31,17 +31,17 @@ function isValidDelim(state, pos) {
// Check non-whitespace conditions for opening and closing, and // Check non-whitespace conditions for opening and closing, and
// check that closing delimeter isn't followed by a number // check that closing delimeter isn't followed by a number
if (prevChar === 0x20/* " " */ || prevChar === 0x09/* \t */ || if(prevChar === 0x20/* " " */ || prevChar === 0x09/* \t */ ||
prevChar === 0x0d/* "\r" */ || prevChar === 0x0a/* \n */ || prevChar === 0x0d/* "\r" */ || prevChar === 0x0a/* \n */ ||
(nextChar >= 0x30/* "0" */ && nextChar <= 0x39/* "9" */)) { (nextChar >= 0x30/* "0" */ && nextChar <= 0x39/* "9" */)) {
can_close = false; can_close = false;
} }
if (nextChar === 0x20/* " " */ || nextChar === 0x09/* \t */ || if(nextChar === 0x20/* " " */ || nextChar === 0x09/* \t */ ||
nextChar === 0x0d/* "\r" */ || nextChar === 0x0a/* \ns */) { nextChar === 0x0d/* "\r" */ || nextChar === 0x0a/* \ns */) {
can_open = false; can_open = false;
} }
if (state.src.substring(pos,pos+3) === "$:/") { if(state.src.substring(pos,pos+3) === "$:/") {
can_open = false; can_open = false;
can_close = false; can_close = false;
} }
@ -55,11 +55,11 @@ function isValidDelim(state, pos) {
function math_inline(state, silent) { function math_inline(state, silent) {
var start, match, token, res, pos, esc_count; var start, match, token, res, pos, esc_count;
if (state.src[state.pos] !== "$") { return false; } if(state.src[state.pos] !== "$") { return false; }
res = isValidDelim(state, state.pos); res = isValidDelim(state, state.pos);
if (!res.can_open) { if(!res.can_open) {
if (!silent) { state.pending += "$"; } if(!silent) { state.pending += "$"; }
state.pos += 1; state.pos += 1;
return true; return true;
} }
@ -70,40 +70,40 @@ function math_inline(state, silent) {
// we have found an opening delimieter already. // we have found an opening delimieter already.
start = state.pos + 1; start = state.pos + 1;
match = start; match = start;
while ( (match = state.src.indexOf("$", match)) !== -1) { while( (match = state.src.indexOf("$", match)) !== -1) {
// Found potential $, look for escapes, pos will point to // Found potential $, look for escapes, pos will point to
// first non escape when complete // first non escape when complete
pos = match - 1; pos = match - 1;
while (state.src[pos] === "\\") { pos -= 1; } while(state.src[pos] === "\\") { pos -= 1; }
// Even number of escapes, potential closing delimiter found // Even number of escapes, potential closing delimiter found
if ( ((match - pos) % 2) == 1 ) { break; } if( ((match - pos) % 2) == 1 ) { break; }
match += 1; match += 1;
} }
// No closing delimter found. Consume $ and continue. // No closing delimter found. Consume $ and continue.
if (match === -1) { if(match === -1) {
if (!silent) { state.pending += "$"; } if(!silent) { state.pending += "$"; }
state.pos = start; state.pos = start;
return true; return true;
} }
// Check if we have empty content, ie: $$. Do not parse. // Check if we have empty content, ie: $$. Do not parse.
if (match - start === 0) { if(match - start === 0) {
if (!silent) { state.pending += "$$"; } if(!silent) { state.pending += "$$"; }
state.pos = start + 1; state.pos = start + 1;
return true; return true;
} }
// Check for valid closing delimiter // Check for valid closing delimiter
res = isValidDelim(state, match); res = isValidDelim(state, match);
if (!res.can_close) { if(!res.can_close) {
if (!silent) { state.pending += "$"; } if(!silent) { state.pending += "$"; }
state.pos = start; state.pos = start;
return true; return true;
} }
if (!silent) { if(!silent) {
token = state.push('math_inline', '$latex', 0); token = state.push('math_inline', '$latex', 0);
token.markup = "$"; token.markup = "$";
token.content = state.src.slice(start, match); token.content = state.src.slice(start, match);
@ -126,32 +126,32 @@ function math_inline_block(state, silent) {
// we have found an opening delimieter already. // we have found an opening delimieter already.
start = state.pos + 2; start = state.pos + 2;
match = start; match = start;
while ( (match = state.src.indexOf("$$", match)) !== -1) { while( (match = state.src.indexOf("$$", match)) !== -1) {
// Found potential $$, look for escapes, pos will point to // Found potential $$, look for escapes, pos will point to
// first non escape when complete // first non escape when complete
pos = match - 1; pos = match - 1;
while (state.src[pos] === "\\") { pos -= 1; } while(state.src[pos] === "\\") { pos -= 1; }
// Even number of escapes, potential closing delimiter found // Even number of escapes, potential closing delimiter found
if ( ((match - pos) % 2) == 1 ) { break; } if( ((match - pos) % 2) == 1 ) { break; }
match += 2; match += 2;
} }
// No closing delimter found. Consume $$ and continue. // No closing delimter found. Consume $$ and continue.
if (match === -1) { if(match === -1) {
if (!silent) { state.pending += "$$"; } if(!silent) { state.pending += "$$"; }
state.pos = start; state.pos = start;
return true; return true;
} }
// Check if we have empty content, ie: $$$$. Do not parse. // Check if we have empty content, ie: $$$$. Do not parse.
if (match - start === 0) { if(match - start === 0) {
if (!silent) { state.pending += "$$$$"; } if(!silent) { state.pending += "$$$$"; }
state.pos = start + 2; state.pos = start + 2;
return true; return true;
} }
if (!silent) { if(!silent) {
token = state.push('math_inline_block', '$latex', 0); token = state.push('math_inline_block', '$latex', 0);
token.block = true; token.block = true;
token.markup = "$$"; token.markup = "$$";

View File

@ -234,12 +234,12 @@ function MarkdownParser(type,text,options) {
rules: { pragma: {}, block: this.blockRuleClasses, inline: this.inlineRuleClasses } rules: { pragma: {}, block: this.blockRuleClasses, inline: this.inlineRuleClasses }
}); });
} }
catch (err) { catch(err) {
wikiParser = $tw.wiki.parseText("text/vnd.tiddlywiki", wikiParser = $tw.wiki.parseText("text/vnd.tiddlywiki",
"<strong>Error encountered while parsing the tiddler:</strong><p>" + err.message + "</p>", "<strong>Error encountered while parsing the tiddler:</strong><p>" + err.message + "</p>",
{parseAsInline: false, wiki: options.wiki}); {parseAsInline: false, wiki: options.wiki});
} }
finally { finally{
$tw.utils.parseStringLiteral = origParseStringLiteral; $tw.utils.parseStringLiteral = origParseStringLiteral;
} }
if(wikiParser.tree.length > 0) { if(wikiParser.tree.length > 0) {

View File

@ -37,7 +37,7 @@ exports.run = function(text,size,errorCorrectLevel,fallback) {
var result; var result;
try { try {
result = generateQrCode(text,{size: size, errorCorrectLevel: errorCorrectLevel}); result = generateQrCode(text,{size: size, errorCorrectLevel: errorCorrectLevel});
} catch (ex) { } catch(ex) {
console.log("makeqr error: " + ex); console.log("makeqr error: " + ex);
result = fallback || ("data:image/svg+xml," + encodeURI(QRCODE_GENERATION_ERROR_PREFIX + ex + QRCODE_GENERATION_ERROR_SUFFIX)); result = fallback || ("data:image/svg+xml," + encodeURI(QRCODE_GENERATION_ERROR_PREFIX + ex + QRCODE_GENERATION_ERROR_SUFFIX));
} }
@ -54,7 +54,7 @@ function generateQrCode(text,options) {
qr = qrcode(typeNumber,errorCorrectLevel); qr = qrcode(typeNumber,errorCorrectLevel);
qr.addData(text); qr.addData(text);
qr.make(); qr.make();
} catch (e) { } catch(e) {
if(typeNumber >= 40) { if(typeNumber >= 40) {
throw new Error("Text too long to encode"); throw new Error("Text too long to encode");
} else { } else {

View File

@ -377,7 +377,7 @@ Parser.prototype.tokenise = function(source) {
// Skip whitespace // Skip whitespace
pos = $tw.utils.skipWhiteSpace(source,pos); pos = $tw.utils.skipWhiteSpace(source,pos);
// Avoid falling off the end of the string // Avoid falling off the end of the string
if (pos >= source.length) { if(pos >= source.length) {
break; break;
} }
// Examine the next character // Examine the next character

View File

@ -365,7 +365,7 @@ Slicer.prototype.onCloseTag = function(name) {
// Render the tag // Render the tag
if(actions.isAnchor) { if(actions.isAnchor) {
this.onCloseAnchor(e); this.onCloseAnchor(e);
} else if (!actions.dontRenderTag && !selfClosing) { } else if(!actions.dontRenderTag && !selfClosing) {
var markupInfo = actions.markup && actions.markup[this.outputMode]; var markupInfo = actions.markup && actions.markup[this.outputMode];
if(markupInfo) { if(markupInfo) {
this.addTextToCurrentChunk(markupInfo.suffix); this.addTextToCurrentChunk(markupInfo.suffix);

View File

@ -84,7 +84,7 @@ TiddlyWebAdaptor.prototype.getStatus = function(callback) {
var json = null; var json = null;
try { try {
json = JSON.parse(data); json = JSON.parse(data);
} catch (e) { } catch(e) {
} }
if(json) { if(json) {
self.logger.log("Status:",data); self.logger.log("Status:",data);
@ -164,7 +164,7 @@ TiddlyWebAdaptor.prototype.getCsrfToken = function() {
var regex = /^(?:.*; )?csrf_token=([^(;|$)]*)(?:;|$)/, var regex = /^(?:.*; )?csrf_token=([^(;|$)]*)(?:;|$)/,
match = regex.exec(document.cookie), match = regex.exec(document.cookie),
csrf = null; csrf = null;
if (match && (match.length === 2)) { if(match && (match.length === 2)) {
csrf = match[1]; csrf = match[1];
} }
return csrf; return csrf;

View File

@ -21,7 +21,7 @@ exports.params = [
Run the macro Run the macro
*/ */
exports.run = function(key,map) { exports.run = function(key,map) {
try{ try {
return JSON.parse(map)[key]; return JSON.parse(map)[key];
} catch(e) { } catch(e) {
return ""; return "";

View File

@ -70,7 +70,7 @@ var WikiTextParser = function(type,text,options) {
var root = JSON.parse(JSON.stringify(parser.tree)); var root = JSON.parse(JSON.stringify(parser.tree));
// macros are defined in a linear tree; walk down the tree and append the source's parsed content // macros are defined in a linear tree; walk down the tree and append the source's parsed content
var baseroot = root; var baseroot = root;
while (root[0] && root[0].children && root[0].children.length !== 0 ){ while(root[0] && root[0].children && root[0].children.length !== 0 ){
root = root[0].children; root = root[0].children;
} }
root[0].children[0] = this.tree[0]; root[0].children[0] = this.tree[0];

View File

@ -249,7 +249,7 @@ var rules = [
} }
applyCssHelper(cell,styles); applyCssHelper(cell,styles);
w.subWikifyTerm(cell.children,this.cellTermRegExp); w.subWikifyTerm(cell.children,this.cellTermRegExp);
if (!cell.attributes) cell.attributes ={}; if(!cell.attributes) cell.attributes ={};
if(w.matchText.substr(w.matchText.length-2,1) == " ") // spaceRight if(w.matchText.substr(w.matchText.length-2,1) == " ") // spaceRight
$tw.utils.addAttributeToParseTreeNode(cell,"align",spaceLeft ? "center" : "left"); $tw.utils.addAttributeToParseTreeNode(cell,"align",spaceLeft ? "center" : "left");
else if(spaceLeft) else if(spaceLeft)
@ -370,9 +370,9 @@ var rules = [
var f = stack[stack.length-1]; var f = stack[stack.length-1];
e = {type:"element",tag:this.element,children: []}; e = {type:"element",tag:this.element,children: []};
stack.push(e); stack.push(e);
if (t ===0){ if(t ===0){
w.output.push(e); w.output.push(e);
}else { } else {
f.children.push(e); f.children.push(e);
} }
@ -458,7 +458,7 @@ var rules = [
w.source = oldSource; w.source = oldSource;
w.nextMatch = oldNextMatch; w.nextMatch = oldNextMatch;
w.children = oldChildren; w.children = oldChildren;
for (var i=0; i<parser.tree.length; i++) { for(var i=0; i<parser.tree.length; i++) {
w.output.push(parser.tree[i]); w.output.push(parser.tree[i]);
} }
w.nextMatch = this.lookaheadRegExp.lastIndex; w.nextMatch = this.lookaheadRegExp.lastIndex;
@ -488,12 +488,12 @@ var rules = [
if(lookaheadMatch && lookaheadMatch.index == w.matchStart) { if(lookaheadMatch && lookaheadMatch.index == w.matchStart) {
name = lookaheadMatch[1] || lookaheadMatch[2]; name = lookaheadMatch[1] || lookaheadMatch[2];
var params = lookaheadMatch[3], nameold =name; var params = lookaheadMatch[3], nameold =name;
if (name) { if(name) {
if (!!macroadapter.paramadapter[name]) { if(!!macroadapter.paramadapter[name]) {
params=macroadapter.paramadapter[name](params); params=macroadapter.paramadapter[name](params);
//alert("going out as "+params); //alert("going out as "+params);
} }
if (!!macroadapter.namedapter[name]) { if(!!macroadapter.namedapter[name]) {
name=macroadapter.namedapter[name]; name=macroadapter.namedapter[name];
} }
w.nextMatch = this.lookaheadRegExp.lastIndex; w.nextMatch = this.lookaheadRegExp.lastIndex;