1
0
mirror of https://github.com/Jermolene/TiddlyWiki5 synced 2024-11-23 10:07:19 +00:00

Parameter parenthesis should be mandatory in function/procedure/widget definitions

See https://github.com/Jermolene/TiddlyWiki5/pull/6666#issuecomment-1280404387
This commit is contained in:
jeremy@jermolene.com 2022-10-17 08:31:07 +01:00
parent 3a4589dc79
commit 5194b24108
3 changed files with 6 additions and 6 deletions

View File

@ -35,7 +35,7 @@ Instantiate parse rule
exports.init = function(parser) {
this.parser = parser;
// Regexp to match
this.matchRegExp = /^\\(function|procedure|widget)\s+([^(\s]+)(\(\s*([^)]*)\))?(\s*\r?\n)?/mg;
this.matchRegExp = /^\\(function|procedure|widget)\s+([^(\s]+)\((\s*([^)]*))?\)(\s*\r?\n)?/mg;
};
/*

View File

@ -6,7 +6,7 @@ tags: [[$:/tags/wiki-test-spec]]
title: Output
\whitespace trim
\widget $let
\widget $let()
\whitespace trim
<$parameters $params="@params">
<$setmultiplevariables $names="[<@params>jsonindexes[]]" $values="[<@params>jsonindexes[]] :map[<@params>jsonget<currentTiddler>addprefix[--]addsuffix[--]]">

View File

@ -121,7 +121,7 @@ describe("WikiText parser tests", function() {
});
it("should parse procedure definitions with no parameters", function() {
expect(parse("\\procedure myMacro\nnothing\n\\end\n")).toEqual(
expect(parse("\\procedure myMacro()\nnothing\n\\end\n")).toEqual(
[{"type":"set","attributes":{"name":{"name":"name","type":"string","value":"myMacro"},"value":{"name":"value","type":"string","value":"nothing"}},"children":[],"params":[],"orderedAttributes":[{"name":"name","type":"string","value":"myMacro"},{"name":"value","type":"string","value":"nothing"}],"isProcedureDefinition":true}]
@ -129,7 +129,7 @@ describe("WikiText parser tests", function() {
});
it("should parse single line procedure definitions with no parameters", function() {
expect(parse("\\procedure myMacro nothing\n")).toEqual(
expect(parse("\\procedure myMacro() nothing\n")).toEqual(
[{"type":"set","attributes":{"name":{"name":"name","type":"string","value":"myMacro"},"value":{"name":"value","type":"string","value":"nothing"}},"children":[],"params":[],"orderedAttributes":[{"name":"name","type":"string","value":"myMacro"},{"name":"value","type":"string","value":"nothing"}],"isProcedureDefinition":true}]
@ -152,7 +152,7 @@ describe("WikiText parser tests", function() {
);
}); it("should parse function definitions with no parameters", function() {
expect(parse("\\function myMacro\nnothing\n\\end\n")).toEqual(
expect(parse("\\function myMacro()\nnothing\n\\end\n")).toEqual(
[{"type":"set","attributes":{"name":{"name":"name","type":"string","value":"myMacro"},"value":{"name":"value","type":"string","value":"nothing"}},"children":[],"params":[],"orderedAttributes":[{"name":"name","type":"string","value":"myMacro"},{"name":"value","type":"string","value":"nothing"}],"isFunctionDefinition":true}]
@ -160,7 +160,7 @@ describe("WikiText parser tests", function() {
});
it("should parse single line function definitions with no parameters", function() {
expect(parse("\\function myMacro nothing\n")).toEqual(
expect(parse("\\function myMacro() nothing\n")).toEqual(
[{"type":"set","attributes":{"name":{"name":"name","type":"string","value":"myMacro"},"value":{"name":"value","type":"string","value":"nothing"}},"children":[],"params":[],"orderedAttributes":[{"name":"name","type":"string","value":"myMacro"},{"name":"value","type":"string","value":"nothing"}],"isFunctionDefinition":true}]