Is there a way to grab the markdown as text? #261
Unanswered
altinaaaaaaa
asked this question in
Q&A
Replies: 1 comment
-
Hello @altinaaaaaaa the official django already have strip tags, so you can use it to remove the html tags instead. from django.utils.html import strip_tags
html_string = '<strong>Hello</strong>, <p>world!</p>'
stripped_string = strip_tags(html_string)
print(stripped_string)
# Output: Hello, world! |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
In an older project I used markdownify to convert a markdown field into text, which I could then do pythonic things with. For instance in my
models.py
I didto get just the first 150 characters of the body which was written in markdown. Does django-markdown-editor have something like this?
I found that it does have
from martor.utils import markdownify
however, using that on aMartorField()
does NOT remove the html tags and return only the text. Is there a way to grab the contents of aMartorField()
stripped of all html formatting?Beta Was this translation helpful? Give feedback.
All reactions