1
0
mirror of https://github.com/Jermolene/TiddlyWiki5 synced 2024-12-26 18:10:27 +00:00

Added support for single punctuation character macro names to TiddlyTextParser

This commit is contained in:
Jeremy Ruston 2012-05-05 11:57:24 +01:00
parent 13fd3ec66f
commit b646856c0a

View File

@ -27,7 +27,7 @@ var TiddlyTextParser = function(options) {
TiddlyTextParser.prototype.parse = function(type,text) { TiddlyTextParser.prototype.parse = function(type,text) {
var output = [], var output = [],
dependencies = new $tw.Dependencies(), dependencies = new $tw.Dependencies(),
macroRegExp = /(?:\[\[([^\]]+)\]\])|(?:<<([^>\s]+)(?:\s*)((?:[^>]|(?:>(?!>)))*)>>)/mg, macroRegExp = /(?:\[\[([^\]]+)\]\])|(?:<<(?:([!@£\$%\^\&\*\(\)`\~'"\|\\\/;\:\.\,\+\=\-\_\{\}])|([^>\s]+))(?:\s*)((?:[^>]|(?:>(?!>)))*)>>)/mg,
lastMatchPos = 0, lastMatchPos = 0,
match, match,
macroNode; macroNode;
@ -35,12 +35,13 @@ TiddlyTextParser.prototype.parse = function(type,text) {
match = macroRegExp.exec(text); match = macroRegExp.exec(text);
if(match) { if(match) {
output.push($tw.Tree.Text(text.substring(lastMatchPos,match.index))); output.push($tw.Tree.Text(text.substring(lastMatchPos,match.index)));
var macroName = match[2] || match[3];
if(match[1]) { // Transclusion if(match[1]) { // Transclusion
macroNode = $tw.Tree.Macro("tiddler",{ macroNode = $tw.Tree.Macro("tiddler",{
target: match[1] target: match[1]
},[],this.wiki); },[],this.wiki);
} else if(match[2]) { // Macro call } else if(macroName) { // Macro call
macroNode = $tw.Tree.Macro(match[2],match[3],[],this.wiki); macroNode = $tw.Tree.Macro(macroName,match[4],[],this.wiki);
} }
output.push(macroNode); output.push(macroNode);
dependencies.mergeDependencies(macroNode.dependencies); dependencies.mergeDependencies(macroNode.dependencies);