better regex for filename
Connor McSheffrey committed
Oct 13, 2013 at 19:47 UTC
a7dd6e7c70ac7cbbf1f54d0e75212a4d789dc7c7
1 file changed
+6
-3
docs/Gruntfile.js
+6
-3
@@ -18,8 +18,8 @@ module.exports = function(grunt) {
18
/**
19
* Update HTML file to include an ID and script src link
20
*/
21
- function writeToHTML() {
22
- grunt.file.write('_site/cookbook' + componentName + '.html', liveEditJS);
21
+ function writeToHTML(markdown, componentName) {
22
+ grunt.file.write('_site/cookbook' + componentName + '.html', markdown);
23
}
24
25
function readFromCookbookEntry(abspath, rootdir, subdir, filename) {
@@ -40,6 +40,7 @@ module.exports = function(grunt) {
40
return;
41
};
42
43
+ // Here we should iterate over matched code samples
44
matchedJS = matchedJS[0];
45
46
// Remove markdown syntax
@@ -51,7 +52,7 @@ module.exports = function(grunt) {
52
53
componentNameCamelCase = componentName;
54
54
- componentNameUpperCase = componentName.toUpperCase().replace("-","_");
55
+ componentNameUpperCase = componentName.toUpperCase().replace(/[\. ,:-]+/g, "_");
56
57
componentNameCamelCase = componentNameCamelCase.replace(/-([a-z])/g, function (g) { return g[1].toUpperCase() });
58
@@ -60,6 +61,8 @@ module.exports = function(grunt) {
61
console.log(componentName);
62
63
writeToLiveSampleJS(liveEditJS, componentName);
64
+
65
+ writeToHTML(markdown, componentName);
66
}
67
68
grunt.registerTask('makeLiveSamples', 'Create live edit JS file for code samples in React Cookbook entries', function() {