_common.js 1021 B

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