Applying styles to select variables in a string

PennController for IBEX Forums Support Applying styles to select variables in a string

This topic contains 2 replies, has 2 voices, and was last updated by Avatar Philipp 1 month ago.

Viewing 3 posts - 1 through 3 (of 3 total)
  • Author
    Posts
  • #6170
    Avatar
    Philipp
    Participant

    Hi Jeremy,

    in our experiment, we present participants with items consisting in a list of strings from a spreadsheet. Each part of the item, a sentence for example, is stored in a different column in a spreadsheet and concatenated during the trial. What I can’t figure out is how to make only the critical part of that sentence, say the variable.object bold:

    PennController. Template( PennController.GetTable( "my_table.csv"),
                              variable => PennController( "my_trials",
                                                          newText("example_sentence", variable.subject+" "+variable.verb+" "+variable.adjective +variable.object)
                                                          .settings.css("font-size", "25px")
                                                          .settings.center()
                                                          .settings.bold()
                                                          .print()

    As it is now, the entire sentence is bold. Calling any variation of the .settings.bold() method on the individual variable doesn’t help and bold(variable.object) doesn’t work either. Is there any easy way to do this?

    Thanks in advance 🙂

    #6172
    Jeremy
    Jeremy
    Keymaster

    Hi,

    You can use the <strong> HTML tag to surround the part that you want to print in bold. Here’s what it would look like with the code you give (updated to use PennController’s more modern syntax)

    Template( "my_table.csv" ,
      variable => newTrial( "my_trials",
        newText("example_sentence", variable.subject+" "+variable.verb+" "+variable.adjective+" <strong>"+variable.object+"</strong>")
          .css("font-size", "25px")
          .center()
          .print()

    Let me know if you have questions

    Jeremy

    #6176
    Avatar
    Philipp
    Participant

    Thank you so much! 🙂

Viewing 3 posts - 1 through 3 (of 3 total)

You must be logged in to reply to this topic.