There seems to be an inherited problem with redactor using the p tag as a default. I struggled to find a solution where I do need p tags and where inserted links were still getting wrapped in p tags.
Setting linebreaks to true and deniedTags results automatically setting "paragraphize" to false and also results in not getting any "br" tags (a bit of a hackish solution considering that there is a "paragraphize" property one can set to "false", doesn't always work (dark magic)).
But this results in my copy that needs to be wrapped in "p" tag not to be wrapped. Of course the editors have no clue what a "p" tag is so the magic of having a WSYWG editor became a horror.
So i opted to enforce a rule that the editors should use "formatting>normal text" from the toolbar. This resulted in a type error on line 902 redactor.js > Uncaught TypeError: Cannot read property 'toLowerCase' of undefined
. I scratched my head since this works for Headings and Quotes (Selected text would be wrapped by the heading type selected eg, h1 h2).
After debugging I found that on line 843 in Redactor if (this.opts.linebreaks || tag != 'p')
seems to be the culprit. Now not being the architect of the code changing this to if (this.opts.linebreaks || tag == 'p')
resulted in everything to work.
Now I can add custom p format with custom class and the selected text would be wrapped accordingly.
The magic = this.block.formatWrap(tag);
Now up to trying to make my inserted links not to be wrapped in a 'p' tag.
The above is a nasty hack and not full proof for future use since upgrading would override the change. I would like to challenge anybody to come up with a better solution.
<body>
tag). And either way, the image and caption were inside several nested block-level elements.