diff --git a/static/js/terminal/index.js b/static/js/terminal/index.js
index e28823c..c52f558 100644
--- a/static/js/terminal/index.js
+++ b/static/js/terminal/index.js
@@ -1053,30 +1053,9 @@ AnsiTerminal.prototype.toString = function (type){
stylesBuffer[i][j].value = node.value;
}
- if (styleBuffer.foreground) {
- style += 'color:' + styleBuffer.foreground + ';';
- }
-
- if (styleBuffer.background) {
- style += 'background-color:' + styleBuffer.background + ';';
- }
-
- if (styleBuffer.bold) {
- style += 'font-weight:bold;';
- }
-
- if (styleBuffer.italic) {
- style += 'font-style: italic;';
- }
-
- if (styleBuffer.underline) {
- style += 'text-decoration: underline;';
- }
-
if (j === 0) {
+ style = htmlStyle(styleBuffer);
s += '';
-
- style = '';
attrCache = node.attr;
} else if (j === cols - 1) {
s += '';
@@ -1084,9 +1063,8 @@ AnsiTerminal.prototype.toString = function (type){
if (node.value) {
if (node.attr !== attrCache) {
+ style = htmlStyle(styleBuffer);
s += '';
-
- style = '';
attrCache = node.attr;
}
@@ -2762,3 +2740,34 @@ function styles(node){
return styles;
}
+
+/**
+ * html style
+ * @param styles
+ * @returns {string}
+ */
+function htmlStyle(styles){
+ var style = '';
+
+ if (styles.foreground) {
+ style += 'color:' + styles.foreground + ';';
+ }
+
+ if (styles.background) {
+ style += 'background-color:' + styles.background + ';';
+ }
+
+ if (styles.bold) {
+ style += 'font-weight:bold;';
+ }
+
+ if (styles.italic) {
+ style += 'font-style: italic;';
+ }
+
+ if (styles.underline) {
+ style += 'text-decoration: underline;';
+ }
+
+ return style;
+}