diff --git a/gulpfile.js b/gulpfile.js
index 22b6ac3..7690943 100644
--- a/gulpfile.js
+++ b/gulpfile.js
@@ -11,7 +11,7 @@ function errorHandler() {
gulp.task('default', ['server'], function() {
gulp.watch(config.globs.other, ['static']);
- gulp.watch([config.globs.html, config.templateFile], ['markup']);
+ gulp.watch([config.globs.html, config.templateFile, config.globs.sass], ['markup']);
gulp.watch(config.globs.sass, ['compass']);
gulp.watch(config.globs.js, ['browserify']);
});
@@ -37,9 +37,10 @@ gulp.task('static', function() {
.pipe(gulp.dest(config.buildRoot));
});
-gulp.task('markup', function() {
+gulp.task('markup', ['compass'], function() {
var wrap = require('gulp-wrap'),
- path = require('path');
+ path = require('path'),
+ fs = require('fs');
return gulp.src(config.globs.html, { base: './src' })
.pipe(errorHandler())
@@ -49,7 +50,10 @@ gulp.task('markup', function() {
file = path.relative(root, this.file.history[0]);
return config.titles[file] || config.titles['_'];
- }
+ },
+ svgStyles: fs.readFileSync(path.join(config.compass.css, 'svg.css'), {
+ encoding: 'utf-8'
+ })
}))
.pipe(gulp.dest(config.buildRoot));
});
diff --git a/spec/regexper_spec.js b/spec/regexper_spec.js
index f4fc70e..f20adaf 100644
--- a/spec/regexper_spec.js
+++ b/spec/regexper_spec.js
@@ -14,7 +14,8 @@ describe('regexper.js', function() {
'
',
'',
'',
- ''
+ '',
+ 'example styles
'
].join('');
this.regexper = new Regexper(this.root);
@@ -377,6 +378,10 @@ describe('regexper.js', function() {
expect(this.regexper._trackEvent).toHaveBeenCalledWith('visualization', 'start');
});
+ it('adds the svg styles to the svg element', function() {
+ expect(this.regexper.svg.innerHTML).toEqual('');
+ });
+
it('keeps a copy of the running parser', function() {
expect(this.regexper.runningParser).toBeTruthy();
});
diff --git a/src/index.html b/src/index.html
index a5a2e61..bf7b545 100644
--- a/src/index.html
+++ b/src/index.html
@@ -26,71 +26,7 @@
-
+
diff --git a/src/js/regexper.js b/src/js/regexper.js
index 8ccde89..55ee20e 100644
--- a/src/js/regexper.js
+++ b/src/js/regexper.js
@@ -141,6 +141,12 @@ export default class Regexper {
this.state = 'is-loading';
this._trackEvent('visualization', 'start');
+ this.svg.innerHTML = [
+ ''
+ ].join('');
+
this.runningParser = new Parser();
return this.runningParser.parse(expression)
diff --git a/src/sass/_base.scss b/src/sass/_base.scss
index 21e3c3c..d3c91d7 100644
--- a/src/sass/_base.scss
+++ b/src/sass/_base.scss
@@ -2,8 +2,10 @@ $green: #bada55;
$dark-green: shade($green, 25%);
$light-green: tint($green, 25%);
$gray: #6b6659;
+$light-gray: tint($gray, 25%);
$tan: #cbcbba;
$red: #b3151a;
+$blue: #dae9e5;
$black: #000;
$white: #fff;
diff --git a/src/sass/svg.scss b/src/sass/svg.scss
new file mode 100644
index 0000000..1cc2110
--- /dev/null
+++ b/src/sass/svg.scss
@@ -0,0 +1,63 @@
+@import 'base';
+
+text, tspan {
+ font: 12px Arial;
+}
+
+path {
+ fill-opacity: 0;
+ stroke-width: 2px;
+ stroke: $black;
+}
+
+circle.pin {
+ fill: $gray;
+ stroke-width: 2px;
+ stroke: $black;
+}
+
+.anchor text, .any-character text {
+ fill: $white;
+}
+
+.anchor rect, .any-character rect {
+ fill: $gray;
+}
+
+.escape text, .charset-escape text, .literal text {
+ fill: $black;
+}
+
+.escape rect, .charset-escape rect {
+ fill: $green;
+}
+
+.literal rect {
+ fill: $blue;
+}
+
+.charset .charset-box {
+ fill: $tan;
+}
+
+.subexp .subexp-label,
+.charset .charset-label,
+.match-fragment .repeat-label {
+ font-size: 10px;
+}
+
+.subexp .subexp-label,
+.charset .charset-label {
+ dominant-baseline: text-after-edge;
+}
+
+.subexp .subexp-box {
+ stroke: $light-gray;
+ stroke-dasharray: 6,2;
+ stroke-width: 2px;
+ fill-opacity: 0;
+}
+
+.quote {
+ fill: $light-gray;
+}
diff --git a/template.html b/template.html
index f3b6825..115c066 100644
--- a/template.html
+++ b/template.html
@@ -15,6 +15,8 @@
+
+