Reply To: DashedSentence in a PennController trial

PennController for IBEX Forums FAQ / Tips DashedSentence in a PennController trial Reply To: DashedSentence in a PennController trial

#6484
Jeremy
Keymaster

I never followed up on this issue here. The problem was as follows:

  • The cumulative function accepts a string whose chunks are separated by the wildcard (*) character
  • Each of those wildcard-separated chunks can itself contain space characters, which are not chunk separators
  • Before a chunk is revealed, any inner space character (ie. non-separator) is masked as an underscore (_) character, like any other character from the chunk
  • Pre-reveal, if the full sentence is too long, it will be split across multiple lines where the wildcards (displayed as space characters) appear in the string passed to cumulative
  • Once a chunk is revealed, any _ corresponding to an inner space character is now replaced with a space character. As a result, inner and outer space characters are no longer distinguishable and the browser can decide to revise where it inserts line breaks and split the sentence at inner space characters instead of outer space characters, effectively “breaking chunks” visually

The solution was to replace this line from the cumulative function:

getText(textName).text(blanks.map((w,n)=>(n<=i?words[n]:w)).join(' ')) ]);

with this:

getText(textName).text(blanks.map((w,n)=>(n<=i?words[n]:w).replace(/\s/,"&nbsp;")).join(' ')) ]);

Jeremy