This week in my Open Source Development course, I was tasked with contributing to another student's project by submitting my additions through a Pull Request.
The project I decided to contribute to was called til-to-html by paulkim26. This project is essentially a command-line tool that converts .txt
files into .html
files and adds in the necessary HTML
tags.
Process of Submitting my Pull Request
In order to contribute to this project, I decided to add in two new features:
- Add file support for
.md
files - Add capabilities to convert Heading 2 markdown syntax to the appropriate
<h2>...</h2>
HTML tag
Initially, I submitted an issue describing the features I planned to work on, and once it was approved, I forked the repo and got to work on the implementation.
Adding in the support for .md
files was as easy as adding in another condition when checking the extensions of the files to also check for files that end in .md
, but parsing the Heading 2 syntax into HTML needed more work.
In order to complete this feature, I took advantage of regex to search through each line of text and to check if a line matched the Heading 2 markdown syntax. Now, most of the markdown types have alternative syntaxes, and the alternative syntax for Heading 2 requires a dashed line on the line after the heading text, which I also managed to implement through regex.
Syntax | Alternate Syntax | HTML | Rendered Output |
---|---|---|---|
## Heading 2 |
Heading 2 ---------
|
<h2>Heading 2</h2> |
Heading 2 |
After testing the changes I made on my forked repo, it was time to create a pull request. There were a few changes that were requested based on my pull request, but they were mostly based on the way I wrote my code, and I just needed to rewrite some parts to match the owner's style of writing code. After updating my pull request based on the feedback I got, it was approved and the new features were merged with their main branch!
Getting a Pull Request for My Repository
Just as I was tasked to submit a pull request on another project, there was another student who had to submit one for mine. My project was a similar text-to-html converter called TILerator so the additions they wanted to make involved:
- Adding file support for
.md
files - Parsing bold markdown syntax to
<b>...</b>
HTML tag
Their pull request provided some meaningful additions I was willing to approve with minimal changes required. Additionally, through our discussions within the pull request, we even stumbled upon a possible bug that I didn't know could happen in certain situations.
Overall, learning about pull requests and working with them on other repos as well as mine was great to experience as it was something I had not done before. It was interesting to make changes on another repo that had a different style of coding when compared to mine, and I realize that before making any further changes to an open source repo, thoroughly understanding the coding style and flow is vital. Looking forward to learning more throughout my Open Source journey!
That's it for now. See you in the next one.
Top comments (0)