From b39ca75d49fdf005c43cd9b4d7ea300aec32d012 Mon Sep 17 00:00:00 2001 From: Richard Knoll Date: Wed, 3 Dec 2025 18:38:55 +0000 Subject: [PATCH] allow skillmaps to specify name and description in code blocks for RTL languages --- skillmap/src/lib/skillMapParser.ts | 20 ++++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) diff --git a/skillmap/src/lib/skillMapParser.ts b/skillmap/src/lib/skillMapParser.ts index d400a8242be6..f4edf7201632 100644 --- a/skillmap/src/lib/skillMapParser.ts +++ b/skillmap/src/lib/skillMapParser.ts @@ -95,8 +95,8 @@ function buildMapFromSections(header: MarkdownSection, sections: MarkdownSection function inflateSkillMap(section: MarkdownSection): Partial { const result: Partial = { mapId: section.header.toLowerCase(), - displayName: section.attributes["name"] || section.header, - description: section.attributes["description"], + displayName: section.attributes["name"] || getCodeBlock(section, "name") || section.header, + description: section.attributes["description"] || getCodeBlock(section, "description"), completionUrl: section.attributes["completionurl"], prerequisites: [], activities: {}, @@ -135,7 +135,7 @@ function inflateMapNode(section: MarkdownSection): MapNode { activityId: section.header.toLowerCase(), imageUrl: section.attributes["imageurl"], next: [], - displayName: section.attributes["name"] || section.header, + displayName: section.attributes["name"] || getCodeBlock(section, "name") || section.header, nextIds: parseList(section.attributes["next"]) } @@ -309,7 +309,7 @@ function inflateActivity(section: MarkdownSection, base: Partial): const result: Partial = { ...base, kind: "activity", - description: section.attributes["description"], + description: section.attributes["description"] || getCodeBlock(section, "description"), url: section.attributes["url"], tags: parseList(section.attributes["tags"]), // defaults to true @@ -384,11 +384,11 @@ function inflateMetadata(section: MarkdownSection): PageMetadata { const lockedNodeColor = section.attributes["lockednodecolor"]; const completedNodeColor = section.attributes["completednodecolor"]; - const introductoryModal = section.codeBlocks?.find(b => b.languageCode === "intro"); + const introductoryModal = getCodeBlock(section, "intro"); return { - title: section.attributes["name"] || section.header, - description: section.attributes["description"], + title: section.attributes["name"] || getCodeBlock(section, "name") || section.header, + description: section.attributes["description"] || getCodeBlock(section, "description"), infoUrl: cleanInfoUrl(section.attributes["infourl"]), backgroundImageUrl: section.attributes["backgroundurl"], pixelatedBackground: isTrue(section.attributes["pixelatedbackground"]), @@ -411,10 +411,14 @@ function inflateMetadata(section: MarkdownSection): PageMetadata { selectedStrokeColor: highlight || "var(--pxt-primary-background)", pathOpacity: 0.5, }, - introductoryModal: introductoryModal?.content + introductoryModal } } +function getCodeBlock(section: MarkdownSection, languageCode: string): string | undefined { + return section.codeBlocks?.find(b => b.languageCode === languageCode)?.content?.trim(); +} + function getContrastingColor(color: string) { color = color.replace("#", ""); const r = Number.parseInt(color.slice(0, 2), 16);