DEV Community

Avelyn Hyunjeong Choi
Avelyn Hyunjeong Choi

Posted on • Edited on

My first code contribution

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

Issue 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:

  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
Enter fullscreen mode Exit fullscreen mode

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.
  2. Implemented the code.
  3. Created a pull request.
  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 stating that the README.md file does not mention the installation of ts-node. They pushed the PR, 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.

Top comments (3)

Collapse
 
juanfrank77 profile image
Juan F Gonzalez

Claps

Collapse
 
sheikhelmoctar profile image
Sheikh El-Moctar

good 🙂❤️

Collapse
 
barrymichaeldoyle profile image
Barry Michael Doyle

Nice work! We need more people in the world to step up and make improvements like you've done here!