Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
340 views
in Technique[技术] by (71.8m points)

python - Python将纯文本显示为html [重复](Python display plain text as html [duplicate])

I gotta do a notes app so I decided to use summernote and python flask for this.

(我得做一个笔记应用程序,所以我决定为此使用summernotepython flask 。)

I got a form where the user has to input the title and the content using a summernote textarea then the input is stored in the DB.

(我得到了一个表单,用户必须使用summernote文本区域输入标题和内容,然后将输入存储在DB中。)

The problem that I got is when I try to display the notes they come as plain text

(我遇到的问题是当我尝试将注释以纯文本形式显示时) 在此处输入图片说明

this is how I display them

(这就是我显示它们的方式)

            {% for foo in notes %}
                <div class="card">
                    <div class="card-header">
                        <div class="card-title">{{ foo.title }}</div>
                    </div>
                    <div class="card-body">
                        <div class="ribbon-wrapper ribbon-lg">
                        <div class="ribbon bg-primary">
                            <p>{{ foo.category_name }}</p>
                        </div>
                    </div>
                        {{ foo.content }}
                    </div>
                    <div class="card-footer">
                        <a href="#" class="btn btn-info btn-xs"><i class="fas fa-eye"></i></a>
                        <a href="#" class="btn btn-danger btn-xs"><i class="fas fa-trash"></i></a>
                    </div>
                </div>
            {% endfor %}

Is there any way that I could actually render the HTML content instead of displaying it as plain text?

(有什么方法可以实际呈现HTML内容,而不是将其显示为纯文本?)

  ask by Terchil? Marian translate from so

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...