Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
M
MACAO Hugo
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Container registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
MACAO
MACAO Hugo
Commits
816b26f4
Commit
816b26f4
authored
6 months ago
by
Anthony
Browse files
Options
Downloads
Patches
Plain Diff
Improve markdown translation in Survey
parent
75918eff
No related branches found
No related tags found
No related merge requests found
Pipeline
#2008
canceled
6 months ago
Stage: test
Changes
1
Pipelines
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
macao/assets/quiz.js
+16
-6
16 additions, 6 deletions
macao/assets/quiz.js
with
16 additions
and
6 deletions
macao/assets/quiz.js
+
16
−
6
View file @
816b26f4
...
...
@@ -44,6 +44,22 @@ $(function () {
// Load survey model from JSON
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
survey
.
addNavigationItem
({
id
:
"
sv-nav-check
"
,
...
...
@@ -65,12 +81,6 @@ $(function () {
innerCss
:
"
sd-btn nav-input
"
});
survey
.
onTextMarkdown
.
add
((
survey
,
options
)
=>
{
// FIXME: this inserts raw HTML from the text, to remove as soon as Macao-Legacy converter
// can actually produce Markdown
options
.
html
=
options
.
text
;
});
survey
.
onValueChanged
.
add
((
_
,
options
)
=>
{
console
.
log
(
options
)
});
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment