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/markdown as master#48

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 17 commits intomasterfromfeature/markdown-as-master
Jun 24, 2020
Merged
Changes from1 commit
Commits
Show all changes
17 commits
Select commitHold shift + click to select a range
504103a
setup tests
ShMcKJun 21, 2020
8ba4877
update markdown validation
ShMcKJun 21, 2020
67bdfd7
test/update commit order
ShMcKJun 21, 2020
8af3bf6
update parser progress
ShMcKJun 21, 2020
4bb28b9
passing step tests
ShMcKJun 21, 2020
b0d2369
complete parser tests
ShMcKJun 21, 2020
5dd69ce
remove commit validation in skeleton
ShMcKJun 21, 2020
791212e
make step solution optional
ShMcKJun 21, 2020
67b0195
fix multiple commit order issue
ShMcKJun 21, 2020
8558b8e
fix step commit parsing
ShMcKJun 21, 2020
692cb66
setup commit parsing for testing
ShMcKJun 23, 2020
deba9b3
parse commits with tests
ShMcKJun 23, 2020
f6159c4
validate commits
ShMcKJun 24, 2020
0765174
validate step has tests && tests before solution
ShMcKJun 24, 2020
1b7d20b
update step ids
ShMcKJun 24, 2020
325ba8b
update docs for new build format
ShMcKJun 24, 2020
aa745f9
prepare release
ShMcKJun 24, 2020
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
complete parser tests
Signed-off-by: shmck <shawn.j.mckay@gmail.com>
  • Loading branch information
@ShMcK
ShMcK committedJun 21, 2020
commitb0d2369d7f09db9791f4f8761a5770b823dc5c37
104 changes: 32 additions & 72 deletionssrc/utils/parse.ts
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -45,15 +45,15 @@ export function parseMdContent(md: string): TutorialFrame | never {
mdContent.summary.description = summaryMatch.groups.tutorialDescription.trim();
}

let current = { level: -1, step:0 };
let current = { level: -1, step:-1 };
// Identify each part of the content
parts.forEach((section: string) => {
// match level
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) {
current = { level: current.level + 1, step:0 };
current = { level: current.level + 1, step:-1 };
const { levelTitle, levelSummary, levelContent } = levelMatch.groups;

// @ts-ignore
Expand All@@ -75,15 +75,15 @@ export function parseMdContent(md: string): TutorialFrame | never {
const stepRegex = /^(#{3}\s(?<stepTitle>.*)[\n\r]+(?<stepContent>[^]*))/;
const stepMatch: RegExpMatchArray | null = section.match(stepRegex);
if (stepMatch && stepMatch.groups) {
current = { level: current.level, step: current.step + 1 };
const { stepId, stepContent } = stepMatch.groups;
mdContent.levels[current.level].steps[current.step] = {
id: `${current.level + 1}.${current.step + 1}`,
content: stepContent.trim(),
};
current = { ...current, step: current.step + 1 };
} else {
// parse hints from stepContent
const hintDetectRegex = /^(#{4}\sHINTS[\n\r]+(\*\s(?<hintContent>[^]*))[\n\r]+)+/;
const hintDetectRegex = /^(#{4}\sHINTS[\n\r]+([\*|\-]\s(?<hintContent>[^]*))[\n\r]+)+/;
const hintMatch = section.match(hintDetectRegex);
if (!!hintMatch) {
const hintItemRegex = /[\n\r]+\*\s/;
Expand DownExpand Up@@ -142,84 +142,44 @@ export function parse(params: ParseParams): any {
level = { ...configLevelProps, ...level };
if (steps) {
steps.forEach((step: T.Step, index: number) => {
console.log("step", step);
const mdStep = level.steps[index];
console.log("mdStep", mdStep);
step = {
...step,
...mdStep,
};

conststepKey = step.id;
console.log("stepKey", stepKey);
const stepSetupKey = `${stepKey}Q`;
if (params.commits[stepSetupKey]) {
if (!step.setup) {
step.setup = {
commits: [],
};
try {
const mdStep = level.steps[index];

step = {
...step,
...mdStep,
};

conststepSetupKey =`${step.id}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 = `${step.id}A`;
if (params.commits[stepSolutionKey]) {
if (!step.solution) {
step.solution = {
commits: [],
};
}
step.solution.commits = params.commits[stepSolutionKey];
}
step.solution.commits = params.commits[stepSolutionKey];
} catch (error) {
console.error("Error parsing level steps");
console.warn(JSON.stringify(level.steps));
console.error(error.message);
}
// update level step
level.steps[index] = step;
});
}
}

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

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

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

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

console.log(params.commits);

if (params.commits[level.id]) {
if (!level.setup) {
level.setup = {};
Expand Down

[8]ページ先頭

©2009-2025 Movatter.jp