• If you are citizen of an European Union member nation, you may not use this service unless you are at least 16 years old.

  • Files spread between Dropbox, Google Drive, Gmail, Slack, and more? Dokkio, a new product from the PBworks team, integrates and organizes them for you. Try it for free today.

View
 

XHTML Compliant Output

Page history last edited by Alexander 10 years, 10 months ago

What is the Problem?

NicEdit generates bad, non standards complient code that is different in every browser and breaks the editor if editing on a different browser then the one used to create the content.

 

Why is this an issue?

Style application and HTML clean up is the most complex challenge in writing a WYSIWYG and one that I never quite got too yet with nicEdit. There are 2 components for a fully XHTML compliant system:

  1. First we would need to implement all nicEdit buttons in a way that stops using the browser execCommand() behaviours and apply their styles directly on the selection/ranges. This solves the issues such as you were having applying commands to the different ways of applying the same style (<b>, <strong>, <span style="font-weight: bold">) for example and allows the editor to handle all 3 in its content rather then the default browser behavior which is not that flexible.
  2. Second nicEdit would do access time HTML cleanup (such as nicXHTML tries to do but is buggy for now) in order to handle other content that isn't applied via the editor controls (from pasting content for example).

 

What is available now?

For now the nicXHTML plugin is very experimental and does not solve this issue completely.  To try it out configure you download with nicXHTML and then add {xhtml : true} to your options.  There are many known issues with the implementation.

 

Another option that I have recommended which maybe work for some people is to use server side cleanup based strategies such as the PHP's tidy functions to clean the HTML produced by nicEdit. However, this solution wont be available for everyone, adds complexity, and is not ideal.

 

When can I expect this to be fixed?

There is alot of work to do on this, doing it correctly is a little more complex then just lifting another implementation like tinyMCE and throwing it into nicEdit. NicEdit is a side project I do have a fulltime job so don't have the few weeks free time this would take. But ill keep working away when I can and welcome any patches to fix nicXHTML as well as anyone implementing a new plugin that works better (ill include any 3ed party plugins in the downloader).

 

Example on how to use PHP's tidy to clean the code:

tidy_repair_string(

                         $_POST['body'],

                         array(

                                   'show-body-only' => true,

                                   'doctype' => '-//W3C//DTD XHTML 1.0 Transitional//EN',

                                   'output-xhtml' => true

                         )

);

Comments (0)

You don't have permission to comment on this page.