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

#5437
mrhelfrich
Participant

I’m not sure why but I’m unable to edit my original post and it looks like the copied code has some formatting problem so here is the code copied again:

showWord = (s,i) => '<p>'+s.map((w,n)=>`
        <span${(i===n?"":' style=\'border-bottom:solid 1px black;\'><span style=\'visibility:hidden;\'')}'>
        ${w.replace(/^\s*(\w+).*$/,"$1")}${(i===n?"":'</span>')}</span>${w.replace(/^\s*\w+/,'')}`).join(' ')+'</p>'
        
dashed = (name, sentence) => {
    let words = sentence.split(' ');
    return [
        [newText(name, showWord(words)).print()], 
        ...words.map( (w,i) => [newKey(`${name}-${i}-${w}`," ").log().wait() , getText(name).text(showWord(words,i))] ),
        [newKey(`${name}-last`," ").log().wait()]
    ].flat(1);
}