Redactor - How to implement stripTags API call?

329 views Asked by At

I want to strip all HTML tags except the <a> tag from redactor. I found this handy API call called stripTags but I don't know how to use it with my current code. Any ideas?

API

var html = this.clean.stripTags(html, '<a>');

JS

  $(function()
    {
      $('.text-editor-strip').redactor();
  });

Attempt

If the stripTag is anywhere in the function then it stops Redactor from initialising as below.

 $(function()
   {
     var html = this.clean.stripTags(html, '<a>');
     $('.text-editor-strip').redactor();
 });
1

There are 1 answers

1
Brett DeWoody On

There is a paragraphize setting you can turn off to eliminate the <p> tags. You can enable it when you initialize redactor:

$('#redactor').redactor({
  paragraphize: false
});

This will use <br/> tags in place of paragraphs tags.

Here's a demo.