diff --git a/lib/wheat/data.js b/lib/wheat/data.js index 58242fd..cb998ad 100644 --- a/lib/wheat/data.js +++ b/lib/wheat/data.js @@ -23,8 +23,9 @@ function preProcessMarkdown(markdown) { // Look for snippet placeholders var unique = props.uniqueSnippets = {}; - props.snippets = (markdown.match(/\n<[^<>:\s]+\.[a-z]{2,4}(\*|[#].+)?>\n/g) || []).map( + props.snippets = (markdown.match(/\n<[^<>:\s]+\.[a-z]{2,4}(\*|[#|\:].+)?>\n/g) || []).map( function (original) { + // nuke the leading and trailing /n< and >/n var path = original.substr(2, original.length - 4); var filename = path; @@ -32,19 +33,26 @@ function preProcessMarkdown(markdown) { if (execute) { filename = filename.substr(0, filename.length - 1); } - base = path.substr(path.indexOf('/') + 1).replace(/[#*].*$/, ''); + base = path.substr(path.indexOf('/') + 1).replace(/[(#|\:)*].*$/, ''); var match = filename.match(/#(.+)$/); var name; if (match) { name = match[1]; filename = path.substr(0, match.index); } + var version = 'fs'; + match = filename.match(/\:(.+)$/); + if (match) { + version = match[1]; + filename = path.substr(0, match.index); + } return unique[base] = { original: original, filename: filename, execute: execute, base: base, - name: name + name: name, + version: version }; } ); @@ -52,7 +60,6 @@ function preProcessMarkdown(markdown) { props.uniqueSnippets = false; } - return props; } @@ -123,7 +130,7 @@ function activateSnippets(version, snippets, canExecute, callback) { } var group = this.group(); snippets.forEach(function (snippet) { - Git.readFile(version, "articles/" + snippet.filename, group()); + Git.readFile(snippet.version, "articles/" + snippet.filename, group()); }); }, function (err, files) {