Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
49 changes: 18 additions & 31 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,34 +8,9 @@ exports.getLineHTMLForExport = function (hook, context) {
var authors = _authorsOfLine(context.attribLine, context.apool);
var newLineHTML = "";
var charPos = 0;

// Use this code if this function is called in an asynchronous way
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you please leave this block in the code?

/*async.series([
function(cb){
async.each(authors, function(author, callback) {
console.log(author);
db.getSub("globalAuthor:" + author, ["colorId"], function(err, result) {
if (err) {
console.log(err);
} else {
console.log("color: "+result);
newLineHTML += _getHTMLString(author.name.replace('.','_'), result, context.text.substring(charPos, charPos + author.chars));
charPos += author.chars;
}
callback();
});
}, function(err) {
if (err) {
console.log(err);
}
cb();
});
}
],
function(err, results){
return newLineHTML+'<br/>';
});*/

if (context.lineContent[0] === '*') {
context.lineContent = context.lineContent.substr(1);
}
authors.forEach(function(author) {
var authorName = author.name;
var color = null;
Expand All @@ -44,13 +19,25 @@ exports.getLineHTMLForExport = function (hook, context) {
authorName = authorName.replace('.','_');
color = _getAuthorColor(author.name);
}
newLineHTML += _getHTMLString(authorName, color, context.text.substring(charPos, charPos + author.chars));
var plainAuthorText = context.text.substring(charPos, charPos + author.chars);
var newHTML = _getHTMLString(authorName, color, plainAuthorText);
context.lineContent = context.lineContent.replace(plainAuthorText, newHTML);

var end = context.lineContent.indexOf(newHTML) + newHTML.length;
newLineHTML += context.lineContent.substr(0, end);
context.lineContent = context.lineContent.substr(end);

charPos += author.chars;
});
if (newLineHTML == "") {
if (newLineHTML === "") {
return;
}
return newLineHTML+'<br/>';

if (context.lineContent.length) {
newLineHTML += context.lineContent;
}
context.lineContent = newLineHTML+'<br/>';
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please merge your code on this line

return true;
}

function _authorsOfLine(alineAttrs, apool) {
Expand Down