Skip to content

Commit

Permalink
Fix wrapping lines > MAX_CHAR_LINE
Browse files Browse the repository at this point in the history
  • Loading branch information
Wistaro committed May 14, 2017
1 parent daf4668 commit 445382f
Showing 1 changed file with 16 additions and 1 deletion.
17 changes: 16 additions & 1 deletion generator.js
Expand Up @@ -76,15 +76,30 @@ function generateCourse()
const splitInput = inputStr.split('\n');

for (var i = 0; i < splitInput.length; i++)

{
const val = splitInput[i];
bufferStr += val;
if (val.length < MAX_CHAR_LINE && val.trim() !== "")

if (val.length < MAX_CHAR_LINE)
{
for (var idxSpace = 1; idxSpace <= MAX_CHAR_LINE - val.length; idxSpace++)
{
bufferStr += " ";
}
}else{


let nbFullLines=~~eval(val.length/MAX_CHAR_LINE);

let nbSpaces = MAX_CHAR_LINE - val.substring(nbFullLines*MAX_CHAR_LINE,val.length).length;

for (var idxSpace = 1; idxSpace <= nbSpaces; idxSpace++)
{
bufferStr += " ";
}


}
}

Expand Down

0 comments on commit 445382f

Please sign in to comment.