jspsych / jsPsych

Create behavioral experiments in a browser using JavaScript
http://www.jspsych.org
MIT License
1.03k stars 668 forks source link

HTML/Markdown not supported in Survey plugin #3324

Open DominiqueMakowski opened 3 months ago

DominiqueMakowski commented 3 months ago

Documentation suggests that markdown/HTML is supported in SurveyJS:

However, the formatting of radiogroup options does not seem to work

image

                            {
                                title: "Example",
                                type: "radiogroup",
                                choices: ["My **markown** text", "Some <b>HTML</b> text"],
                                colCount: 0,
                            },

Is there an option I missed to enable inline formatting? Thanks!

DominiqueMakowski commented 3 months ago

Based on this example here it seems like they call an event: https://surveyjs.io/form-library/examples/edit-survey-questions-markdown/reactjs#content-code But I'm not sure if that's doable from JsPsych.

See also using markdown for values in Likert scale

becky-gilbert commented 3 months ago

Thanks @DominiqueMakowski - you're right, we should support markdown. It is supported in SurveyJS but doesn't work 'out of the box' - instead we need to install a markdown parser package (Showdown or Marked) and use the Survey's onTextMarkdown event to convert any text elements that allow markdown to HTML. I will definitely add this to the next plugin version.

In the meantime you might be able to get it to work by adding the onTextMarkdown event handler to the survey via the survey_function parameter, and loading Marked or Showdown using their browser/client-side CDN options. My other tip is to make sure you're using the knockout version of the markdown example code. HOWEVER: I haven't actually tried this approach and don't know how difficult it would be to get working, or if it would work at all!