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.
Welcome to Romans Static Site Generator v.0.1
RomanStaticSG is made in python. It is a simple static site generator. It accepts an input file, or input folder. The current file types that are parsed are text and markdown. Markdown however currently only supports heading level 1 parsing. The program will then take the accepted files and create basic html webpages, as well as an index.html file. The script also allows you to input a custom output directory, so that the files could be saved in a custom location.
How to Use RomanStaticSG
Python 3.9+ Required
To use RomanStaticSG simply type
python romanssg.py --help
When running the command input command and not specifying the output command, a local folder named "dist" will be created in the directory of the existing file
python romanssg.py --help | python romanssg.py -h Help Screen Usage: python romanssg.py Commands:
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) Changed to 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! :)