Index: trunk/extensions/VisualEditor/modules/parser/pegParser.pegjs.txt |
— | — | @@ -404,8 +404,9 @@ |
405 | 405 | / pre |
406 | 406 | / comment &eolf |
407 | 407 | / pre |
| 408 | + / bt:block_tag { return [bt] } // avoid a paragraph if we know that the line starts with a block tag |
408 | 409 | / para |
409 | | - / inline // includes generic tags; wrapped into paragraphs in DOM postprocessor |
| 410 | + / inlineline // includes generic tags; wrapped into paragraphs in DOM postprocessor |
410 | 411 | / (s:sol { |
411 | 412 | if (s) { |
412 | 413 | return [s, {type: 'NEWLINE'}]; |
— | — | @@ -416,8 +417,13 @@ |
417 | 418 | ) |
418 | 419 | |
419 | 420 | block_lines |
420 | | - = s:sol (space* newline)? |
421 | | - bl:block_line { return s.concat(bl); } |
| 421 | + = s:sol |
| 422 | + // eat an empty line before the block |
| 423 | + s2:(ss:space* so:sol { return [{type: 'TEXT', value: ss.join('')}].concat(so) })? |
| 424 | + bl:block_line { |
| 425 | + var s2_ = (s2 !== '') ? s2 : []; |
| 426 | + return s.concat(s2_, bl); |
| 427 | + } |
422 | 428 | |
423 | 429 | // Block structures with start-of-line wiki syntax |
424 | 430 | block_line |
— | — | @@ -426,7 +432,6 @@ |
427 | 433 | / lists |
428 | 434 | / pre_indent |
429 | 435 | / pre |
430 | | - / space* block_tag space* &eolf |
431 | 436 | |
432 | 437 | |
433 | 438 | /* Headings */ |
— | — | @@ -515,16 +520,6 @@ |
516 | 521 | return s1.concat(s2, [{type: 'TAG', name: 'p'}], c); |
517 | 522 | } |
518 | 523 | |
519 | | -para_line |
520 | | - = s:sol? c:inlineline { |
521 | | - var res = []; |
522 | | - if (s !== '') { |
523 | | - return s.concat(c); |
524 | | - } else { |
525 | | - return c; |
526 | | - } |
527 | | - } |
528 | | - |
529 | 524 | br = space* &newline { return {type: 'SELFCLOSINGTAG', name: 'br'} } |
530 | 525 | |
531 | 526 | pre_indent |
— | — | @@ -624,9 +619,9 @@ |
625 | 620 | = "[" target:url " " text:extlink_text "]" { |
626 | 621 | return [ { type: 'TAG', |
627 | 622 | name: 'a', |
628 | | - attribs: [['href', target]] } |
629 | | - , {type: 'TEXT', value: text} |
630 | | - , {type: 'ENDTAG', name: 'a'}]; |
| 623 | + attribs: [['href', target]] } ] |
| 624 | + .concat( text |
| 625 | + , [{type: 'ENDTAG', name: 'a'}]); |
631 | 626 | } |
632 | 627 | |
633 | 628 | // = "[" target:url text:extlink_text "]" { return { type: 'extlink', target: target, text: text } } |
— | — | @@ -635,7 +630,7 @@ |
636 | 631 | = proto:"http:" rest:([^ \]]+) { return proto + rest.join(''); } |
637 | 632 | |
638 | 633 | extlink_text |
639 | | - = c:[^\]]+ { return c.join(''); } |
| 634 | + = c:(inline_element / ch:[^\]] { return {type: 'TEXT', value: ch}; })+ |
640 | 635 | |
641 | 636 | template |
642 | 637 | = "{{" target:link_target params:("|" p:template_param { return p })* "}}" { |