mirror of
https://github.com/Jermolene/TiddlyWiki5
synced 2024-11-23 10:07:19 +00:00
Minor refactoring, including switching to strict mode
This commit is contained in:
parent
2e9f334eca
commit
b907d846f3
2
cook.js
2
cook.js
@ -2,6 +2,8 @@
|
||||
//
|
||||
// Usage: node cook.js <recipefile>
|
||||
|
||||
"use strict";
|
||||
|
||||
var TiddlyWiki = require("./js/TiddlyWiki.js").TiddlyWiki,
|
||||
Recipe = require("./js/Recipe.js").Recipe,
|
||||
util = require("util");
|
||||
|
3
ginsu.js
3
ginsu.js
@ -5,6 +5,9 @@
|
||||
// The .html extension is optional
|
||||
//
|
||||
// Ginsu creates the specified places the .tid files in the specified directory (which must already exist)
|
||||
|
||||
"use strict";
|
||||
|
||||
var fs = require("fs"),
|
||||
path = require("path"),
|
||||
Tiddler = require("./js/Tiddler.js").Tiddler,
|
||||
|
@ -17,6 +17,8 @@ Options and their defaults are:
|
||||
|
||||
*/
|
||||
|
||||
"use strict";
|
||||
|
||||
var ArgParser = function(argString,options) {
|
||||
var parseToken = function(match,p) {
|
||||
var n;
|
||||
@ -35,16 +37,16 @@ var ArgParser = function(argString,options) {
|
||||
return n;
|
||||
};
|
||||
this.byPos = [];
|
||||
var dblQuote = "(?:\"((?:(?:\\\\\")|[^\"])+)\")";
|
||||
var sngQuote = "(?:'((?:(?:\\\\\')|[^'])+)')";
|
||||
var dblSquare = "(?:\\[\\[((?:\\s|\\S)*?)\\]\\])";
|
||||
var dblBrace = "(?:\\{\\{((?:\\s|\\S)*?)\\}\\})";
|
||||
var unQuoted = options.noNames ? "([^\"'\\s]\\S*)" : "([^\"':\\s][^\\s:]*)";
|
||||
var emptyQuote = "((?:\"\")|(?:''))";
|
||||
var skipSpace = "(?:\\s*)";
|
||||
var token = "(?:" + dblQuote + "|" + sngQuote + "|" + dblSquare + "|" + dblBrace + "|" + unQuoted + "|" + emptyQuote + ")";
|
||||
var re = options.noNames ? new RegExp(token,"mg") : new RegExp(skipSpace + token + skipSpace + "(?:(\\:)" + skipSpace + token + ")?","mg");
|
||||
var match;
|
||||
var dblQuote = "(?:\"((?:(?:\\\\\")|[^\"])+)\")",
|
||||
sngQuote = "(?:'((?:(?:\\\\\')|[^'])+)')",
|
||||
dblSquare = "(?:\\[\\[((?:\\s|\\S)*?)\\]\\])",
|
||||
dblBrace = "(?:\\{\\{((?:\\s|\\S)*?)\\}\\})",
|
||||
unQuoted = options.noNames ? "([^\"'\\s]\\S*)" : "([^\"':\\s][^\\s:]*)",
|
||||
emptyQuote = "((?:\"\")|(?:''))",
|
||||
skipSpace = "(?:\\s*)",
|
||||
token = "(?:" + dblQuote + "|" + sngQuote + "|" + dblSquare + "|" + dblBrace + "|" + unQuoted + "|" + emptyQuote + ")",
|
||||
re = options.noNames ? new RegExp(token,"mg") : new RegExp(skipSpace + token + skipSpace + "(?:(\\:)" + skipSpace + token + ")?","mg"),
|
||||
match;
|
||||
do {
|
||||
match = re.exec(argString);
|
||||
if(match) {
|
||||
@ -69,8 +71,8 @@ var ArgParser = function(argString,options) {
|
||||
} while(match);
|
||||
this.byName = {};
|
||||
for(var t=0; t<this.byPos.length; t++) {
|
||||
var n = this.byPos[t].n;
|
||||
var v = this.byPos[t].v;
|
||||
var n = this.byPos[t].n,
|
||||
v = this.byPos[t].v;
|
||||
if(n in this.byName)
|
||||
this.byName[n].push(v);
|
||||
else
|
||||
|
@ -3,6 +3,8 @@ FileRetriever can asynchronously retrieve files from HTTP URLs or the local file
|
||||
throttling so that we don't get error EMFILE "Too many open files".
|
||||
*/
|
||||
|
||||
"use strict";
|
||||
|
||||
var fs = require("fs"),
|
||||
path = require("path"),
|
||||
url = require("url"),
|
||||
|
@ -27,6 +27,8 @@ this.ingredients = {
|
||||
|
||||
*/
|
||||
|
||||
"use strict";
|
||||
|
||||
var Tiddler = require("./Tiddler.js").Tiddler,
|
||||
tiddlerInput = require("./TiddlerInput.js"),
|
||||
tiddlerOutput = require("./TiddlerOutput.js"),
|
||||
|
@ -14,6 +14,8 @@ Tiddler.fields - hashmap of tiddler fields
|
||||
|
||||
*/
|
||||
|
||||
"use strict";
|
||||
|
||||
var Tiddler = function(/* tiddler,fields */) {
|
||||
var tiddler, fields, c = 0, t;
|
||||
if(arguments[c] instanceof Tiddler) {
|
||||
|
@ -2,6 +2,8 @@
|
||||
Functions concerned with parsing representations of tiddlers
|
||||
*/
|
||||
|
||||
"use strict";
|
||||
|
||||
var ArgParser = require("./ArgParser.js").ArgParser,
|
||||
utils = require("./Utils.js"),
|
||||
util = require("util");
|
||||
|
@ -2,6 +2,8 @@
|
||||
Functions concerned with parsing representations of tiddlers
|
||||
*/
|
||||
|
||||
"use strict";
|
||||
|
||||
var utils = require("./Utils.js");
|
||||
|
||||
var tiddlerOutput = exports;
|
||||
|
@ -1,3 +1,5 @@
|
||||
"use strict";
|
||||
|
||||
var Tiddler = require("./Tiddler.js").Tiddler;
|
||||
|
||||
var TiddlyWiki = function() {
|
||||
|
@ -2,6 +2,8 @@
|
||||
Functions concerned with parsing TiddlyWiki files
|
||||
*/
|
||||
|
||||
"use strict";
|
||||
|
||||
var tiddlerInput = require("./TiddlerInput.js"),
|
||||
utils = require("./Utils.js");
|
||||
|
||||
|
@ -4,6 +4,8 @@ Various static utility functions.
|
||||
This file is a bit of a dumping ground; the expectation is that most of these functions will be refactored.
|
||||
*/
|
||||
|
||||
"use strict";
|
||||
|
||||
var utils = exports;
|
||||
|
||||
// Pad a string to a certain length with zeros
|
||||
|
Loading…
Reference in New Issue
Block a user