转换富文本以在HTML页面上显示正常 [英] Converting rich text to show normal on HTML page

查看:1259
本文介绍了转换富文本以在HTML页面上显示正常的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好



我使用羽毛笔以富文本形式保存了一个字符串。现在,当我从数据库中提取我的html字符串时,它没有像普通文本那样显示确切显示的内容。



这是数据库中保存的字符串:

<   H3   >  Hello <   / H3  > ; 



当我使用该字符串时,它仍显示为:

 <   H3  >  Hello <   / H3  > 

你好



我的尝试:



我在使用字符串之前尝试使用

 pre 

标签,但没有运气

解决方案

如果您有某种控制能够使用特定格式显示格式化文本,则必须以该格式传递文本。



虽然它是可能会从一种格式转换为另一种格式,某些特殊格式选项可能会丢失,并且显示通常不是绝对相同的。所以最好使用一个能够显示输入格式而不是转换的控件。



这意味着在你的情况下,最好使用一个HTML编辑控件显示存储在数据库中的HTML文本或将文本以RTF格式存储在数据库中。



如果不可能,则必须使用HTML到RTF转换器,反之亦然。


这实际上帮助了我 Angular ng -bind-html指令 [ ^

Hi Guys

I saved a string in a rich-text form using quill. Now when i pull my html string from the database it doesn't show like normal text it shows exactly what is saved.

This is the saved string from the database:

"<H3>Hello</H3>"


When I use that string it still shows as:

"<H3>Hello</H3>"

NOT "Hello"

What I have tried:

I tried using the

pre

tags before using the string but no luck

解决方案

If you have some kind of control which is able to show formatted text using a specific format, you have to pass the text in that format.

While it is possible to convert from one format to another, some special format options might get lost and the display is often not absolute identical. So it is always better to use a control that is able to show the input format rather than converting.

That means in your case that it is better to either use a HTML edit control to show the HTML text stored in the database or store the text in RTF format in the database.

If that is not possible you have to use an HTML to RTF converter or vice versa.


This actually helped me Angular ng-bind-html Directive[^]


这篇关于转换富文本以在HTML页面上显示正常的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆