Skip to content

Commit

Permalink
HFP-3141 Fix sentences being parsed as a single word
Browse files Browse the repository at this point in the history
This would happen if a sentence was wrapped in space and asterisk, e.g. ' *this is the answer* ',
which would be marked as a single word in the view, when it should be 4 words.
Adding space as an exception in the matching regex fixes this.
  • Loading branch information
thomasmars committed Oct 12, 2020
1 parent 6712ee7 commit cbe28a3
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion scripts/mark-the-words.js
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ H5P.MarkTheWords = (function ($, Question, Word, KeyboardNav, XapiGenerator) {
if (node instanceof Text) {
var text = $(node).text();
var selectableStrings = text.replace(/( |\r\n|\n|\r)/g, ' ')
.match(/ \*[^\*]+\* |[^\s]+/g);
.match(/ \*[^\* ]+\* |[^\s]+/g);

if (selectableStrings) {
selectableStrings.forEach(function (entry) {
Expand Down

0 comments on commit cbe28a3

Please sign in to comment.