DEV Community

Maryam
Maryam

Posted on

Journey through Open Source: Contributing to txtToWeb

I recently had the pleasure of contributing to an open source project called txtToWeb. It's a handy command-line tool that converts text files to HTML content. However, I noticed it could benefit from supporting the conversion of Markdown files and parsing italic syntax as well.

Identifying and Proposing a Feature

After closely examining the tool, I realized that the ability to convert Markdown files and specifically parse italic syntax was missing. With this in mind, I raised Issue #6 to propose the addition of this feature.

The maintainer was receptive to this idea, and after a fruitful discussion, I received the green light to start working on this enhancement.

Crafting the Change

To implement this, I forked the repository and got down to coding. The original version of txtToWeb did not have a function to handle the conversion of Markdown files to HTML, so I created a new function named md_to_html to add this feature.

I focused initially on supporting the italic syntax in Markdown. The key was to use a regular expression to substitute both _text_ and *text* with <i>text</i> in HTML.

# A snippet of the md_to_html function
content = re.sub(r"_([^_]*)_|\*([^\*]*)\*", r"<i>\1\2</i>", content)
Enter fullscreen mode Exit fullscreen mode

This code snippet was instrumental in implementing the feature and ensuring that the italic syntax in Markdown was correctly converted to HTML.

Submitting a Pull Request

After thoroughly testing the feature and making sure everything was working as expected, I documented the changes in the README and created a Pull Request linking it back to Issue #6.

The maintainer was prompt in reviewing the changes, and after a constructive feedback and subsequent modifications, the pull request was merged!

Reflections and Learning

This contribution experience was enlightening. It taught me the significance of understanding the existing architecture of a project before introducing new features. The review process was detailed and helped me refine my coding practices and adhere to the project's coding standards.

Receiving a Contribution

My repository also received a pull request around the same time. Reviewing someone else's code was a learning experience in itself. It was crucial to maintain open communication, provide clear and constructive feedback, and ensure that the contributor felt valued and the code aligned with the project's standards.

Conclusion

In conclusion, contributing to the txtToWeb project was a rewarding journey. It was a learning curve filled with challenges, accomplishments, and a lot of new knowledge. For anyone considering contributing to open-source projects, I would say – Go for it! It's a journey worth embarking on.

Top comments (0)