|
@@ -57,7 +57,7 @@ var formatText = (function() {
|
|
|
this.isStrike = this.trigger === '~' || this.trigger === '-';
|
|
this.isStrike = this.trigger === '~' || this.trigger === '-';
|
|
|
|
|
|
|
|
/** @type {boolean} */
|
|
/** @type {boolean} */
|
|
|
- this.isQuote = this.trigger === '>';
|
|
|
|
|
|
|
+ this.isQuote = this.trigger === '>' || this.trigger === ">";
|
|
|
|
|
|
|
|
/** @type {boolean} */
|
|
/** @type {boolean} */
|
|
|
this.isEmoji = this.trigger === ':';
|
|
this.isEmoji = this.trigger === ':';
|
|
@@ -78,7 +78,7 @@ var formatText = (function() {
|
|
|
this.prevTwin = null;
|
|
this.prevTwin = null;
|
|
|
|
|
|
|
|
/** @type {boolean|number} */
|
|
/** @type {boolean|number} */
|
|
|
- this.terminated = false;
|
|
|
|
|
|
|
+ this.terminated = this.isEol ? triggerIndex : false;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
/** @return {boolean} */
|
|
/** @return {boolean} */
|
|
@@ -153,6 +153,8 @@ var formatText = (function() {
|
|
|
return true;
|
|
return true;
|
|
|
// else no content, should not be finished now
|
|
// else no content, should not be finished now
|
|
|
}
|
|
}
|
|
|
|
|
+ if (str[i] === '\n' && this.isEol)
|
|
|
|
|
+ return true;
|
|
|
return false;
|
|
return false;
|
|
|
};
|
|
};
|
|
|
|
|
|
|
@@ -207,16 +209,21 @@ var formatText = (function() {
|
|
|
* @return {string|null}
|
|
* @return {string|null}
|
|
|
**/
|
|
**/
|
|
|
MsgBranch.prototype.isNewToken = function(str, i) {
|
|
MsgBranch.prototype.isNewToken = function(str, i) {
|
|
|
- if (this.isCode || this.isCodeBlock || this.isEmoji)
|
|
|
|
|
|
|
+ if (this.isCode || this.isEmoji || this.isCodeBlock)
|
|
|
return null;
|
|
return null;
|
|
|
- if (!this.lastNode || this.lastNode instanceof MsgTextLeaf) {
|
|
|
|
|
- var nextIsAlphadec = isAlphadec(str[i +1]);
|
|
|
|
|
|
|
+ if (!this.lastNode || this.lastNode.terminated || this.lastNode instanceof MsgTextLeaf) {
|
|
|
|
|
+ var nextIsAlphadec = isAlphadec(str[i +1])
|
|
|
|
|
+ ,prevIsAlphadec = isAlphadec(str[i -1]);
|
|
|
|
|
|
|
|
if (str.substr(i, 3) === '```')
|
|
if (str.substr(i, 3) === '```')
|
|
|
return '```';
|
|
return '```';
|
|
|
|
|
+ if (str.substr(i, 4) === ">") // FIXME AND begining of line OR begining of QUOTED
|
|
|
|
|
+ return ">";
|
|
|
|
|
+ if (str[i] === '>') // FIXME AND begining of line OR begining of QUOTED
|
|
|
|
|
+ return str[i];
|
|
|
if (['`', '\n'].indexOf(str[i]) !== -1)
|
|
if (['`', '\n'].indexOf(str[i]) !== -1)
|
|
|
return str[i];
|
|
return str[i];
|
|
|
- if (['*', '~', '-', '_' ].indexOf(str[i]) !== -1 && (nextIsAlphadec || ['*', '`', '~', '-', '_', ':', '<'].indexOf(str[i+1]) !== -1))
|
|
|
|
|
|
|
+ if (['*', '~', '-', '_' ].indexOf(str[i]) !== -1 && (nextIsAlphadec || ['*', '~', '-', '_', '<', '&'].indexOf(str[i+1]) !== -1))
|
|
|
return str[i];
|
|
return str[i];
|
|
|
if ([':', '<'].indexOf(str[i]) !== -1 && nextIsAlphadec)
|
|
if ([':', '<'].indexOf(str[i]) !== -1 && nextIsAlphadec)
|
|
|
return str[i];
|
|
return str[i];
|
|
@@ -323,6 +330,7 @@ var formatText = (function() {
|
|
|
|
|
|
|
|
if (this._parent.checkIsCodeBlock()) {
|
|
if (this._parent.checkIsCodeBlock()) {
|
|
|
// TODO syntax highlight
|
|
// TODO syntax highlight
|
|
|
|
|
+ // TODO line breaks
|
|
|
classList.push('codeblock');
|
|
classList.push('codeblock');
|
|
|
} else if (this._parent.checkIsCode()) {
|
|
} else if (this._parent.checkIsCode()) {
|
|
|
classList.push('code');
|
|
classList.push('code');
|
|
@@ -344,15 +352,17 @@ var formatText = (function() {
|
|
|
MsgBranch.prototype.outerHTML = function() {
|
|
MsgBranch.prototype.outerHTML = function() {
|
|
|
var html = "";
|
|
var html = "";
|
|
|
|
|
|
|
|
- if (this.isQuote) {
|
|
|
|
|
|
|
+ if (this.isQuote)
|
|
|
html += '<span class="quote">';
|
|
html += '<span class="quote">';
|
|
|
- }
|
|
|
|
|
|
|
+ if (this.isEol)
|
|
|
|
|
+ html += '<br/>';
|
|
|
|
|
+
|
|
|
this.subNodes.forEach(function(node) {
|
|
this.subNodes.forEach(function(node) {
|
|
|
html += node.outerHTML();
|
|
html += node.outerHTML();
|
|
|
});
|
|
});
|
|
|
- if (this.isQuote) {
|
|
|
|
|
|
|
+
|
|
|
|
|
+ if (this.isQuote)
|
|
|
html += '</span>';
|
|
html += '</span>';
|
|
|
- }
|
|
|
|
|
return html;
|
|
return html;
|
|
|
};
|
|
};
|
|
|
|
|
|
|
@@ -410,6 +420,7 @@ var formatText = (function() {
|
|
|
};
|
|
};
|
|
|
|
|
|
|
|
MsgTree.prototype.eof = function() {
|
|
MsgTree.prototype.eof = function() {
|
|
|
|
|
+ // FIXME merge of same block-branches (opti + quoted)
|
|
|
var unterminated = this.getFirstUnterminated(this.root);
|
|
var unterminated = this.getFirstUnterminated(this.root);
|
|
|
|
|
|
|
|
if (unterminated) {
|
|
if (unterminated) {
|