Skip to content
Snippets Groups Projects
Commit 15216e5d authored by Anthony's avatar Anthony
Browse files

Re Include Markdown it and onTextMarkdown method

parent 3292408c
No related branches found
No related tags found
No related merge requests found
...@@ -42,6 +42,22 @@ $(function () { ...@@ -42,6 +42,22 @@ $(function () {
// Load survey model from JSON // Load survey model from JSON
const survey = new Survey.Model(jsonStatic); const survey = new Survey.Model(jsonStatic);
// Instantiate `markdown-it`
const converter = markdownit({
html: true // Support HTML tags in the source (unsafe, see documentation)
});
survey.onTextMarkdown.add((_, options) => {
console.log("On text markdown")
// Convert Markdown to HTML
let str = converter.renderInline(options.text);
// ...
// Sanitize the HTML markup using a third-party library here
// ...
// Set HTML markup to render
options.html = str;
});
// Add "Check answers" button // Add "Check answers" button
survey.addNavigationItem({ survey.addNavigationItem({
id: "sv-nav-check", id: "sv-nav-check",
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment