Markdown Previewer: text not displaying 'dangerouslySetInnerHTML' text?

Please see link to codepen below:
[Markdown Previewer (codepen.io)]:
https://codepen.io/bkabat35/pen/WNgQLPq?editors=1010

My markdown previewer is not displaying the proper H1 size, H2 size, etc.(and so on) for the test #5 requirements. I have included Babel, react 18.2, react-dom 18.2, markdown v.4.2.12 marked library and Prism 9000 - prism react renderer in the JS settings. I was following a codealong on youtube and everything was working up until this point then I encountered an issue after replacing >{content} with ‘dangerouslySetInnerHTML’ on JS(Babel) line 20 and 21 as shown in the codepen link. I also tried using marked.parse after ‘dangerouslySetInnerHTML={{__html: marked(content, {renderer, renderer})’ and the text rendered in the markdown preview remained the same as in the text editor. Why does the text entered(for example #Hello or ##Hello ) in the textarea not show the proper markdown in the previewer?

I just tested your codepen and it seems to be working for me. Entering #Hello produces the HTML <h1>Hello</h1> in the preview window.

Did you fix it after you posted this? Or are you asking about something else?

codepen_markdown_editor

Please see what I am referring to in the attached screen capture. I am not getting the markdown previewer to respond when I enter text preceded by a hashtag for instance.

Try putting a space between the hash and the word.

Thanks, it is working now. I should have checked the code along a little closer. The progammer did mention to include a space before either ## or #. I googled the github flavored markdown preview cheatsheet on github docs: GitHub - krman009/Github-Flavoured-Markdown: Github Flavoured Markdown Cheat Sheet

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