Subramanya Sastry has uploaded a new change for review.

  https://gerrit.wikimedia.org/r/65858


Change subject: Serialize image-spans without hacking the span tag.
......................................................................

Serialize image-spans without hacking the span tag.

* The serializer code had a long-standing hack where the span node
  was modified by setting rel and href attributes on it so as to
  reuse the link-handler set on the a-tag.

* This hack then introduced artificial semantic errors in roundtrip
  tests on the href='' attribute set on the span (modification of DOM
  input to the serializer).  Try the following roundtrip test.

node roundtrip-test.js --prefix pl Mistrzostwa_Słowacji_w_Lekkoatletyce_2011

* This patch eliminates the hack and uses the handleImage function
  directly without setting attributes on the span.

* No change in parser test results, but eliminates false semantic
  error reports on the above page (and possibly other pages as well).

Change-Id: Icb94f8298328685c0f006a975308da47df2a0ebd
---
M js/lib/mediawiki.WikitextSerializer.js
1 file changed, 6 insertions(+), 9 deletions(-)


  git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/Parsoid 
refs/changes/58/65858/1

diff --git a/js/lib/mediawiki.WikitextSerializer.js 
b/js/lib/mediawiki.WikitextSerializer.js
index 8298168..99f8765 100644
--- a/js/lib/mediawiki.WikitextSerializer.js
+++ b/js/lib/mediawiki.WikitextSerializer.js
@@ -2318,6 +2318,11 @@
                        emitEndTag("''", node, state, cb);
                }
        },
+       imageSpan: {
+               handle: function(node, state, cb) {
+                       return state.serializer.handleImage(node, state, cb);
+               }
+       },
        a:  {
                handle: function(node, state, cb) {
                        return state.serializer.linkHandler(node, state, cb);
@@ -2689,15 +2694,7 @@
                }
        }
        if (nodeName === 'span' && nodeTypeOf === 'mw:Image') {
-               // Hack: forward this span to DOM-based link handler until the 
span
-               // handler is fully DOM-based.
-
-               // Fake regular link attributes
-               // Set rel in addition to typeof
-               node.setAttribute('rel', 'mw:Image');
-               // And set an empty href, so that
-               node.setAttribute('href', '');
-               return self.tagHandlers.a || null;
+               return self.tagHandlers.imageSpan;
        }
 
        if (dp.stx === 'html' ||

-- 
To view, visit https://gerrit.wikimedia.org/r/65858
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: Icb94f8298328685c0f006a975308da47df2a0ebd
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/Parsoid
Gerrit-Branch: master
Gerrit-Owner: Subramanya Sastry <[email protected]>

_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to