r104579 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r104578‎ | r104579 | r104580 >
Date:18:43, 29 November 2011
Author:gwicke
Status:deferred
Tags:
Comment:
Fix a few more tests by allowing inline content inside links. 76 now passing.
Modified paths:
  • /trunk/extensions/VisualEditor/modules/parser/pegParser.pegjs.txt (modified) (history)

Diff [purge]

Index: trunk/extensions/VisualEditor/modules/parser/pegParser.pegjs.txt
@@ -404,8 +404,9 @@
405405 / pre
406406 / comment &eolf
407407 / pre
 408+ / bt:block_tag { return [bt] } // avoid a paragraph if we know that the line starts with a block tag
408409 / para
409 - / inline // includes generic tags; wrapped into paragraphs in DOM postprocessor
 410+ / inlineline // includes generic tags; wrapped into paragraphs in DOM postprocessor
410411 / (s:sol {
411412 if (s) {
412413 return [s, {type: 'NEWLINE'}];
@@ -416,8 +417,13 @@
417418 )
418419
419420 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+ }
422428
423429 // Block structures with start-of-line wiki syntax
424430 block_line
@@ -426,7 +432,6 @@
427433 / lists
428434 / pre_indent
429435 / pre
430 - / space* block_tag space* &eolf
431436
432437
433438 /* Headings */
@@ -515,16 +520,6 @@
516521 return s1.concat(s2, [{type: 'TAG', name: 'p'}], c);
517522 }
518523
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 -
529524 br = space* &newline { return {type: 'SELFCLOSINGTAG', name: 'br'} }
530525
531526 pre_indent
@@ -624,9 +619,9 @@
625620 = "[" target:url " " text:extlink_text "]" {
626621 return [ { type: 'TAG',
627622 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'}]);
631626 }
632627
633628 // = "[" target:url text:extlink_text "]" { return { type: 'extlink', target: target, text: text } }
@@ -635,7 +630,7 @@
636631 = proto:"http:" rest:([^ \]]+) { return proto + rest.join(''); }
637632
638633 extlink_text
639 - = c:[^\]]+ { return c.join(''); }
 634+ = c:(inline_element / ch:[^\]] { return {type: 'TEXT', value: ch}; })+
640635
641636 template
642637 = "{{" target:link_target params:("|" p:template_param { return p })* "}}" {

Status & tagging log