Skip to content

Commit ae13658

Browse files
authored
Let skillmaps specify an intro modal (microsoft#10939)
* add basic support for intro modals in skillmaps * rename and add eslint exception
1 parent 1f9e836 commit ae13658

9 files changed

Lines changed: 231 additions & 18 deletions

File tree

‎pxtlib/markdownMetadataParser.ts‎

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,12 @@ namespace pxt {
44
header: string;
55
attributes: pxt.Map<string>;
66
listAttributes?: pxt.Map<MarkdownList>;
7+
codeBlocks?: MarkdownCodeBlock[];
8+
}
9+
10+
export interface MarkdownCodeBlock {
11+
content: string;
12+
languageCode?: string;
713
}
814

915
export interface MarkdownList {
@@ -22,6 +28,7 @@ namespace pxt {
2228
let listStack: MarkdownList[] = [];
2329

2430
let currentIndent = 0;
31+
let currentCodeBlock: MarkdownCodeBlock | null = null;
2532

2633
for (const line of lines) {
2734
if (!line.trim()) {
@@ -31,6 +38,35 @@ namespace pxt {
3138
continue;
3239
}
3340

41+
if (line.startsWith("```")) {
42+
if (currentCodeBlock) {
43+
if (currentSection) {
44+
if (!currentSection.codeBlocks) {
45+
currentSection.codeBlocks = [currentCodeBlock]
46+
}
47+
else {
48+
currentSection.codeBlocks.push(currentCodeBlock);
49+
}
50+
}
51+
currentCodeBlock = null;
52+
continue;
53+
}
54+
else {
55+
const match = /^```([a-zA-Z_\-]*)$/.exec(line);
56+
57+
if (match) {
58+
currentCodeBlock = {
59+
content: "",
60+
languageCode: match[1]
61+
};
62+
continue;
63+
}
64+
}
65+
}
66+
else if (currentCodeBlock) {
67+
currentCodeBlock.content += line + "\n";
68+
}
69+
3470
if (line.startsWith("#")) {
3571
const headerMatch = /^(#+)\s*(.+)$/.exec(line);
3672

0 commit comments

Comments
 (0)