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

Add initial support for Markdown #5

Merged
merged 6 commits into from
Sep 20, 2023
Merged

Conversation

seog-jun
Copy link
Contributor

Fixes #4

  • Added a new feature for the tool to be able to convert the MD file to .HTML, and mdParseToHtml() is added to paser.js and it is used to convert the content of .MD file to HTML tag line by line.
  • Updated README.md to show for the changes.

src/parser.js Outdated
Comment on lines 45 to 61
if (line.startsWith("# ")) {
var slicedLine = line.slice(2);
return `<h1>${slicedLine}</h1>`;
} else if (line.startsWith("## ")) {
var slicedLine = line.slice(3);
return `<h2>${slicedLine}</h2>`;
} else if (line.startsWith("### ")) {
var slicedLine = line.slice(3);
return `<h3>${slicedLine}</h3>`;
} else if (line.startsWith("_") && line.endsWith("_")) {
var slicedLine = line.slice(1);
slicedLine = slicedLine.slice(0, -1);
return `<i>${slicedLine}</i>`;
} else {
return `<p>${line}</p>`;
}
})
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would like you to refer from using var since it's outdated just use a let and declare it before the line 42.

Is there a way that you can change this part line 54 your are assuming that italics takes the entire line, could you implement it the way that would allow for something like this hello _italic_ hello. I think this regex would help(\*|_)(.*?)\1

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Used 'let' instead of 'var' variable and added regex to find lines in italics as you mentioned.

Please have a look and let me know if it's okay to merge. Thanks

@pbelokon
Copy link
Owner

Looks good

@pbelokon pbelokon merged commit df14809 into pbelokon:main Sep 20, 2023
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 this pull request may close these issues.

Add Markdown Functionality
2 participants