Question T13457
Visible to All Users

Customize the question title

created 2 years ago

Hi,
We would like to be able to put some words in bold or in color in the question title.
I was wondering if it's possible to make them accept markup language like the complete survey html?
In the creator and the library.
Thank you very much,
Camille

Answers approved by surveyjs Support

created 2 years ago

Hello Camille,
You will need to use survey.onTextMarkdown event anyway. You can have a list of words that you make bold or in color and just search for them in options.text property and based on that set options.html property by adding replacing your words with <b>yourWordInBold</b> and <span style="color:red">yourColoredWord</span>. If you have predefined words then your Creator users don't need to use markups.

Thank you,
Andrew
SurveyJS Team

    Show previous comments (1)

      Hello Camille,
      To render HTML in a survey title and description in design and preview mode, register a markdown processing library (for instance, Showdown) and handle the survey.onTextMarkdown event to convert markdown to HTML:

      JavaScript
      creator.onSurveyInstanceCreated.add(function(sender, options){ if(options.reason === 'designer' || options.reason === 'test'){ options.survey.onTextMarkdown.add(function (survey, options) { // convert the markdown text to html var str = converter.makeHtml(options.text); // remove root paragraphs <p></p> str = str.substring(3); str = str.substring(0, str.length - 4); // set html options.html = str; }); } });

      Example

      Please let us know if you have further questions.

      P.S. We hope you enjoyed the level of service you received. If so, we would love if you could leave your feedback on SurveyJS page at g2.com. As we’re building our business, every review helps build credibility for future customers and your feedback would be greatly appreciated.

        Thank you, I already left a message on G2 :)

          Thank you. Please feel free to contact us if at your convenience.