Skip to content

Commit 7737fb4

Browse files
committed
@onPageComplete added
1 parent 5d58fae commit 7737fb4

File tree

11 files changed

+52
-31
lines changed

11 files changed

+52
-31
lines changed

lib/build/parser/match.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,9 @@ var regex = {
99
'###': match('#', 3),
1010
'+': match('\\+', 1),
1111
'```': match('`', 3),
12-
'action': /^@(action|test|hint|continue)/,
12+
'action': /^@(action|test|hint)/,
1313
'import': /^@import\((.+)\)$/,
14-
'onComplete': /^(@onComplete.+)/
14+
'onPageComplete': /^(@onPageComplete.+)/
1515
};
1616
function parseWithCode(code) {
1717
return function (line) {
@@ -33,7 +33,7 @@ exports.task = parseWithCode('+');
3333
exports.codeBlock = parseWithCode('```');
3434
exports.isAction = parseWithCode('action');
3535
exports.isImport = parseWithCode('import');
36-
exports.isComplete = parseWithCode('onComplete');
36+
exports.isPageComplete = parseWithCode('onPageComplete');
3737
exports.isArray = function (line) {
3838
var isMatch = line.match(/^\[.+\]$/);
3939
return isMatch ? isMatch[0] : null;

lib/build/parser/page.js

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ function page(result, lines, index) {
1212
description: ''
1313
});
1414
var inCodeBlock = false;
15-
var currentComplete = null;
15+
var currentPageComplete = null;
1616
var bracketCount = 0;
1717
var i = 0;
1818
while (i < lines.length - 1) {
@@ -22,12 +22,12 @@ function page(result, lines, index) {
2222
case !!Match.isImport(line):
2323
lines = import_1.loadImport(lines, Match.isImport(line));
2424
continue;
25-
case (!!Match.isComplete(line) || !!currentComplete):
26-
currentComplete = !!currentComplete ? currentComplete += '\n' + line : Match.isComplete(line);
27-
bracketCount = cleanup_1.bracketTracker(currentComplete);
25+
case (!!Match.isPageComplete(line) || !!currentPageComplete):
26+
currentPageComplete = !!currentPageComplete ? currentPageComplete += '\n' + line : Match.isPageComplete(line);
27+
bracketCount = cleanup_1.bracketTracker(currentPageComplete);
2828
if (bracketCount === 0) {
29-
result.chapters[index.chapter].pages[index.page].onComplete = cleanup_1.trimValue(currentComplete);
30-
currentComplete = null;
29+
result.chapters[index.chapter].pages[index.page].onPageComplete = cleanup_1.trimValue(currentPageComplete);
30+
currentPageComplete = null;
3131
}
3232
continue;
3333
case !!Match.codeBlock(line):

lib/build/parser/task.js

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ function task(result, lines, index) {
1111
});
1212
index.task += 1;
1313
var inCodeBlock = false;
14+
var currentPageComplete = null;
1415
var currentAction = null;
1516
var bracketCount = 0;
1617
var i = 0;
@@ -21,6 +22,14 @@ function task(result, lines, index) {
2122
case !!Match.isImport(line):
2223
lines = import_1.loadImport(lines, Match.isImport(line));
2324
continue;
25+
case (!!Match.isPageComplete(line) || !!currentPageComplete):
26+
currentPageComplete = !!currentPageComplete ? currentPageComplete += '\n' + line : Match.isPageComplete(line);
27+
bracketCount = cleanup_1.bracketTracker(currentPageComplete);
28+
if (bracketCount === 0) {
29+
result.chapters[index.chapter].pages[index.page].onPageComplete = cleanup_1.trimValue(currentPageComplete);
30+
currentPageComplete = null;
31+
}
32+
continue;
2433
case !!currentAction:
2534
if (line.length === 0) {
2635
currentAction += '\n';

lib/cli.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ var search_1 = require('./search/search');
99
var tutorials_1 = require('./tutorials/tutorials');
1010
var publish_1 = require('./publish/publish');
1111
program
12-
.version('0.3.23')
12+
.version('0.3.24')
1313
.usage('[options] <keywords>')
1414
.option('-b, --build [path/to/tutorial.md]', 'tutorial markdown file', /^.+\.md$/i)
1515
.option('-c, --create [name]', 'tutorial name')

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "coderoad-cli",
3-
"version": "0.3.23",
3+
"version": "0.3.24",
44
"description": "Command line interface for CodeRoad. Build project files.",
55
"keywords": [
66
"coderoad"

src/build/parser/match.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,9 @@ var regex = {
1010
'###': match('#', 3),
1111
'+': match('\\+', 1),
1212
'```': match('`', 3),
13-
'action': /^@(action|test|hint|continue)/,
13+
'action': /^@(action|test|hint)/,
1414
'import': /^@import\((.+)\)$/,
15-
'onComplete': /^(@onComplete.+)/
15+
'onPageComplete': /^(@onPageComplete.+)/
1616
};
1717

1818
function parseWithCode(code: string) {
@@ -35,7 +35,7 @@ export const task = parseWithCode('+');
3535
export const codeBlock = parseWithCode('```');
3636
export const isAction = parseWithCode('action');
3737
export const isImport = parseWithCode('import');
38-
export const isComplete = parseWithCode('onComplete');
38+
export const isPageComplete = parseWithCode('onPageComplete');
3939

4040
export const isArray = function(line: string): string {
4141
let isMatch = line.match(/^\[.+\]$/);

src/build/parser/page.ts

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ export function page(result: CR.Output, lines: string[], index: CR.Index): CR.Ou
1212
description: ''
1313
});
1414
let inCodeBlock = false;
15-
let currentComplete = null;
15+
let currentPageComplete = null;
1616
let bracketCount = 0;
1717

1818
let i = 0;
@@ -28,13 +28,13 @@ export function page(result: CR.Output, lines: string[], index: CR.Index): CR.Ou
2828
continue;
2929

3030
// @onComplete
31-
case (!!Match.isComplete(line) || !!currentComplete):
32-
currentComplete = !!currentComplete ? currentComplete += '\n' + line : Match.isComplete(line);
33-
bracketCount = bracketTracker(currentComplete);
31+
case (!!Match.isPageComplete(line) || !!currentPageComplete):
32+
currentPageComplete = !!currentPageComplete ? currentPageComplete += '\n' + line : Match.isPageComplete(line);
33+
bracketCount = bracketTracker(currentPageComplete);
3434
// complete
3535
if (bracketCount === 0) {
36-
result.chapters[index.chapter].pages[index.page].onComplete = trimValue(currentComplete);
37-
currentComplete = null;
36+
result.chapters[index.chapter].pages[index.page].onPageComplete = trimValue(currentPageComplete);
37+
currentPageComplete = null;
3838
}
3939
continue;
4040

src/build/parser/task.ts

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import * as Match from './match';
22
import {chapter} from './chapter';
33
import {page} from './page';
44
import {addToTasks} from './actions';
5-
import {trimLeadingSpaces, bracketTracker} from './cleanup';
5+
import {trimLeadingSpaces, bracketTracker, trimValue} from './cleanup';
66
import {loadImport} from './import';
77

88

@@ -13,6 +13,7 @@ export function task(result: CR.Output, lines: string[], index: CR.Index): CR.Ou
1313
});
1414
index.task += 1;
1515
let inCodeBlock = false;
16+
let currentPageComplete = null;
1617
let currentAction = null;
1718
let bracketCount = 0;
1819

@@ -28,6 +29,17 @@ export function task(result: CR.Output, lines: string[], index: CR.Index): CR.Ou
2829
lines = loadImport(lines, Match.isImport(line));
2930
continue;
3031

32+
// @onComplete
33+
case (!!Match.isPageComplete(line) || !!currentPageComplete):
34+
currentPageComplete = !!currentPageComplete ? currentPageComplete += '\n' + line : Match.isPageComplete(line);
35+
bracketCount = bracketTracker(currentPageComplete);
36+
// complete
37+
if (bracketCount === 0) {
38+
result.chapters[index.chapter].pages[index.page].onPageComplete = trimValue(currentPageComplete);
39+
currentPageComplete = null;
40+
}
41+
continue;
42+
3143
// @action multiline
3244
case !!currentAction:
3345
if (line.length === 0) {

src/cli.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ import tutorials from './tutorials/tutorials';
99
import publish from './publish/publish';
1010

1111
program
12-
.version('0.3.23')
12+
.version('0.3.24')
1313
.usage('[options] <keywords>')
1414
.option('-b, --build [path/to/tutorial.md]', 'tutorial markdown file', /^.+\.md$/i)
1515
.option('-c, --create [name]', 'tutorial name')

src/typings/cr.d.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ declare namespace CR {
1515
title: string;
1616
description: string;
1717
tasks?: Task[];
18-
onComplete?: string;
18+
onPageComplete?: string;
1919
}
2020
interface Task {
2121
description: string;

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy