Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Feature/hints#31

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Merged
ShMcK merged 5 commits intomasterfromfeature/hints
Jun 7, 2020
Merged
Show file tree
Hide file tree
Changes from1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
PrevPrevious commit
NextNext commit
run multi-line step test
Signed-off-by: shmck <shawn.j.mckay@gmail.com>
  • Loading branch information
@ShMcK
ShMcK committedJun 7, 2020
commit142a047fc2e613f539b9da19f85f7cb7ccf70d7a
74 changes: 44 additions & 30 deletionssrc/utils/parse.ts
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -52,7 +52,7 @@ export function parseMdContent(md: string): TutorialFrame | never {
// Identify each part of the content
parts.forEach((section: string) => {
// match level
const levelRegex = /^(##\s(?<levelId>L\d+)\s(?<levelTitle>.*)[\n\r]*(>\s*(?<levelSummary>.*))?[\n\r]+(?<levelContent>[^]*))/;
const levelRegex = /^(#{2}\s(?<levelId>L\d+)\s(?<levelTitle>.*)[\n\r]*(>\s*(?<levelSummary>.*))?[\n\r]+(?<levelContent>[^]*))/;
const levelMatch: RegExpMatchArray | null = section.match(levelRegex);
if (levelMatch && levelMatch.groups) {
const {
Expand All@@ -73,10 +73,18 @@ export function parseMdContent(md: string): TutorialFrame | never {
};
} else {
// match step
const stepRegex = /^(###\s(?<stepId>(?<levelId>L\d+)S\d+)\s(?<stepTitle>.*)[\n\r]+(?<stepContent>[^]*))/;
const stepRegex = /^(#{3}\s(?<stepId>(?<levelId>L\d+)S\d+)\s(?<stepTitle>.*)[\n\r]+(?<stepContent>[^]*))/;
const stepMatch: RegExpMatchArray | null = section.match(stepRegex);
if (stepMatch && stepMatch.groups) {
const { stepId, stepContent } = stepMatch.groups;

// parse hints from stepContent
// const hintRegex = /^(#{4}\sHINTS[\n\r]+(?<hintContent>[^]*))/g;

// if (!!stepContent.match(hintRegex)) {
// console.log("HAS HINT");
// }

mdContent.steps[stepId] = {
id: stepId,
content: stepContent.trim(),
Expand DownExpand Up@@ -135,39 +143,45 @@ export function parse(params: ParseParams): any {
}

// add level step commits
level.steps = (level.steps || []).map(
(step: T.Step, stepIndex: number) => {
const stepKey = `${levelSetupKey}S${stepIndex + 1}`;
const stepSetupKey = `${stepKey}Q`;
if (params.commits[stepSetupKey]) {
if (!step.setup) {
step.setup = {
commits: [],
};
try {
level.steps = (level.steps || []).map(
(step: T.Step, stepIndex: number) => {
const stepKey = `${levelSetupKey}S${stepIndex + 1}`;
const stepSetupKey = `${stepKey}Q`;
if (params.commits[stepSetupKey]) {
if (!step.setup) {
step.setup = {
commits: [],
};
}
step.setup.commits = params.commits[stepSetupKey];
}
step.setup.commits = params.commits[stepSetupKey];
}

const stepSolutionKey = `${stepKey}A`;
if (params.commits[stepSolutionKey]) {
if (!step.solution) {
step.solution = {
commits: [],
};
const stepSolutionKey = `${stepKey}A`;
if (params.commits[stepSolutionKey]) {
if (!step.solution) {
step.solution = {
commits: [],
};
}
step.solution.commits = params.commits[stepSolutionKey];
}
step.solution.commits = params.commits[stepSolutionKey];
}

// add markdown
const stepMarkdown: Partial<T.Step> = mdContent.steps[step.id];
if (stepMarkdown) {
step = { ...step, ...stepMarkdown };
}
// add markdown
const stepMarkdown: Partial<T.Step> = mdContent.steps[step.id];
if (stepMarkdown) {
step = { ...step, ...stepMarkdown };
}

step.id = `${stepKey}`;
return step;
}
);
step.id = `${stepKey}`;
return step;
}
);
} catch (error) {
console.log(JSON.stringify(level.steps));
console.error("Error parsing level steps");
console.error(error.message);
}

return level;
})
Expand Down
Loading

[8]ページ先頭

©2009-2025 Movatter.jp