Build a Markdown Previewer: Parsing Default Markdown

I am working on building the Markdown previewer for the Front End Libraries certification. My project is working pretty well but the problem I am having is that my default markdown, which I have contained in the state as “exampleInput,” is not being parsed and is rendering to the DOM as plain markdown. I have included a link to my GitHub repository since I am working in VS Code.
GitHub

Hi there! Great job on the project so far.

It looks like the issue is with the way the exampleInput string is being created. Take a look at the textarea input and you’ll see there are a bunch of spaces at the start of each line. The extra spaces are preventing the markdown from being recognized.

Do you know what I could do to fix this? I tried splitting the exampleInput variable into an array of lines and using array.map() to trim the whitespace, but this only worked when the webpage initially loaded. Once the handleChange() method is called I am still experiencing the same problem.

In VS Code, put your cursor before the last backtick, hold down Shift + Alt (or use the middle mouse button), and drag up to the last line of markdown, now delete all the selected spaces. Save and it should work.

For the bonus test look at the lib options.

https://marked.js.org/using_advanced#options

1 Like

Thanks a lot that solved the problem.

This topic was automatically closed 182 days after the last reply. New replies are no longer allowed.