r92179 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r92178‎ | r92179 | r92180 >
Date:18:49, 14 July 2011
Author:tparscal
Status:deferred
Tags:
Comment:
Updated WikiDom libraries, demo and tests to use start/end instead of offset/length for ranges.
Modified paths:
  • /trunk/parsers/wikidom/demos/renderers/document.js (modified) (history)
  • /trunk/parsers/wikidom/lib/wiki.AnnotationRenderer.js (modified) (history)
  • /trunk/parsers/wikidom/lib/wiki.js (modified) (history)
  • /trunk/parsers/wikidom/tests/wikidom/wiki.test.js (modified) (history)

Diff [purge]

Index: trunk/parsers/wikidom/tests/wikidom/wiki.test.js
@@ -120,7 +120,7 @@
121121 'annotations': [
122122 {
123123 'type': 'ilink',
124 - 'range': { 'offset': 15, 'length': 4 },
 124+ 'range': { 'start': 15, 'end': 19 },
125125 'data': { 'namespace': 'Main', 'title': 'Main_Page' }
126126 }
127127 ]
@@ -163,8 +163,8 @@
164164 {
165165 'text': 'Line with bold and italic text',
166166 'annotations': [
167 - { 'type': 'bold', 'range': { 'offset': 10, 'length': 4 } },
168 - { 'type': 'italic', 'range': { 'offset': 19, 'length': 6 } }
 167+ { 'type': 'bold', 'range': { 'start': 10, 'end': 14 } },
 168+ { 'type': 'italic', 'range': { 'start': 19, 'end': 25 } }
169169 ]
170170 }
171171 ]
Index: trunk/parsers/wikidom/lib/wiki.AnnotationRenderer.js
@@ -16,8 +16,8 @@
1717 * Insertions for the same range will be nested in order of declaration.
1818 * @example
1919 * ar = new wiki.AnnotationRenderer();
20 - * ar.wrapWithText( { 'offset': 1, 'length': 1 }, '[', ']' );
21 - * ar.wrapWithText( { 'offset': 1, 'length': 1 }, '{', '}' );
 20+ * ar.wrapWithText( { 'start': 1, 'end': 2 }, '[', ']' );
 21+ * ar.wrapWithText( { 'start': 1, 'end': 2 }, '{', '}' );
2222 * // Outputs: "a[{b}]c"
2323 * console.log( ar.apply( 'abc' ) );
2424 *
@@ -26,17 +26,15 @@
2727 * @param post String: Text to insert after range
2828 */
2929 this.wrapWithText = function( range, pre, post ) {
30 - var start = range.offset;
31 - if ( !( start in insertions ) ) {
32 - insertions[start] = [pre];
 30+ if ( !( range.start in insertions ) ) {
 31+ insertions[range.start] = [pre];
3332 } else {
34 - insertions[start].push( pre );
 33+ insertions[range.start].push( pre );
3534 }
36 - var end = range.offset + range.length;
37 - if ( !( end in insertions ) ) {
38 - insertions[end] = [post];
 35+ if ( !( range.end in insertions ) ) {
 36+ insertions[range.end] = [post];
3937 } else {
40 - insertions[end].unshift( post );
 38+ insertions[range.end].unshift( post );
4139 }
4240 };
4341
Index: trunk/parsers/wikidom/lib/wiki.js
@@ -37,8 +37,8 @@
3838 * line: Line object
3939 * lists: Array of list objects
4040 * range
41 - * offset: Integer
42 - * length: Integer
 41+ * start: Integer
 42+ * end: Integer
4343 * annotation
4444 * type: String
4545 * range: Range object
Index: trunk/parsers/wikidom/demos/renderers/document.js
@@ -9,8 +9,8 @@
1010 {
1111 "type": "italic",
1212 "range": {
13 - "offset": 10,
14 - "length": 7
 13+ "start": 10,
 14+ "end": 17
1515 }
1616 }
1717 ]
@@ -83,15 +83,15 @@
8484 {
8585 "type": "italic",
8686 "range": {
87 - "offset": 0,
88 - "length": 4
 87+ "start": 0,
 88+ "end": 4
8989 }
9090 },
9191 {
9292 "type": "xlink",
9393 "range": {
94 - "offset": 8,
95 - "length": 6
 94+ "start": 8,
 95+ "end": 22
9696 },
9797 "data": {
9898 "url": "http://www.a.com"
@@ -100,8 +100,8 @@
101101 {
102102 "type": "bold",
103103 "range": {
104 - "offset": 10,
105 - "length": 4
 104+ "start": 10,
 105+ "end": 14
106106 }
107107 }
108108 ]
@@ -112,15 +112,15 @@
113113 {
114114 "type": "italic",
115115 "range": {
116 - "offset": 11,
117 - "length": 3
 116+ "start": 11,
 117+ "end": 14
118118 }
119119 },
120120 {
121121 "type": "bold",
122122 "range": {
123 - "offset": 20,
124 - "length": 4
 123+ "start": 20,
 124+ "end": 24
125125 }
126126 }
127127 ]
@@ -136,8 +136,8 @@
137137 {
138138 "type": "bold",
139139 "range": {
140 - "offset": 0,
141 - "length": 9
 140+ "start": 0,
 141+ "end": 9
142142 }
143143 }
144144 ]
@@ -183,8 +183,8 @@
184184 {
185185 "type": "italic",
186186 "range": {
187 - "offset": 0,
188 - "length": 6
 187+ "start": 0,
 188+ "end": 6
189189 }
190190 }
191191 ]
@@ -197,8 +197,8 @@
198198 {
199199 "type": "bold",
200200 "range": {
201 - "offset": 0,
202 - "length": 5
 201+ "start": 0,
 202+ "end": 5
203203 }
204204 }
205205 ]
@@ -211,8 +211,8 @@
212212 {
213213 "type": "ilink",
214214 "range": {
215 - "offset": 7,
216 - "length": 4
 215+ "start": 7,
 216+ "end": 12
217217 },
218218 "data": {
219219 "title": "User:JohnDoe"

Status & tagging log