Index: trunk/extensions/VisualEditor/modules/parser/pegParser.pegjs.txt |
— | — | @@ -199,10 +199,15 @@ |
200 | 200 | var index = bolds[i]; |
201 | 201 | var txt = out[index - 1]; |
202 | 202 | txt.value += "'"; |
203 | | - bolds = bolds.slice(0, i) |
204 | | - .concat(bolds.slice(i + 1, bolds.length - i - 1)); |
| 203 | + if ( i > 0 ) { |
| 204 | + bolds = bolds.slice(0, i-1) |
| 205 | + .concat(bolds.slice(i + 1, bolds.length - i - 1)); |
| 206 | + } else { |
| 207 | + bolds.shift(); |
| 208 | + } |
| 209 | + |
205 | 210 | italics.push(index); |
206 | | - italics.sort(); |
| 211 | + italics.sort(function(a,b) { return a - b }); |
207 | 212 | }; |
208 | 213 | |
209 | 214 | // convert italics/bolds into tags |
— | — | @@ -295,12 +300,12 @@ |
296 | 301 | firstspace = j; |
297 | 302 | } else if (lastchar !== ' ') { |
298 | 303 | if ( secondtolastchar === ' ' && |
299 | | - firstsingleletterword === -1) { |
300 | | - firstsingleletterword = j; |
301 | | - } else if ( secondtolastchar && |
302 | | - secondtolastchar !== ' ') { |
303 | | - firstmultiletterword = j; |
304 | | - } |
| 304 | + firstsingleletterword === -1) |
| 305 | + { |
| 306 | + firstsingleletterword = j; |
| 307 | + } else if ( firstmultiletterword == -1) { |
| 308 | + firstmultiletterword = j; |
| 309 | + } |
305 | 310 | } |
306 | 311 | } |
307 | 312 | } |
— | — | @@ -475,7 +480,16 @@ |
476 | 481 | space |
477 | 482 | = s:[ \t]+ { return s.join(''); } |
478 | 483 | |
| 484 | +spaceTokenList |
| 485 | + = s:space* { |
| 486 | + if ( s.length ) { |
| 487 | + return [{type: 'TEXT', value: s.join('')}]; |
| 488 | + } else { |
| 489 | + return []; |
| 490 | + } |
| 491 | + } |
479 | 492 | |
| 493 | + |
480 | 494 | // Start of line |
481 | 495 | sol = (newline / & { return pos === 0; } { return true; }) |
482 | 496 | cn:(c:comment n:newline? { return [c, {type: 'TEXT', value: n}] })* { |
— | — | @@ -537,7 +551,11 @@ |
538 | 552 | / table |
539 | 553 | / lists |
540 | 554 | // tag-only lines should not trigger pre |
541 | | - / space* bt:block_tag space* &eolf { return bt } |
| 555 | + / st:spaceTokenList |
| 556 | + bt:(bts:block_tag stl:spaceTokenList { return bts.concat(stl) })+ |
| 557 | + &eolf { |
| 558 | + return st.concat(bt); |
| 559 | + } |
542 | 560 | / pre_indent |
543 | 561 | / pre |
544 | 562 | |
— | — | @@ -935,7 +953,7 @@ |
936 | 954 | } else { |
937 | 955 | res.type = 'TAG'; |
938 | 956 | } |
939 | | - return res; |
| 957 | + return [res]; |
940 | 958 | } |
941 | 959 | |
942 | 960 | /* Generic XML-like tags |
— | — | @@ -1127,7 +1145,7 @@ |
1128 | 1146 | ("||" / newline "|") |
1129 | 1147 | ! [}+-] |
1130 | 1148 | //& { dp('before attrib, pos=' + pos); return true; } |
1131 | | - a:(as:generic_attribute+ space* "|" !"|" { console.log('bla'); return as } )? |
| 1149 | + a:(as:generic_attribute+ space* "|" !"|" { return as } )? |
1132 | 1150 | //& { dp('past attrib, pos=' + pos); return true; } |
1133 | 1151 | // use inline_breaks to break on tr etc |
1134 | 1152 | td:(!inline_breaks |