Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cleaning up Code in HtmlProcessor.cs #9

Closed
Pasqua101 opened this issue Sep 22, 2023 · 1 comment · Fixed by #12
Closed

Cleaning up Code in HtmlProcessor.cs #9

Pasqua101 opened this issue Sep 22, 2023 · 1 comment · Fixed by #12

Comments

@Pasqua101
Copy link
Contributor

Some of the code from the ConvertMdToHtml function and from the ConvertTextToHtml function has been reused. Mainly the htmlBuilder code has been reused. I'd suggested cleaning it up by making a function to create the start of the HTML file.
For example:

public static StringBuilder HtmlCreator(title){
    StringBuilder startOfHtml = new();
    startOfHtml.AppendLine("<!DOCTYPE html>")
    // rest of the start of the html file below
    return startOfHtml;
}

This doesn't just help cleanup code but also makes modifying the start of the HTML file easier. Since you will only have to make the change in one place.

@Yousef-Majidi
Copy link
Owner

Yousef-Majidi commented Sep 26, 2023

Great suggestion. However, I went a slightly different route. The logic to build the HTML output is moved to a new function, and the processing logic for .txt and .md files have been broken off into their respective functions. These new functions return the body content of the HTML. So, now the input text content is processed based on the file extension and then passed down as an argument to the new function that build the HTML output.

closed by 9b83415

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants