skewer-format 1.0.0 → 1.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.d.ts +2 -0
- package/dist/index.js +3 -1
- package/dist/src/interface.d.ts +17 -0
- package/dist/src/interface.js +2 -0
- package/dist/src/lexer.js +8 -30
- package/dist/src/methods.d.ts +2 -0
- package/dist/src/methods.js +8 -0
- package/dist/src/parser.d.ts +1 -18
- package/dist/src/parser.js +9 -9
- package/dist/tsconfig.tsbuildinfo +1 -0
- package/package.json +5 -9
package/dist/index.d.ts
CHANGED
package/dist/index.js
CHANGED
|
@@ -1,7 +1,9 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.parser = exports.lexer = void 0;
|
|
3
|
+
exports.skewerToJSON = exports.parser = exports.lexer = void 0;
|
|
4
4
|
var lexer_1 = require("./src/lexer");
|
|
5
5
|
Object.defineProperty(exports, "lexer", { enumerable: true, get: function () { return lexer_1.lexer; } });
|
|
6
6
|
var parser_1 = require("./src/parser");
|
|
7
7
|
Object.defineProperty(exports, "parser", { enumerable: true, get: function () { return parser_1.parser; } });
|
|
8
|
+
var methods_1 = require("./src/methods");
|
|
9
|
+
Object.defineProperty(exports, "skewerToJSON", { enumerable: true, get: function () { return methods_1.skewerToJSON; } });
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
export interface Question {
|
|
2
|
+
id?: string;
|
|
3
|
+
type?: string;
|
|
4
|
+
question?: string;
|
|
5
|
+
options?: {
|
|
6
|
+
key: string;
|
|
7
|
+
value: string;
|
|
8
|
+
}[];
|
|
9
|
+
answer?: string | Array<string>;
|
|
10
|
+
explanation?: string;
|
|
11
|
+
}
|
|
12
|
+
export interface QuestionSet {
|
|
13
|
+
id: string;
|
|
14
|
+
type: string;
|
|
15
|
+
para: string;
|
|
16
|
+
questions: Array<Question>;
|
|
17
|
+
}
|
package/dist/src/lexer.js
CHANGED
|
@@ -5,22 +5,22 @@ function lexer(input) {
|
|
|
5
5
|
const tokens = [];
|
|
6
6
|
const lines = input
|
|
7
7
|
.split("\n")
|
|
8
|
-
.map(line => line.trim())
|
|
8
|
+
.map((line) => line.trim())
|
|
9
9
|
.filter(Boolean);
|
|
10
10
|
for (const line of lines) {
|
|
11
11
|
const optionMatch = line.match(/^([A-Z])\.\s*(.+)$/);
|
|
12
12
|
if (optionMatch) {
|
|
13
13
|
tokens.push({
|
|
14
14
|
type: "OPTION_KEY",
|
|
15
|
-
value: optionMatch[1]
|
|
15
|
+
value: optionMatch[1],
|
|
16
16
|
});
|
|
17
17
|
tokens.push({
|
|
18
18
|
type: "DOT",
|
|
19
|
-
value: "."
|
|
19
|
+
value: ".",
|
|
20
20
|
});
|
|
21
21
|
tokens.push({
|
|
22
22
|
type: "OPTION_VALUE",
|
|
23
|
-
value: optionMatch[2]
|
|
23
|
+
value: optionMatch[2],
|
|
24
24
|
});
|
|
25
25
|
continue;
|
|
26
26
|
}
|
|
@@ -28,47 +28,25 @@ function lexer(input) {
|
|
|
28
28
|
if (keyValueMatch) {
|
|
29
29
|
tokens.push({
|
|
30
30
|
type: "KEY",
|
|
31
|
-
value: keyValueMatch[1]
|
|
31
|
+
value: keyValueMatch[1],
|
|
32
32
|
});
|
|
33
33
|
tokens.push({
|
|
34
34
|
type: "COLON",
|
|
35
|
-
value: ":"
|
|
35
|
+
value: ":",
|
|
36
36
|
});
|
|
37
37
|
tokens.push({
|
|
38
38
|
type: "VALUE",
|
|
39
|
-
value: keyValueMatch[2]
|
|
39
|
+
value: keyValueMatch[2],
|
|
40
40
|
});
|
|
41
41
|
}
|
|
42
42
|
const sentinalMatch = line.match(/^---$/m);
|
|
43
43
|
if (sentinalMatch) {
|
|
44
44
|
tokens.push({
|
|
45
45
|
type: "SENTINEL",
|
|
46
|
-
value: "---"
|
|
46
|
+
value: "---",
|
|
47
47
|
});
|
|
48
48
|
continue;
|
|
49
49
|
}
|
|
50
50
|
}
|
|
51
51
|
return tokens;
|
|
52
52
|
}
|
|
53
|
-
const input = `
|
|
54
|
-
|
|
55
|
-
---
|
|
56
|
-
QUESTION: Which of the following best describes the primary purpose of a preloader in web design?
|
|
57
|
-
A. To enhance the visual aesthetics of the website
|
|
58
|
-
B. To ensure faster actual loading times of the website
|
|
59
|
-
C. To create the perception of faster loading times through engaging animations or progress indicators
|
|
60
|
-
D. To provide additional information about the website's content
|
|
61
|
-
ANSWER: C
|
|
62
|
-
EXPLANATION: Preloaders are used to create the perception of faster loading times, engaging users with animations or progress indicators while the website content loads in the background.
|
|
63
|
-
|
|
64
|
-
---
|
|
65
|
-
QUESTION: In the context of web design, what does SVG stand for and what is its primary use?
|
|
66
|
-
A. Scalable Vector Graphics, used for defining three-dimensional graphics
|
|
67
|
-
B. Simple Vector Graphics, used for creating basic two-dimensional images
|
|
68
|
-
C. Scalable Vector Graphics, used for defining two-dimensional graphics with interactivity and animation support
|
|
69
|
-
D. Standard Vector Graphics, used for standardizing image formats across different platforms
|
|
70
|
-
ANSWER: C
|
|
71
|
-
EXPLANATION: SVG stands for Scalable Vector Graphics, an XML-based vector image format for two-dimensional graphics with support for interactivity and animation.
|
|
72
|
-
|
|
73
|
-
---
|
|
74
|
-
`;
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.skewerToJSON = skewerToJSON;
|
|
4
|
+
const lexer_1 = require("./lexer");
|
|
5
|
+
const parser_1 = require("./parser");
|
|
6
|
+
function skewerToJSON(input) {
|
|
7
|
+
return (0, parser_1.parser)((0, lexer_1.lexer)(input));
|
|
8
|
+
}
|
package/dist/src/parser.d.ts
CHANGED
|
@@ -1,20 +1,3 @@
|
|
|
1
1
|
import type { Token } from "./lexer.js";
|
|
2
|
-
|
|
3
|
-
id?: string;
|
|
4
|
-
type?: string;
|
|
5
|
-
question?: string;
|
|
6
|
-
options?: {
|
|
7
|
-
key: string;
|
|
8
|
-
value: string;
|
|
9
|
-
}[];
|
|
10
|
-
answer?: string | Array<string>;
|
|
11
|
-
explanation?: string;
|
|
12
|
-
}
|
|
13
|
-
interface QuestionSet {
|
|
14
|
-
id: string;
|
|
15
|
-
type: string;
|
|
16
|
-
para: string;
|
|
17
|
-
questions: Array<Question>;
|
|
18
|
-
}
|
|
2
|
+
import { type Question, type QuestionSet } from "./interface";
|
|
19
3
|
export declare function parser(tokens: Token[]): Array<Question | QuestionSet>;
|
|
20
|
-
export {};
|
package/dist/src/parser.js
CHANGED
|
@@ -6,14 +6,14 @@ function parser(tokens) {
|
|
|
6
6
|
var _a;
|
|
7
7
|
const resultArr = [];
|
|
8
8
|
let question = {
|
|
9
|
-
options: []
|
|
9
|
+
options: [],
|
|
10
10
|
};
|
|
11
11
|
let sentinel = "close";
|
|
12
|
-
let currentType;
|
|
12
|
+
// let currentType: string;
|
|
13
13
|
let i = 0;
|
|
14
14
|
function resetQuestion() {
|
|
15
15
|
question = {
|
|
16
|
-
options: []
|
|
16
|
+
options: [],
|
|
17
17
|
};
|
|
18
18
|
}
|
|
19
19
|
while (i < tokens.length) {
|
|
@@ -32,7 +32,7 @@ function parser(tokens) {
|
|
|
32
32
|
switch (key) {
|
|
33
33
|
case "TYPE":
|
|
34
34
|
question.type = valueToken.value;
|
|
35
|
-
currentType = valueToken.value;
|
|
35
|
+
// currentType = valueToken.value;
|
|
36
36
|
break;
|
|
37
37
|
case "QUESTION":
|
|
38
38
|
if (sentinel === "open") {
|
|
@@ -52,7 +52,8 @@ function parser(tokens) {
|
|
|
52
52
|
else {
|
|
53
53
|
question.answer = valueToken.value;
|
|
54
54
|
}
|
|
55
|
-
if (question.answer.length == 1 &&
|
|
55
|
+
if (question.answer.length == 1 &&
|
|
56
|
+
question.type == undefined) {
|
|
56
57
|
question.type = "MCQ";
|
|
57
58
|
}
|
|
58
59
|
break;
|
|
@@ -66,11 +67,10 @@ function parser(tokens) {
|
|
|
66
67
|
}
|
|
67
68
|
if (token.type == "OPTION_KEY") {
|
|
68
69
|
const optionValueToken = tokens[i + 2];
|
|
69
|
-
if (optionValueToken &&
|
|
70
|
-
optionValueToken.type === "OPTION_VALUE") {
|
|
70
|
+
if (optionValueToken && optionValueToken.type === "OPTION_VALUE") {
|
|
71
71
|
(_a = question.options) === null || _a === void 0 ? void 0 : _a.push({
|
|
72
72
|
key: token.value,
|
|
73
|
-
value: optionValueToken.value
|
|
73
|
+
value: optionValueToken.value,
|
|
74
74
|
});
|
|
75
75
|
i += 3;
|
|
76
76
|
continue;
|
|
@@ -136,6 +136,6 @@ ANSWER: B
|
|
|
136
136
|
EXPLANATION: Serif fonts are often chosen for their historical significance and readability, making them a popular choice for body text in web design to ensure clarity and ease of reading.
|
|
137
137
|
|
|
138
138
|
---`;
|
|
139
|
-
|
|
139
|
+
const lex_out = (0, lexer_js_1.lexer)(input);
|
|
140
140
|
// console.log(lex_out);
|
|
141
141
|
console.log(parser(lex_out));
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"root":["../index.ts","../src/interface.ts","../src/lexer.ts","../src/methods.ts","../src/parser.ts"],"version":"5.9.3"}
|
package/package.json
CHANGED
|
@@ -1,17 +1,17 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "skewer-format",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.1.0",
|
|
4
4
|
"description": "New format to store quiz in text format",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"author": "sassykumar <sasikumarstu@gamil.com>",
|
|
7
7
|
"files": [
|
|
8
8
|
"dist"
|
|
9
9
|
],
|
|
10
|
-
"type": "
|
|
10
|
+
"type": "module",
|
|
11
11
|
"main": "dist/index.js",
|
|
12
12
|
"scripts": {
|
|
13
13
|
"dev": "vite",
|
|
14
|
-
"build": "tsc -b
|
|
14
|
+
"build": "tsc -b ",
|
|
15
15
|
"lint": "eslint .",
|
|
16
16
|
"preview": "vite preview",
|
|
17
17
|
"prepare": "husky"
|
|
@@ -42,11 +42,7 @@
|
|
|
42
42
|
"vite": "^8.0.0"
|
|
43
43
|
},
|
|
44
44
|
"lint-staged": {
|
|
45
|
-
"*.{js,ts,tsx,json,css,md}":
|
|
46
|
-
|
|
47
|
-
],
|
|
48
|
-
"*.{js,ts,tsx}": [
|
|
49
|
-
"eslint --fix --max-warnings=10"
|
|
50
|
-
]
|
|
45
|
+
"*.{js,ts,tsx,json,css,md}": "prettier --write",
|
|
46
|
+
"*.{js,ts,tsx}": "eslint --fix --max-warnings=10"
|
|
51
47
|
}
|
|
52
48
|
}
|