mirror of
https://github.com/Jermolene/TiddlyWiki5
synced 2024-12-26 18:10:27 +00:00
added triple double-quotes delimiters for marco/widget parameters (to support json strings)
This commit is contained in:
parent
9147cadd3c
commit
a2ec4c55e3
@ -99,11 +99,13 @@ exports.parseStringLiteral = function(source,pos) {
|
|||||||
type: "string",
|
type: "string",
|
||||||
start: pos
|
start: pos
|
||||||
};
|
};
|
||||||
var reString = /(?:"([^"]*)")|(?:'([^']*)')/g;
|
var reString = /(?:"""([\s\S]*?)"""|"([^"]*)")|(?:'([^']*)')/g;
|
||||||
reString.lastIndex = pos;
|
reString.lastIndex = pos;
|
||||||
var match = reString.exec(source);
|
var match = reString.exec(source);
|
||||||
if(match && match.index === pos) {
|
if(match && match.index === pos) {
|
||||||
node.value = match[1] === undefined ? match[2] : match[1];
|
node.value = match[1] !== undefined ? match[1] :(
|
||||||
|
match[2] !== undefined ? match[2] : match[3]
|
||||||
|
);
|
||||||
node.end = pos + match[0].length;
|
node.end = pos + match[0].length;
|
||||||
return node;
|
return node;
|
||||||
} else {
|
} else {
|
||||||
@ -134,7 +136,9 @@ exports.parseMacroParameter = function(source,pos) {
|
|||||||
token.match[3] !== undefined ? token.match[3] : (
|
token.match[3] !== undefined ? token.match[3] : (
|
||||||
token.match[4] !== undefined ? token.match[4] : (
|
token.match[4] !== undefined ? token.match[4] : (
|
||||||
token.match[5] !== undefined ? token.match[5] : (
|
token.match[5] !== undefined ? token.match[5] : (
|
||||||
""
|
token.match[6] !== undefined ? token.match[6] : (
|
||||||
|
""
|
||||||
|
)
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
|
@ -35,12 +35,12 @@ exports.parse = function() {
|
|||||||
// Move past the macro call
|
// Move past the macro call
|
||||||
this.parser.pos = this.matchRegExp.lastIndex;
|
this.parser.pos = this.matchRegExp.lastIndex;
|
||||||
var params = [],
|
var params = [],
|
||||||
reParam = /\s*(?:([A-Za-z0-9\-_]+)\s*:)?(?:\s*(?:"([^"]*)"|'([^']*)'|\[\[([^\]]*)\]\]|([^"'\s]+)))/mg,
|
reParam = /\s*(?:([A-Za-z0-9\-_]+)\s*:)?(?:\s*(?:"""([\s\S]*?)"""|"([^"]*)"|'([^']*)'|\[\[([^\]]*)\]\]|([^"'\s]+)))/mg,
|
||||||
paramMatch = reParam.exec(paramString);
|
paramMatch = reParam.exec(paramString);
|
||||||
while(paramMatch) {
|
while(paramMatch) {
|
||||||
// Process this parameter
|
// Process this parameter
|
||||||
var paramInfo = {
|
var paramInfo = {
|
||||||
value: paramMatch[2] || paramMatch[3] || paramMatch[4] || paramMatch[5]
|
value: paramMatch[2] || paramMatch[3] || paramMatch[4] || paramMatch[5] || paramMatch[6]
|
||||||
};
|
};
|
||||||
if(paramMatch[1]) {
|
if(paramMatch[1]) {
|
||||||
paramInfo.name = paramMatch[1];
|
paramInfo.name = paramMatch[1];
|
||||||
|
@ -35,12 +35,12 @@ exports.parse = function() {
|
|||||||
// Move past the macro call
|
// Move past the macro call
|
||||||
this.parser.pos = this.matchRegExp.lastIndex;
|
this.parser.pos = this.matchRegExp.lastIndex;
|
||||||
var params = [],
|
var params = [],
|
||||||
reParam = /\s*(?:([A-Za-z0-9\-_]+)\s*:)?(?:\s*(?:"([^"]*)"|'([^']*)'|\[\[([^\]]*)\]\]|([^"'\s]+)))/mg,
|
reParam = /\s*(?:([A-Za-z0-9\-_]+)\s*:)?(?:\s*(?:"""([\s\S]*?)"""|"([^"]*)"|'([^']*)'|\[\[([^\]]*)\]\]|([^"'\s]+)))/mg,
|
||||||
paramMatch = reParam.exec(paramString);
|
paramMatch = reParam.exec(paramString);
|
||||||
while(paramMatch) {
|
while(paramMatch) {
|
||||||
// Process this parameter
|
// Process this parameter
|
||||||
var paramInfo = {
|
var paramInfo = {
|
||||||
value: paramMatch[2] || paramMatch[3] || paramMatch[4] || paramMatch[5]
|
value: paramMatch[2] || paramMatch[3] || paramMatch[4] || paramMatch[5]|| paramMatch[6]
|
||||||
};
|
};
|
||||||
if(paramMatch[1]) {
|
if(paramMatch[1]) {
|
||||||
paramInfo.name = paramMatch[1];
|
paramInfo.name = paramMatch[1];
|
||||||
|
@ -40,12 +40,12 @@ exports.parse = function() {
|
|||||||
var paramString = this.match[2],
|
var paramString = this.match[2],
|
||||||
params = [];
|
params = [];
|
||||||
if(paramString !== "") {
|
if(paramString !== "") {
|
||||||
var reParam = /\s*([A-Za-z0-9\-_]+)(?:\s*:\s*(?:"([^"]*)"|'([^']*)'|\[\[([^\]]*)\]\]|([^"'\s]+)))?/mg,
|
var reParam = /\s*([A-Za-z0-9\-_]+)(?:\s*:\s*(?:"""([\s\S]*?)"""|"([^"]*)"|'([^']*)'|\[\[([^\]]*)\]\]|([^"'\s]+)))?/mg,
|
||||||
paramMatch = reParam.exec(paramString);
|
paramMatch = reParam.exec(paramString);
|
||||||
while(paramMatch) {
|
while(paramMatch) {
|
||||||
// Save the parameter details
|
// Save the parameter details
|
||||||
var paramInfo = {name: paramMatch[1]},
|
var paramInfo = {name: paramMatch[1]},
|
||||||
defaultValue = paramMatch[2] || paramMatch[3] || paramMatch[4] || paramMatch[5];
|
defaultValue = paramMatch[2] || paramMatch[3] || paramMatch[4] || paramMatch[5] || paramMatch[6];
|
||||||
if(defaultValue) {
|
if(defaultValue) {
|
||||||
paramInfo["default"] = defaultValue;
|
paramInfo["default"] = defaultValue;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user