CKEditor strips inline attributes

It feels like you’re using CKEditor 4.1+ that comes with Advanced Content Filter (ACF). If so, you need to specify config.allowedContent and configure it to get your things working. You may also be interested in config.extraAllowedContent. See this answer for more details.

Using PHP substr() and strip_tags() while retaining formatting and without breaking HTML

Not amazing, but works. function html_cut($text, $max_length) { $tags = array(); $result = “”; $is_open = false; $grab_open = false; $is_close = false; $in_double_quotes = false; $in_single_quotes = false; $tag = “”; $i = 0; $stripped = 0; $stripped_text = strip_tags($text); while ($i < strlen($text) && $stripped < strlen($stripped_text) && $stripped < $max_length) { $symbol … Read more

How to strip or escape html tags in Android

The solutions in the answer linked to by @sparkymat generally require either regex – which is an error-prone approach – or installing a third-party library such as jsoup or jericho. A better solution on Android devices is just to make use of the Html.fromHtml() function: public String stripHtml(String html) { if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.N) { … Read more