Skip to content

Commit

Permalink
fixing #3; doesn't render signal groupings
Browse files Browse the repository at this point in the history
  • Loading branch information
drom committed Apr 6, 2016
1 parent e1bc7f5 commit 6ca8769
Show file tree
Hide file tree
Showing 9 changed files with 38 additions and 114 deletions.
115 changes: 9 additions & 106 deletions bin/wavedrom-cli.js
Original file line number Diff line number Diff line change
Expand Up @@ -1658,7 +1658,7 @@ module.exports = renderArcs;

/* eslint-env browser */

},{"./create-element":2,"./w3":30,"tspan":33}],24:[function(require,module,exports){
},{"./create-element":2,"./w3":30,"tspan":32}],24:[function(require,module,exports){
'use strict';

var jsonmlParse = require('./create-element');
Expand Down Expand Up @@ -1952,7 +1952,7 @@ module.exports = renderGroups;

/* eslint-env browser */

},{"tspan":33}],27:[function(require,module,exports){
},{"tspan":32}],27:[function(require,module,exports){
'use strict';

var tspan = require('tspan'),
Expand Down Expand Up @@ -2083,12 +2083,12 @@ module.exports = renderMarks;

/* eslint-env browser */

},{"./create-element":2,"tspan":33}],28:[function(require,module,exports){
},{"./create-element":2,"tspan":32}],28:[function(require,module,exports){
'use strict';

var rec = require('./rec'),
lane = require('./lane'),
onmlStringify = require('onml/lib/stringify'),
jsonmlParse = require('./create-element'),
parseConfig = require('./parse-config'),
parseWaveLanes = require('./parse-wave-lanes'),
renderMarks = require('./render-marks'),
Expand Down Expand Up @@ -2119,7 +2119,7 @@ function renderWaveForm (index, source, output) {
renderMarks(root, content, index, lane);
renderArcs(root, ret.lanes, index, source, lane);
renderGaps(root, ret.lanes, index, lane);
groups.innerHTML = onmlStringify(renderGroups(ret.groups, index, lane));
groups.insertBefore(jsonmlParse(renderGroups(ret.groups, index, lane)), null);
lane.xg = Math.ceil((xmax - lane.tgo) / lane.xs) * lane.xs;
width = (lane.xg + (lane.xs * (lane.xmax + 1)));
height = (content.length * lane.yo +
Expand All @@ -2141,7 +2141,7 @@ module.exports = renderWaveForm;

/* eslint-env browser */

},{"./insert-svg-template":11,"./insert-svg-template-assign":10,"./lane":17,"./parse-config":18,"./parse-wave-lanes":20,"./rec":22,"./render-arcs":23,"./render-assign":24,"./render-gaps":25,"./render-groups":26,"./render-marks":27,"./render-wave-lane":29,"onml/lib/stringify":32}],29:[function(require,module,exports){
},{"./create-element":2,"./insert-svg-template":11,"./insert-svg-template-assign":10,"./lane":17,"./parse-config":18,"./parse-wave-lanes":20,"./rec":22,"./render-arcs":23,"./render-assign":24,"./render-gaps":25,"./render-groups":26,"./render-marks":27,"./render-wave-lane":29}],29:[function(require,module,exports){
'use strict';

var tspan = require('tspan'),
Expand Down Expand Up @@ -2249,7 +2249,7 @@ module.exports = renderWaveLane;

/* eslint-env browser */

},{"./create-element":2,"./find-lane-markers":5,"./w3":30,"tspan":33}],30:[function(require,module,exports){
},{"./create-element":2,"./find-lane-markers":5,"./w3":30,"tspan":32}],30:[function(require,module,exports){
'use strict';

module.exports = {
Expand All @@ -2268,103 +2268,6 @@ module.exports = window.WaveSkin;
},{}],32:[function(require,module,exports){
'use strict';

function isObject (o) {
return o && Object.prototype.toString.call(o) === '[object Object]';
}

function indent (txt) {
var arr, res = [];

if (typeof txt !== 'string') {
return txt;
}

arr = txt.split('\n');

if (arr.length === 1) {
return ' ' + txt;
}

arr.forEach(function (e) {
if (e.trim() === '') {
res.push(e);
return;
}
res.push(' ' + e);
});

return res.join('\n');
}

function clean (txt) {
var arr = txt.split('\n');
var res = [];
arr.forEach(function (e) {
if (e.trim() === '') {
return;
}
res.push(e);
});
return res.join('\n');
}

function stringify (a) {
var res, body, isEmpty, isFlat;

body = '';
isFlat = true;
isEmpty = a.some(function (e, i, arr) {
if (i === 0) {
res = '<' + e;
if (arr.length === 1) {
return true;
}
return;
}

if (i === 1) {
if (isObject(e)) {
Object.keys(e).forEach(function (key) {
res += ' ' + key + '="' + e[key] + '"';
});
if (arr.length === 2) {
return true;
}
res += '>';
return;
} else {
res += '>';
}
}

switch (typeof e) {
case 'string':
case 'number':
case 'boolean':
body += e + '\n';
return;
}

isFlat = false;
body += stringify(e);
});

if (isEmpty) {
return res + '/>\n'; // short form
} else {
if (isFlat) {
return res + clean(body) + '</' + a[0] + '>\n';
} else {
return res + '\n' + indent(body) + '</' + a[0] + '>\n';
}
}
}

module.exports = stringify;

},{}],33:[function(require,module,exports){
'use strict';

var token = /<o>|<ins>|<s>|<sub>|<sup>|<b>|<i>|<tt>|<\/o>|<\/ins>|<\/s>|<\/sub>|<\/sup>|<\/b>|<\/i>|<\/tt>/;

function update (s, cmd) {
Expand Down Expand Up @@ -2471,14 +2374,14 @@ function parse (str) {

exports.parse = parse;

},{}],34:[function(require,module,exports){
},{}],33:[function(require,module,exports){
/* wavedrom begin */

module.exports = require('wavedrom');

/* wavedrom end */

},{"wavedrom":9}]},{},[34])(34)
},{"wavedrom":9}]},{},[33])(33)
});/* foot begin */

// some parameters
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,6 @@
"devDependencies": {
"browserify": "^13.0.0",
"minimist": "^1.2.0",
"wavedrom": "^1.2.4"
"wavedrom": "^1.2.6"
}
}
4 changes: 4 additions & 0 deletions test/res/step1.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
4 changes: 4 additions & 0 deletions test/res/step2.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
4 changes: 4 additions & 0 deletions test/res/step3.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
11 changes: 4 additions & 7 deletions test/res/step4.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
4 changes: 4 additions & 0 deletions test/res/step5.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
4 changes: 4 additions & 0 deletions test/res/step6.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
4 changes: 4 additions & 0 deletions test/res/step7.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit 6ca8769

Please sign in to comment.