_common.js 965 B

1234567891011121314151617181920212223242526272829303132333435
  1. // Generated by CoffeeScript 1.9.3
  2. var AnsiPainter, _common;
  3. AnsiPainter = require('../../AnsiPainter');
  4. module.exports = _common = {
  5. getStyleTagsFor: function(style) {
  6. var i, len, ret, tag, tagName, tagsToAdd;
  7. tagsToAdd = [];
  8. if (style.color != null) {
  9. tagName = 'color-' + style.color;
  10. if (AnsiPainter.tags[tagName] == null) {
  11. throw Error("Unkown color `" + style.color + "`");
  12. }
  13. tagsToAdd.push(tagName);
  14. }
  15. if (style.background != null) {
  16. tagName = 'bg-' + style.background;
  17. if (AnsiPainter.tags[tagName] == null) {
  18. throw Error("Unkown background `" + style.background + "`");
  19. }
  20. tagsToAdd.push(tagName);
  21. }
  22. ret = {
  23. before: '',
  24. after: ''
  25. };
  26. for (i = 0, len = tagsToAdd.length; i < len; i++) {
  27. tag = tagsToAdd[i];
  28. ret.before = ("<" + tag + ">") + ret.before;
  29. ret.after = ret.after + ("</" + tag + ">");
  30. }
  31. return ret;
  32. }
  33. };