My first code contribution
Tags: opensource, beginners, cli
Published: 2023-09-15 19:28:37

GitHub Repo: https://github.com/bhavik001/TxtToHTML

[Issue](https://github.com/bhavik001/TxtToHTML/issues/9) introduces a new functionality that enables the conversion from `.md` to `.html`. Initially, this was implemented manually instead of incorporating an existing open-source markdown parser, library, or framework, which will be utilized later in this project. Regex, `.replace` were mainly used in the manual conversion process between the two file formats, as demonstrated below:

```javascript
  const paragraphs = inputFileContent
      .replace(/^#\s(.+)$/gm, '<h1>$1</h1>') // heading 1
      .replace(/^##\s(.+)$/gm, '<h2>$1</h2>') // heading 2
      .replace(/^(?!<h[1-6]>|<ul>|<ol>|<li>|<a>).+$/gm, '<p>$&</p>') // paragraph
      .replace(/\[(.+?)\]\((.+?)\)/g, '<a href=$2">$1</a>') //  link
      .replace(/\*(.*?)\*/g, '<i>$1</i>') // italic
      .replace(/\*\*(.*?)\*\*/g, '<b>$1</b>') // bold
```
Current code supports the Markdown syntax features for Italics, Bold, Heading 1, Heading 2, and a Link.
Finally, `README.md` file was updated to include the newly implemented functionality.

**Process of getting my work accepted**

1. Filed an [Issue](https://github.com/bhavik001/TxtToHTML/issues/9).
2. Implemented the code.
3. Created a [pull request](https://github.com/bhavik001/TxtToHTML/pull/10).
4. Code reviewed by the author.
5. Code approved and merged by the author.

**Problem I had**

Understanding an unfamiliar codebase was challenging and occasionally complex. Ensuring that my contributions adhered to the existing style also presented its own set of challenges.

**Learning opportunity**

I encountered methods that I hadn't considered before, which can help me become a better programmer. Receiving feedback on my contributions has enabled me to learn from others' perspectives, leading to more robust and efficient coding practices. Contributing to others' code involved communication and collaboration with another developer. This experience has been invaluable for working in a team.

**What I would do differently next time?**

I would place greater emphasis on thoroughly documenting code changes, providing detailed explanations for the rationale behind specific decisions. Additionally, I would strictly adhere to the project's established coding standards and guidelines from the outset, aiming to minimize the need for revisions in the future.

**What was it like to receive a PR request from a contributor?**

It feels good when someone asks me if they can contribute to my work. I feel like it's not just me who is taking care of this project, and I need to ensure that this project is worth contributing to.

A contributor added an [issue](https://github.com/avelynhc/til_tracker/issues/9) stating that the `README.md` file does not mention the installation of `ts-node`. They pushed the [PR](https://github.com/avelynhc/til_tracker/pull/11), and there were a lot of interactions for such a small change. The entire conversation revolved around whether `ts-node` should be installed globally or not. I worried that I might write something silly and be laughed at. Additionally, I was concerned that I might be too nitpicky. However, the contributor was very open-minded and willing to consider my comments and suggestions. To be honest, it was kind of amazing to be able to discuss my project with other people, something I had never done before.