开发者

Textarea without wysiwyg editor but have nice format

I have a textarea where someone can input text. I do not want a wysiwyg editor.

But what would be great:

Strip all tags, but make correct <p> and <br /> if user input has new lines. Additionally convert all urls, with or without http// or parameter to clickable links.

I cannot find a solution.

So you could type in开发者_运维百科to the textarea:

........
This is a paragraph
This ist still in the paragraph

this is a new paragraph www.this-would-be-clickable

new paragraphp `<strong>`this will be shown not bold`</strong>`
........

thankfull for every advice


Take a look at CKEditor. It may be more than what you need, but still very good. http://ckeditor.com/


Another more simplistic alternative is Wymeditor.

Seems to me that Markdown or Textile would get you a long way, though.

But if all you need is the newline/paragraph control and url to link, you could easily build it yourself with some regex.


I found a function inside a famous blog software..... plus this regex for links, the regex seems to work, but most probably there are better solution:

/((http(s?)://)|(www.))([^\s()[]<>]+|([^\s)])|[[^\s]]])+(?

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜