how to get replit markdown in python or django?
i just wanted to know how to get replit markdown in python or django. By that i mean, it should include the exact features of the replit markdown. Like code blocks for languages, bold, italics, and more.
well oldwizard's answer is right but theres a better method
import markdown2 # the new updated version my_content = "# whatever" my_html = markdown2.markdown(my_content) # you don't need to create a object print(my_html) # <h1>whatever</h1>
@ch1ck3n This works, but there's a problem. The problem is, anything I put in the
my_content section, comes out in one code block. This means If i group anything with code, it shows up all joined in as a code block. Here's an example
So as you see in the screenshot, i put the header
something, which is supposed to output:
but, in the screen shot, it gets grouped with the code
next, the bold is also supposed to be bold and separate from the code block. So please let me know if you need further explanation. If you don't, please let me know an alternate option, or how to fix this.
@ch1ck3n did you look at the screenshot closely?
Notice the grey background? Notice how the bold and the header is also in the background? In replit markdown, that doesn't happen. I want the
# something and
**bold** to be separate. Isn't that replit markdown? The code should be in the grey background, and the other elements should be separate. Shouldn't they?
Please let me know if you need further explanation.
@ch1ck3n no, no. You don't seem to be getting it. Please look at the image closely. Do you see the gray background all over?
Do you see all over
# something, the code and the
Does that seem correct? Does it look like the gray background should be all over? In replit markdown, gray background should only be in code blocks right? Like when you put `
But in this case, it's all over. That's incorrect. So could you fix that?
Please let me know if you need further explanation
@ch1ck3n i didn't say anything about making code blocks grayer or anything. Did you read my comments closely? alright, do you know replit markdown?
If you do, you would know, the gray background would only be on code blocks right? the gray will not be on anything else. Only on code blocks. The rest of them should be normal right? Without any background right? Like when you do bold, does it have a background? No. But if you look at mine, the background is not only on the code, but is also on everything else. Could you fix that? Or do you need further explaining?
@ch1ck3n that is the whole page, I'll make it bigger.
can you see it now? Please let me know if you can't. If you want, I'll also show you the code I'm using. Do you want that?
Please let me know if you need more explanation, or if you code, or screenshots or anything. Just ask if you need anything.
P.S: I won't be answering for a few hours after this comment, I'll answer after a few hours, I'm going to be AFK. So if you have an answer, you can comment now, but I'll respond later. we can discuss when I'm back after a few hours again.
Markdown is universal, meaning it's there in most websites that allow you to post things because markdown is literally turning a few symbols into html code that can be parsed by any browser. So the way you do that in Django is pretty simple as well.
When you run a Django app, you most likely render a template file containing the HTML code. All you have to do is convert markdown into HTML, and put render that HTML into the template file. You can do that using the markdown package. Install it into your file using the pip command and use it like this:
import markdown as md markdown_renderer = md.Markdown() # Create a markdown object. markdown_renderer.convert("*This text will be italicized* ") # .convert() will return HTML code like: # <p><em>This text will be italicized</em><p>
ALl you need to do down is to put this HTML code into the template. Hope I was helpful