Forem Creators and Builders 🌱

Discussion on: Api call "body_markdown" not displaying article with h1, h2... headers.

Collapse
 
s_aitchison profile image
Suzanne Aitchison

Nice work getting your API calls set up - looks like you're fetching the article markdown successfully 🎉

As you've spotted, the markdown is received from the API as a string. This means it will look like the raw content you enter on DEV, rather than the preview/published version (i.e. with all the markdown syntax like ## for headings).

To display it on your website like it appears on DEV, you'll need to add an extra step to turn the string markdown into HTML. There are a lot of markdown parsing libraries that can do this for you, but which one you should choose will depend on what framework or tools you're using in your website (and, of course, personal preference!).

If you're not sure which library to use, it might be a great idea to start a discussion on DEV with the #discuss tag to find out what other developers with a similar setup like to use!

Collapse
 
the_greatbonnie profile image
The Great Bonnie!

Just googled 'markdown parsing libraries for Django' and I found one called 'Markdownify Library'. I have converted the body markdown to HTML and the article appears just like on dev.to.

Am really grateful for your support.

Collapse
 
s_aitchison profile image
Suzanne Aitchison

That's awesome! You made short work of that 💪

Thread Thread
 
the_greatbonnie profile image
The Great Bonnie!

Actually, I have written an article on Dev To on how I did it.

Here is the link:

dev.to/the_greatbonnie/how-to-disp...

Thread Thread
 
coffeecraftcode profile image
Christina Gorton

Thank you for writing something up and sharing with everyone on DEV!