Index: trunk/extensions/VisualEditor/modules/parser/mediawiki.DOMConverter.js |
— | — | @@ -52,7 +52,7 @@ |
53 | 53 | } |
54 | 54 | return res; |
55 | 55 | case 'li': |
56 | | - case 'dl': |
| 56 | + case 'dt': |
57 | 57 | case 'dd': |
58 | 58 | return { |
59 | 59 | handler: this._convertHTMLBranch, |
— | — | @@ -63,6 +63,46 @@ |
64 | 64 | handler: this._convertHTMLLeaf, |
65 | 65 | type: 'pre' |
66 | 66 | }; |
| 67 | + case 'table': |
| 68 | + return { |
| 69 | + handler: this._convertHTMLBranch, |
| 70 | + type: 'table' |
| 71 | + }; |
| 72 | + case 'tbody': |
| 73 | + return { |
| 74 | + handler: this._convertHTMLBranch, |
| 75 | + type: 'tbody' // not in WikiDom! |
| 76 | + }; |
| 77 | + case 'tr': |
| 78 | + return { |
| 79 | + handler: this._convertHTMLBranch, |
| 80 | + type: 'tableRow' |
| 81 | + }; |
| 82 | + case 'th': |
| 83 | + return { |
| 84 | + handler: this._convertHTMLBranch, |
| 85 | + type: 'tableHeading' |
| 86 | + }; |
| 87 | + case 'td': |
| 88 | + return { |
| 89 | + handler: this._convertHTMLBranch, |
| 90 | + type: 'tableCell' |
| 91 | + }; |
| 92 | + case 'caption': |
| 93 | + return { |
| 94 | + handler: this._convertHTMLBranch, |
| 95 | + type: 'caption' |
| 96 | + }; |
| 97 | + case 'table': |
| 98 | + return { |
| 99 | + handler: this._convertHTMLBranch, |
| 100 | + type: 'table' |
| 101 | + }; |
| 102 | + case 'hr': |
| 103 | + return { |
| 104 | + handler: this._convertHTMLLeaf, |
| 105 | + type: 'horizontalRule' // XXX? |
| 106 | + }; |
67 | 107 | case 'ul': |
68 | 108 | case 'ol': |
69 | 109 | case 'dl': |
— | — | @@ -70,6 +110,20 @@ |
71 | 111 | handler: this._convertHTMLBranch, |
72 | 112 | type: 'list' |
73 | 113 | }; |
| 114 | + case 'center': |
| 115 | + //XXX: center is block-level in HTML, not sure what it should be |
| 116 | + //in WikiDOM.. |
| 117 | + return { |
| 118 | + handler: this._convertHTMLBranch, |
| 119 | + type: 'center' |
| 120 | + }; |
| 121 | + case 'blockquote': |
| 122 | + //XXX: blockquote is block-level in HTML, not sure what it should be |
| 123 | + //in WikiDOM.. |
| 124 | + return { |
| 125 | + handler: this._convertHTMLBranch, |
| 126 | + type: 'blockquote' |
| 127 | + }; |
74 | 128 | default: |
75 | 129 | console.log( 'HTML to Wiki DOM conversion error. Unsupported node name ' + |
76 | 130 | nodeName ); |
— | — | @@ -90,6 +144,12 @@ |
91 | 145 | return 'textStyle/span'; |
92 | 146 | case 'a': |
93 | 147 | return 'link/unknown'; // XXX: distinguish internal / external etc |
| 148 | + case 'template': |
| 149 | + return 'object/template'; |
| 150 | + case 'ref': |
| 151 | + return 'object/hook'; |
| 152 | + case 'includeonly': |
| 153 | + return 'object/includeonly'; // XXX |
94 | 154 | default: |
95 | 155 | if ( warn ) { |
96 | 156 | console.log( 'HTML to Wiki DOM conversion error. Unsupported html annotation ' + |
— | — | @@ -159,6 +219,7 @@ |
160 | 220 | var parNode = null; |
161 | 221 | |
162 | 222 | function newPara () { |
| 223 | + offset = 0; |
163 | 224 | parNode = { |
164 | 225 | type: 'paragraph', |
165 | 226 | content: { |
— | — | @@ -192,7 +253,7 @@ |
193 | 254 | parNode = null; |
194 | 255 | // Call a handler for the particular node type |
195 | 256 | var hi = this.getHTMLHandlerInfo( cnode.nodeName ); |
196 | | - var res = hi.handler.call(this, cnode, offset + 1, hi.type ); |
| 257 | + var res = hi.handler.call(this, cnode, 0, hi.type ); |
197 | 258 | if ( hi.attribs ) { |
198 | 259 | $.extend( res.node.attributes, hi.attribs ); |
199 | 260 | } |
— | — | @@ -230,6 +291,9 @@ |
231 | 292 | * @returns {Object} WikiDom object |
232 | 293 | */ |
233 | 294 | DOMConverter.prototype._convertHTMLLeaf = function ( node, offset, type ) { |
| 295 | + // XXX Does the offset in every leaf start at zero? |
| 296 | + offset = 0; |
| 297 | + |
234 | 298 | var children = node.childNodes, |
235 | 299 | wnode = { |
236 | 300 | type: type, |