mirror of
https://github.com/Jermolene/TiddlyWiki5
synced 2025-12-10 10:48:05 +00:00
Allow brackets to be omitted for function definitions with no parameters
This commit is contained in:
@@ -27,7 +27,7 @@ Instantiate parse rule
|
||||
exports.init = function(parser) {
|
||||
this.parser = parser;
|
||||
// Regexp to match
|
||||
this.matchRegExp = /^\\function\s+([^(\s]+)\(\s*([^)]*)\)(\s*\r?\n)?/mg;
|
||||
this.matchRegExp = /^\\function\s+([^(\s]+)(\(\s*([^)]*)\))?(\s*\r?\n)?/mg;
|
||||
};
|
||||
|
||||
/*
|
||||
@@ -37,9 +37,9 @@ exports.parse = function() {
|
||||
// Move past the macro name and parameters
|
||||
this.parser.pos = this.matchRegExp.lastIndex;
|
||||
// Parse the parameters
|
||||
var paramString = this.match[2],
|
||||
var paramString = this.match[3],
|
||||
params = [];
|
||||
if(paramString !== "") {
|
||||
if(this.match[2]) {
|
||||
var reParam = /\s*([A-Za-z0-9\-_]+)(?:\s*:\s*(?:"""([\s\S]*?)"""|"([^"]*)"|'([^']*)'|([^"'\s]+)))?/mg,
|
||||
paramMatch = reParam.exec(paramString);
|
||||
while(paramMatch) {
|
||||
@@ -56,7 +56,7 @@ exports.parse = function() {
|
||||
}
|
||||
// Is this a multiline definition?
|
||||
var reEnd;
|
||||
if(this.match[3]) {
|
||||
if(this.match[4]) {
|
||||
// If so, the end of the body is marked with \end
|
||||
reEnd = /(\r?\n\\end[^\S\n\r]*(?:$|\r?\n))/mg;
|
||||
} else {
|
||||
|
||||
Reference in New Issue
Block a user