Skip to content
This repository was archived by the owner on Aug 11, 2021. It is now read-only.

Commit c0192d7

Browse files
authored
Fix italic validation errors (#106)
* Fix italic valid * Remove reference to external metadata file * Make embedded binary image data a warning
1 parent e356406 commit c0192d7

File tree

3 files changed

+14
-13
lines changed

3 files changed

+14
-13
lines changed

scripts/validation/config/rules-tutorials.yml

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,12 @@
3434
format: markdown
3535
errorMessage: Missing 'Required Hardware and Software' section.
3636

37-
- regex: "\\s[\\*_][^*_](?:.*?)[\\*_]"
37+
- regex: "(?<=\\s)\\*[^* ].*\\*[^*]"
38+
shouldMatch: false
39+
format: markdown
40+
errorMessage: The use of italic emphasis is discouraged.
41+
42+
- regex: "(?<=\\s)_[^_].*_[^_]"
3843
shouldMatch: false
3944
format: markdown
4045
errorMessage: The use of italic emphasis is discouraged.

scripts/validation/domain/tutorial.js

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -78,10 +78,6 @@ var Tutorial = class Tutorial {
7878
return files.map(file => file.split("?")[0]);
7979
}
8080

81-
get metadataPath(){
82-
return this.basePath + "/metadata.json";
83-
}
84-
8581
get metadata(){
8682
try {
8783
let rawData = fs.readFileSync(this.path).toString();

scripts/validation/validate.js

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -32,30 +32,30 @@ validator.addValidation(async (tutorials) => {
3232
tutorials.forEach(tutorial => {
3333
let jsonData = tutorial.metadata;
3434
if(!jsonData) {
35-
const errorMessage = "No metadata file found";
36-
errorsOccurred.push(new ValidationError(errorMessage, tutorial.metadataPath));
35+
const errorMessage = "No metadata found";
36+
errorsOccurred.push(new ValidationError(errorMessage, tutorial.path));
3737
return;
3838
}
3939

4040
try {
4141
if(!jsonData.coverImage){
4242
const errorMessage = "No cover image found";
43-
errorsOccurred.push(new ValidationError(errorMessage, tutorial.metadataPath));
43+
errorsOccurred.push(new ValidationError(errorMessage, tutorial.path));
4444
} else if (jsonData.coverImage.indexOf(".svg") == -1) {
4545
const errorMessage = "Cover image is not in SVG format.";
46-
errorsOccurred.push(new ValidationError(errorMessage, tutorial.metadataPath));
46+
errorsOccurred.push(new ValidationError(errorMessage, tutorial.path));
4747
}
4848

4949
let jsonSchema = JSON.parse(fs.readFileSync(config.metadataSchema));
5050
let validationResult = validate(jsonData, jsonSchema);
5151
if(validationResult.errors.length != 0){
5252
const errorMessage = `An error occurred while validating the metadata ${validationResult}`;
53-
errorsOccurred.push(new ValidationError(errorMessage, tutorial.metadataPath));
53+
errorsOccurred.push(new ValidationError(errorMessage, tutorial.path));
5454
}
5555

5656
} catch (error) {
5757
const errorMessage = "An error occurred while parsing the metadata";
58-
errorsOccurred.push(new ValidationError(errorMessage, tutorial.metadataPath));
58+
errorsOccurred.push(new ValidationError(errorMessage, tutorial.path));
5959
}
6060
});
6161
return errorsOccurred;
@@ -96,8 +96,8 @@ validator.addValidation(async (tutorials) => {
9696
let image = htmlDoc.querySelector("image")
9797
// Detect if there are embedded images that are actually rendered
9898
if(image.attributes.width || image.attributes.height){
99-
const errorMessage = path + " containes embedded binary images";
100-
errorsOccurred.push(new ValidationError(errorMessage, tutorial.path));
99+
const errorMessage = path + " contains embedded binary images.";
100+
errorsOccurred.push(new ValidationError(errorMessage, tutorial.path, "warning"));
101101
}
102102
}
103103
});

0 commit comments

Comments
 (0)