diff --git a/locallib.php b/locallib.php
index 7a0daf62f93f51cb9a6ec0b27a849f60820eba86..ebcbcc9c22259d1d4d5edce30e0abd2bce25294a 100644
--- a/locallib.php
+++ b/locallib.php
@@ -64,7 +64,7 @@ function pdfannotator_display_embed($pdfannotator, $cm, $course, $file, $page =
// Load and execute the javascript files.
$PAGE->requires->js(new moodle_url("/mod/pdfannotator/shared/pdf.js?ver=00002"));
$PAGE->requires->js(new moodle_url("/mod/pdfannotator/shared/textclipper.js"));
- $PAGE->requires->js(new moodle_url("/mod/pdfannotator/shared/index.js?ver=00030"));
+ $PAGE->requires->js(new moodle_url("/mod/pdfannotator/shared/index.js?ver=00031"));
$PAGE->requires->js(new moodle_url("/mod/pdfannotator/shared/locallib.js?ver=00005"));
// Pass parameters from PHP to JavaScript.
diff --git a/shared/index.js b/shared/index.js
index f3f1002a4ea528e4b7771036d12c11fe8d96b951..42e1753b85f4f2a70ec7c10efdefefe270878383 100644
--- a/shared/index.js
+++ b/shared/index.js
@@ -809,16 +809,16 @@ function startIndex(Y,_cm,_documentObject,_contextId, _userid,_capabilities, _to
* it contains latex formulae images or not and place its text and/or images on the pdf
*/
function breakLines(author=null, timemodified=null, post, characters = 130) {
- if (typeof post === "string") { // Answer contains text only.
- printTextblock(author, timemodified, post, characters);
- }
-
- if (typeof post === "object") { // Answer is an array of text (optional) and a png image of a latex formula.
- // 1. print the author right away
- printAuthor(author, timemodified);
- // 2. Print text and - if present - images (latex formulae).
- post.forEach(printItem);
- }
+ // 1. print the author right away
+ printAuthor(author, timemodified);
+ post.forEach(function(subContent) {
+ // Answer contains text only or any object such as array.
+ if (typeof subContent === "string") {
+ printTextblock(author, timemodified, subContent, characters);
+ } else if (typeof subContent === "object") {
+ printItem(subContent);
+ }
+ });
}
/**
* Take a text block, split it into pieces no larger than 130 characters
@@ -831,9 +831,7 @@ function startIndex(Y,_cm,_documentObject,_contextId, _userid,_capabilities, _to
text = text.replace(/<br \/>/g, "\n");
// Remove all other HTML-Tags.
text = $("<div>").html(text).text();
- if (author !== null) {
- printAuthor(author, timemodified);
- }
+
var stringarray = doc.splitTextToSize(text, characters);
var textbit;
for (var j = 0; j < stringarray.length; j++) {