| | 1 | <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> |
| | 2 | <html xmlns="http://www.w3.org/1999/xhtml"> |
| | 3 | <head> |
| | 4 | <title>CKEDITOR.htmlParser</title> |
| | 5 | <link rel="stylesheet" type="text/css" href="../../test.css" /> |
| | 6 | <script type="text/javascript" src="../../../../ckeditor_source.js"></script> <!-- %REMOVE_LINE% |
| | 7 | <script type="text/javascript" src="../../../ckeditor.js"></script> |
| | 8 | %REMOVE_LINE% --> |
| | 9 | <script type="text/javascript" src="../../test.js"></script> |
| | 10 | <script type="text/javascript"> |
| | 11 | //<![CDATA[ |
| | 12 | |
| | 13 | CKEDITOR.plugins.load( 'htmlwriter' ); |
| | 14 | |
| | 15 | CKEDITOR.test.addTestCase( ( function() |
| | 16 | { |
| | 17 | // Local reference to the "assert" object. |
| | 18 | var assert = YAHOO.util.Assert; |
| | 19 | |
| | 20 | /** |
| | 21 | * Wrapper of the combination of htmlParser with htmlWriter, for convenience of |
| | 22 | * testing, formatting of writer has been disabled. |
| | 23 | */ |
| | 24 | function htmlParse( htmlString , writerConfig) |
| | 25 | { |
| | 26 | var writer = new CKEDITOR.htmlWriter(); |
| | 27 | writer._.rules = []; |
| | 28 | if( writerConfig ) |
| | 29 | CKEDITOR.tools.extend( writer, writerConfig , true); |
| | 30 | writer.reset(); |
| | 31 | var fragment = CKEDITOR.htmlParser.fragment.fromHtml( htmlString ); |
| | 32 | fragment.writeHtml( writer ); |
| | 33 | return writer.getHtml(); |
| | 34 | } |
| | 35 | |
| | 36 | /** |
| | 37 | * IE always returning CRLF for line-feed, so remove it when retrieving |
| | 38 | * pre-formated text from text area. |
| | 39 | */ |
| | 40 | function getTextAreaValue( id ) |
| | 41 | { |
| | 42 | return CKEDITOR.document.getById( id ).getValue().replace( /\r/gi, '' ); |
| | 43 | } |
| | 44 | |
| | 45 | return { |
| | 46 | |
| | 47 | /** |
| | 48 | * Test element attributes abbreviation. |
| | 49 | */ |
| | 50 | test_fromHtml_9 : function() |
| | 51 | { |
| | 52 | assert.areSame( getTextAreaValue( 'htmlResult9' ), |
| | 53 | htmlParse( getTextAreaValue( 'htmlOriginal9' ) ), |
| | 54 | 'HTML parsing result doesn\'t match.' ); |
| | 55 | }, |
| | 56 | |
| | 57 | name :document.title |
| | 58 | }; |
| | 59 | } )() ); |
| | 60 | |
| | 61 | //]]> |
| | 62 | </script> |
| | 63 | </head> |
| | 64 | <body> |
| | 65 | |
| | 66 | <textarea id="htmlOriginal9"><input type="checkbox" checked autocomplete=off /></textarea> |
| | 67 | <textarea id="htmlResult9"><input autocomplete="off" checked="checked" type="checkbox" /></textarea> |
| | 68 | |
| | 69 | </body> |
| | 70 | </html> |