Subramanya Sastry has uploaded a new change for review.
https://gerrit.wikimedia.org/r/70940
Change subject: DOMFragment tsr spans entire DOM -- use this info in DSR
calculations
......................................................................
DOMFragment tsr spans entire DOM -- use this info in DSR calculations
* "<gallery></gallery>" was not getting a valid DSR. In general,
this was because extensions were getting wrapped in mw:DOMFragment
type nodes with a tsr set to cover the entire extension wikitext
span. However, DSR computation didn't account for this and worked
under the assumption that the tsr only spanned the "opening tag".
Note that this limitation only affected DOMFragments that
had 2 wrapper nodes. Those with just 1 wrapper node were
unaffected by this bug.
* No change in parser test results.
* We probably need separate unit testing for dsr computations.
Change-Id: I372d6d40ca01c96ba5c5bd18d66c60f649f24065
---
M js/lib/mediawiki.DOMPostProcessor.js
1 file changed, 17 insertions(+), 9 deletions(-)
git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/Parsoid
refs/changes/40/70940/1
diff --git a/js/lib/mediawiki.DOMPostProcessor.js
b/js/lib/mediawiki.DOMPostProcessor.js
index dd534f3..7e76ef1 100644
--- a/js/lib/mediawiki.DOMPostProcessor.js
+++ b/js/lib/mediawiki.DOMPostProcessor.js
@@ -40,12 +40,14 @@
"html" : [0,0],
"head" : [0,0],
"p" : [0,0],
- "ol" : [0,0],
- "ul" : [0,0],
- "dl" : [0,0],
"meta" : [0,0],
"tbody" : [0,0],
"pre" : [1,0],
+ // For lists and list elements,
+ // also see computeListEltWidth
+ "ol" : [0,0],
+ "ul" : [0,0],
+ "dl" : [0,0],
"li" : [1,0],
"dt" : [1,0],
"dd" : [1,0],
@@ -58,13 +60,14 @@
"hr" : [4,0],
"table" : [2,2],
"tr" : [2,0],
- "b" : [3,3],
- "i" : [2,2],
"td" : [null,0],
"th" : [null,0],
+ "b" : [3,3],
+ "i" : [2,2],
"br" : [0,0],
"figure": [2,2]
- // span, figure, caption, figcaption, br, a, i, b
+ // a-tag width computed by computeATagWidth
+ // what about span, figure, caption, figcaption?
};
/* ------------- utility functions on DOM nodes/Node attributes ------------ */
@@ -1922,13 +1925,18 @@
};
function tsrSpansTagDOM(n, parsoidData) {
+ // DOMFragment tsr spans their DOM
+ //
+ // For other nodes, if none of the following is true:
// - tags known to have tag-specific tsr
// - html tags with 'stx' set
// - span tags with 'mw:Nowiki' type
- var name = n.nodeName.toLowerCase();
- return !WT_tagsWithLimitedTSR[name] &&
+
+ var type = n.getAttribute("typeof");
+ return /mw:DOMFragment/.test(type) || (
+ !WT_tagsWithLimitedTSR[n.nodeName.toLowerCase()] &&
!DU.hasLiteralHTMLMarker(parsoidData) &&
- !DU.isNodeOfType(n, 'span', 'mw:Nowiki');
+ !(n.nodeName === 'SPAN' && type === 'mw:Nowiki'));
}
function computeListEltWidth(li, nodeName) {
--
To view, visit https://gerrit.wikimedia.org/r/70940
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: newchange
Gerrit-Change-Id: I372d6d40ca01c96ba5c5bd18d66c60f649f24065
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