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

Added initial support for Markdown .md files #10

Merged
merged 5 commits into from Sep 25, 2021

Conversation

abatomunkuev
Copy link
Contributor

Closes #4

Added Markdown .md file support to the tool. What I have done:

  • Created a function markdownContent, that parses Markdown data and returns data converted to HTML code.
  • Function htmlContent: provided if statement check to determine the correct file extension for Markdown (.md) files. Once the Markdown (.md) file has been determined, the new function markdownContent will be called to process that file and populate a content for HTML.
  • Updated documentation for Markdown support feature.

To parse Markdown data, I have used a method from String JavaScript object - replace(). I have provided regular expressions to match the following Markdown syntax:

Markdown syntax HTML equivalent
Header 1 <h1>Test</h1>
Header 2 <h2>Test</h2>
Header 3 <h3>Test</h3>
Bold <b>Test</b>
Italic <i>Test</i>
Link <a href='URL'>Test</a>

For the testing purposes, I have created Markdown (.md) file with the following content:

# Testing Heading & Title 

## Testing Heading 2 
## Testing Heading 3

[Testing link](https://github.com/)
**testing bold text** Hello it's me can you hear me ? 
*testing italic text*

***testing both bold and italic text***

If you find any issues regarding the Markdown support, please inform me.

@RC-Lee
Copy link
Owner

RC-Lee commented Sep 24, 2021

Hi I've reviewed your code, just a simple issue.

The .md files won't parse correctly with italics in bold and bold in italics.

For example, in this md file below

# Silver Blaze


*I* am afraid, Watson, that **I *shall have* to** go,” said Holmes, as we
sat *down* together to our *breakfast **one** morning*.

**“Go! Where to?”**

The parsed html returns as

	<body><h1>Silver Blaze</h1>
<br />
<br />
<i>I* am afraid, Watson, that <b>I *shall have</i> to</b> go,” said Holmes, as we
sat <i>down* together to our *breakfast <b>one</b> morning</i>.
<br />
<b>“Go! Where to?”</b>

It misses a few of the '* marks

The extra break lines <br /> are also not needed.


One other small thing is if you could update the readme file to say that it works with .md files, and also how it parses it?

Much appreciated, thanks!

@RC-Lee
Copy link
Owner

RC-Lee commented Sep 25, 2021

Thanks for all the hard work.
I've tested it out and it seems to work as expected.

Thanks once again!

@RC-Lee RC-Lee merged commit 2d3ea93 into RC-Lee:main Sep 25, 2021
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 support.
2 participants