DEV Community

Avelyn Hyunjeong Choi
Avelyn Hyunjeong Choi

Posted on

Hacktoberfest #03

Issue | PR

Issue
The issue revolved around converting a given markdown file to an HTML file using an external library and returning the HTML content as a string in the format { HTML: string } for further usage.

Set-up

  1. Clone the repo: https://github.com/avelynhc/intellectia.git
  2. Create a .env file
  3. Use Docker to set up database: docker compose up
  4. Server/Client set up: npm install in each directory

How does my code work?

export async function markdownToHTML(): Promise<{ HTML: string } | undefined> {
    try {
        const data: string = readFileFs.readFileSync('./assets/catOnTheMoon.md', 'utf8');
        const converter = new showdown.Converter();
        const result = converter.makeHtml(data);
        return { HTML: result };
    } catch(error: any) {
        console.error(error.message);
        return;
    }
}
Enter fullscreen mode Exit fullscreen mode

The conversion from Markdown to HTML was facilitated using the external library showdown.

Research
I had to research which library to use for the conversion. Among the options were markdown-it and showdown, among others. Since I was already familiar with the markdown-it library but not with showdown, I decided to use the showdown for the conversion.

Interesting interactions with the project maintainers
I pushed the pull request last night, hoping to receive comments and make some changes accordingly. When I woke up this morning, I found that he had left some comments but merged it into the main branch without me making any changes, which was a bit surprising. He mentioned in a comment that he accepted the pull request because the issues indicated in the comments were not mentioned in the DOC issue.

Learning opportunity
While working on this project, I had the opportunity to use a library for file conversion that I had never used before, which was quite an experience. This taught me that there are many libraries available to achieve the same purpose, so it's crucial for us to choose them wisely.

Top comments (0)