If you've been following my blog then you know that I have created an extremely simple static site generator in Rust. That blog can be found here for more info. This week we were tasked with filing a PR on a fellow student's repo to add markdown file support and basic parsing.
To get started on making the pull request I first filed an issue detailing what I would be working on.
The first step I made was actually filing a new issue...I found that the previous logic would not work because all files in the current dir with the same file ending would be added to dist.
python romanssg.py -i=example <- All files that are the same filetypes as example would be added to the dist folder. This is because the previous logic found all files that was the same filetype the directory and added them to files to be processed.
for i in os.listdir("."): if fnmatch.fnmatch(i, "*.txt"): arrayOfFiles.append(i)
filename = curr_value # <-- input arrayOfFiles.append(filename)
Next I moved on to adding markdown support. All I had to do was replace header level 1 tags with h1 tags and append the line to the file
if x.startswith("# "): x = x.replace("# ", "<h1>") newFile.write("\t" + x + "</h1>\n")
Small changes were made to the README as well to indicate that markdown file support was introduced with header level 1 parsing. This was all done with the below PR
The overall experience was fun. It was interesting seeing the workflow of forking, modifying and submitting PR's and also having them reviewed. Next time I hope to start working on PR's earlier because having a short time frame introduces the opportunity to make mistakes or miss test cases....which I probably have...
Thanks for reading! :)