DEV Community

Rachit Chawla
Rachit Chawla

Posted on

Collaborative Coding Adventure: Adding Markdown Support to a Python Tool

Introduction

As part of my journey in the OSD600 (Open Source Development) course, I embarked on a collaborative coding adventure that not only expanded my coding skills but also introduced me to the world of open-source contribution. In this blog post, I will share my experience of working with a fellow classmate to add Markdown support to a Python tool, the process of forking the repository, and the thrill of contributing to open source.

The Challenge: Markdown to HTML Conversion

Our task was to pair up with a classmate and choose a Python repository to contribute to by creating an issue and submitting a pull request. I was fortunate to team up with a fellow developer who had an interesting project: a Python tool that converted plain text files (txt) into HTML.

Getting Started

The first step was to fork my classmate's repository. Forking creates a personal copy of the original repository under my GitHub account. This allowed me to work on the project independently without affecting the original codebase.

Once I had my forked repository, I created an issue in which I proposed the idea of adding Markdown support. I outlined the benefits of this enhancement and the potential improvements it could bring to the tool. My classmate quickly accepted the proposal, and I was ready to dive into the code.

Link to the issue : https://github.com/mnajibi/tml/issues/7

The Implementation: Manual Markdown Parsing

My primary goal was to ensure that the tool could parse Markdown files and convert them into HTML seamlessly, all while adhering to the requirement of manual implementation without external libraries. Markdown is a lightweight markup language, and it uses '#' symbols to denote headers, with the number of '#' symbols indicating the header level (e.g., one '#' for h1, two '##' for h2, and three '###' for h3).

To meet this challenge, I meticulously analyzed each line of the Markdown input, manually detecting the presence of '#' symbols at the beginning of a line. By counting the number of '#' symbols, I was able to identify the header level. Subsequently, I transformed these Markdown headers into their corresponding HTML header tags (e.g., <h1>, <h2>, and <h3>). This manual implementation ensured that the tool remained free from external dependencies, emphasizing its self-contained nature and adherence to the project's requirements. The resulting code not only added Markdown header parsing functionality but also showcased the power of manual Markdown-to-HTML conversion, allowing users to create well-structured documents without relying on external libraries.

Pull Request and Collaboration

After implementing Markdown support, I submitted a pull request to my classmate's repository. A pull request (PR) is a way to propose changes to a repository and have them reviewed by the project owner. It was a moment filled with excitement and anticipation as I waited for the review.

To my delight, my PR was accepted without any additional changes required. It was a rewarding feeling to see my code become part of the project. In return, my classmate also created an issue for me to work on his repository, allowing us both to experience the collaborative nature of open source.

Link to the PR: PR8

Conclusion

My journey of adding Markdown support to a Python tool was an enriching experience. It taught me the importance of collaboration, communication, and the thrill of contributing to open source projects. I not only improved my coding skills but also learned how to work within an established codebase and interact with other developers.

Top comments (0)