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

#5252
Jeremy
Keymaster

Hello,

You can replace the first lines from the code above (ie. until dashed = ..., non-included) with:

showWord = (s,i) => '<p style="font-family: monospace;">'+s.map((w,n)=>`
        <span>${w.replace(/^\s*(\w+).*$/,"$1").replace(/(.)/g,(i===n?"$1":"-"))}</span>${w.replace(/^\s*\w+/,'')}`).join(' ')+'</p>'

I used a monospace font to clearly mark each dash, but feel free to change that if you don’t like the rendering.

You can use the dashed function from within the Template command as usual:

Template( "myTable.csv" , row =>
  newTrial(
    dashed("sentence" , row.sentence )
    ,
    getText("sentence").remove()
    ,
    newButton("Next").print().wait()
  )
)

Jeremy