DEV Community

Bhavik Mistry
Bhavik Mistry

Posted on

Enhancing TxtToHtml: Adding Inline Code Blocks, Fenced Code Blocks, and Horizontal Rules

Hello Everyone!
I'm thrilled to return with some exciting updates to my TxtToHtml command line tool. The project aims to enhance the rendering engine by adding two essential features:
1. Inline Code Blocks and Fenced Code Blocks:
Issue-11 requests the implementation of a feature that will allow text to be rendered as <code>text...</code> by surrounding it in a single backtick. Additionally, it requests assistance with fenced code blocks by looking for triple backticks and enclosing the content in <pre><code>...</code></pre> tags are used.
2. Horizontal Rules
Issue-12 introduces support for horizontal rules in the Markdown rendering process. When users add --- in their Markdown, it should be converted to an <hr> tag in the HTML output.

The Process
Step 1: Creating Parallel Branches
I made two parallel branches, one for Issue-11 and one for Issue-12, to start working on those issues. This guarantees that every feature may be developed separately from the others without interfering.

  • Creating Branch for Issue 11: git checkout -b issue-11
  • Creating Branch for Issue 12: git checkout -b issue-12

Step 2: Making Changes
In the respective branches, I made the following changes:

  1. Branch issue-11: I implemented support for inline <code> blocks and fenced code blocks as described in the issue. The relevant code changes can be found in the merge commit: issue-11 merge commit.
  2. Branch issue-12: I added the functionality to convert --- in Markdown to an <hr> tag in the rendered HTML. The code changes for this feature can be found in the merge commit: issue-12 merge commit.

Step 3: Merging Changes
Once the changes were implemented and tested in their respective branches, it was time to merge them into the main project. Merging ensures that the new features are incorporated into the project's main repository.

  • This is the merging commit for issue-11.
  • This is the merging commit for issue-12.

Challenges
Working on parallel branches was a seamless process for the most part. However, we did encounter a few challenges:

  • Testing: Ensuring that both features worked as expected independently and together was crucial. I learned the importance of thorough testing to catch any regressions.
  • In issue-11, I encountered a problem with a fenced code block. Initially, when I added the logic to the code, it only implemented the inline code block. However, it started working correctly when I included the <pre> element later on.

What I have learned?
During this lab, I gained valuable insights into parallel branching, branch merging, and a distinct approach to integrating final code after feature implementation.

Top comments (0)