Added support for # comment lines in recipe files

print-window-tiddler
Jeremy Ruston 2012-01-13 18:50:37 +00:00
rodzic 510006d67d
commit 8561fb979c
2 zmienionych plików z 8 dodań i 6 usunięć

Wyświetl plik

@ -143,12 +143,13 @@ Recipe.prototype.sortTiddlersForMarker = function(marker) {
// Process the contents of a recipe file
Recipe.prototype.processRecipeFile = function(recipe,text,contextPath) {
var matchLine = function(linetext) {
var lineRegExp = /^(\s*)([^\s\:]+)\s*:\s*(.+)*\s*$/,
var lineRegExp = /^(#?)(\s*)(#?)([^\s\:]+)\s*:\s*(.+)*\s*$/,
match = lineRegExp.exec(linetext);
return match ? {
indent: match[1],
marker: match[2],
value: match[3]
comment: match[1] || match[3],
indent: match[2],
marker: match[4],
value: match[5]
} : null;
},
lines = text.split("\n"),
@ -156,7 +157,7 @@ Recipe.prototype.processRecipeFile = function(recipe,text,contextPath) {
while(line < lines.length) {
var linetext = lines[line++],
match = matchLine(linetext);
if(match) {
if(match && !match.comment) {
if(match.indent.length > 0) {
throw "Unexpected indentation in recipe file";
}

Wyświetl plik

@ -3,7 +3,7 @@ modifier: JeremyRuston
{{{.recipe}}} files are text files that list the components to be assembled into a TiddlyWiki. They link to a simple template file that contains the basic structure of the TiddlyWiki document with additional markers to identify parts of the file where ingredients are inserted. Recipes determine which tiddlers should be included in the file, and put together the individual JavaScript files making up the TiddlyWiki core code.
Each line of the recipe file lists an ingredient, prefixed with a tag that describes what to do with the ingredient. Tags either identify a marker within the template file or are special tags that initiate an action.
Each line of the recipe file is either a comment starting with `#` or lists an ingredient, prefixed with a tag that describes what to do with the ingredient. Tags either identify a marker within the template file or are special tags that initiate an action.
Recipe files contain lines consisting of a marker, a colon and the pathname of an ingredient:
{{{
@ -13,6 +13,7 @@ The filepath is interpreted relative to the directory containing the recipe file
You can use filepaths or URLs to reference recipe files and tiddlers. For example, this recipe cooks the latest TiddlyWiki components directly from the online repositories:
{{{
# Get the recipe direct from GitHub
recipe: https://raw.github.com/TiddlyWiki/tiddlywiki/master/tiddlywikinonoscript.html.recipe
tiddler: http://tiddlywiki-com.tiddlyspace.com/bags/tiddlywiki-com-ref_public/tiddlers.json?fat=1
tiddler: http://tiddlywiki-com.tiddlyspace.com/bags/tiddlywiki-com_public/tiddlers.json?fat=1