Skip to content

Commit fc97e50

Browse files
joppekoersOswin Bult
andcommitted
rename
Co-authored-by: Oswin Bult <oswin@pixelcorp.nl>
1 parent 07f4d04 commit fc97e50

File tree

2 files changed

+31
-50
lines changed

2 files changed

+31
-50
lines changed

frontend/src/lib/server/generate_info.ts

Lines changed: 0 additions & 50 deletions
This file was deleted.
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
// Generate a html file in the gernated folder from the passed markdown file
2+
import markdownit from 'markdown-it';
3+
import markdownItContainer from 'markdown-it-container';
4+
5+
const md = markdownit({
6+
highlight: function (str: string) {
7+
return '<Codeblock code="' + md.utils.escapeHtml(str).trim() + '" />';
8+
}
9+
});
10+
11+
md.use(markdownItContainer, 'exercise', {
12+
render: function (tokens: any, idx: any) {
13+
14+
if (tokens[idx].nesting === 1) {
15+
// opening tag
16+
return '<exercise>\n';
17+
18+
} else {
19+
// closing tag
20+
return '</exercise>\n';
21+
}
22+
}
23+
});
24+
25+
export function markdownToHtml(markdown: string) {
26+
try {
27+
return md.render(markdown);
28+
} catch (err) {
29+
return ('Error reading file:' + err);
30+
}
31+
}

0 commit comments

Comments
 (0)