Hi,
I am a beginner in JavaScript. I am looking to apply for a course and I have some questions to attempt. Similar questions will be asked during the assessment. Please can anyone help me solve this? I know what headers are but as I am learning through a programme I haven’t learnt about this yet. Also I don’t have a lot of time and would like to understand this and move on to the nest question.
QUESTION
Let’s write a simple markdown parser function that will take in a single line of markdown and be translated into the appropriate HTML. To keep it simple, we’ll support only one feature of markdown in atx syntax: headers.
Headers are designated by (1-6) hashes followed by a space, followed by text. The number of hashes determines the header level of the HTML output.
ADDITIONAL RUES:
Additional Rules
Header content should only come after the initial hashtag(s) plus a space character.
Invalid headers should just be returned as the markdown that was recieved, no translation necessary.
Spaces before and after both the header content and the hashtag(s) should be ignored in the resulting output.
This is what I was given to work on it:
let assert = require("chai").assert;
describe('Markdown Headers', function() {
it('basic_valid_cases', function() {
assert.deepEqual(markdownParser("# header"), "<h1>header</h1>");
assert.deepEqual(markdownParser("## smaller header"), "<h2>smaller header</h2>");
});
it('basic_invalid_cases', function() {
assert.deepEqual(markdownParser("#Invalid"), "#Invalid");
});
});