简体   繁体   English

django从textarea python中删除换行符

[英]django remove line break from textarea python

i have a text area tha is tinymce application that devolve the text introduce in html. 我有一个文本区域,tha是tinymce应用程序 ,它分解了在html中引入的文本。 so if i introduce this: I, this is an example. 所以如果我介绍这个:我,这是一个例子。 that i recive, <p> I, this is an example.</p> in my view i remove the html tags, and if the tag are " p " than replace for an \\n . 我会说<p> I, this is an example.</p>在我看来,我删除了html标签,并且如果标签为“ p ”,则替换为\\n result: I, this is an example.\\n but if i introduce this: 结果: I, this is an example.\\n但是如果我介绍这个:

I, 一世,

this is an example. 这是一个例子。

this return: 这个回报:

<p> I,</p>
<p>this is an example.</p>

result: 结果:

I,\n
this is an example.\n

I want to remove the line break, so the result are:I,\\n this is an example.\\n 我想删除换行符,所以结果是:I,\\ n这是一个示例。\\ n

I would recommend fixing the <p> tag issue on the client side, as you can configure tinymce not to use <p> tags at all: 我建议在客户端修复<p>标记问题,因为您可以配置tinymce根本不使用<p>标记:

tinyMCE.init({
        ...
        forced_root_block : false
});

http://www.tinymce.com/wiki.php/Configuration:forced_root_block http://www.tinymce.com/wiki.php/Configuration:forced_root_block

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM