Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
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
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Programme

> [!WARNING]
> [!WARNING]
> This repository is under construction. If you're looking for the current HYF curriculum, check out [Curriculum](https://github.com/HackYourFuture-CPH/curriculum).

Documents the HYF programme, courses and modules.
13 changes: 13 additions & 0 deletions support/src/parse.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,21 @@ export type ParsedImage = {
export type ParseResult = {
readonly links: readonly ParsedLink[];
readonly images: readonly ParsedImage[];
readonly trailingWhitespace: readonly SourceLocation[];
};

export const parse = (content: string): ParseResult => {
const trailingWhitespace: SourceLocation[] = [];

content.split(/\n/).forEach((line, index) => {
if (line.endsWith(" ")) {
trailingWhitespace.push({
line0: index,
column0: line.trimEnd().length,
});
}
});

const parser = mit();
const tokens = parser.parse(content, {});

Expand Down Expand Up @@ -64,5 +76,6 @@ export const parse = (content: string): ParseResult => {
return {
links: parsedLinks,
images: parsedImages,
trailingWhitespace,
};
};
15 changes: 11 additions & 4 deletions support/src/validateLinks.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,10 +28,7 @@ const findAllFiles = async (): Promise<string[]> => {
};

const findMarkdownFiles = (files: string[]): string[] => {
const ignorePattern = /^(README|LICENSE|contributing\/)/;
return files.filter(
(f) => f.toLocaleLowerCase().endsWith(".md") && !ignorePattern.test(f),
);
return files.filter((f) => f.toLocaleLowerCase().endsWith(".md"));
};

const scanForLinks = async (filenames: string[]): Promise<ParsedFile[]> => {
Expand Down Expand Up @@ -70,6 +67,16 @@ const main = async () => {
let errors = 0;

for (const parsedFile of parsedFiles) {
for (const ws of parsedFile.trailingWhitespace) {
showError(
parsedFile.filename,
ws,
"VL003/trailing-whitespace",
"Trailing whitespace",
);
++errors;
}

for (const img of parsedFile.images) {
if (!isExternalLink(img.src)) {
const resolved = path.join(dirname(parsedFile.filename), img.src);
Expand Down