Skip to content

Commit 1376ca1

Browse files
committed
Show HTML in Markdown code block correctly
1 parent 51feb1d commit 1376ca1

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

components/GvdOptions.vue

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,9 @@ function convertMarkdown(str: String) {
3838
return;
3939
}
4040
41-
let output = str.replace(/`(?<code>.+?)`/g, '<code class="gvd-code-inline">$<code></code>')
41+
let output = str.replace(/`(?<code>.+?)`/g, (match, code) => {
42+
return `<code class="gvd-code-inline">${code.replaceAll('<', '&lt;', '>', '&gt;')}</code>`
43+
})
4244
output = output.replace(/\[(?<linkText>.+)\]\((?<url>.+)\)/ig, '<a href="$<url>" class="govuk-link">$<linkText></a>')
4345
4446
return output

0 commit comments

Comments
 (0)