Skip to content

Commit

Permalink
Remove mw:Placeholder from mw:DisplaySpace
Browse files Browse the repository at this point in the history
And the associated data-parsoid.src

Bug: T254502
Change-Id: I0e47a3ea97089ee7b511946b841252eababfe337
  • Loading branch information
arlolra authored and jenkins-bot committed Sep 18, 2020
1 parent b73f196 commit 275cb60
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 19 deletions.
4 changes: 2 additions & 2 deletions src/ParserTests/TestRunner.php
Expand Up @@ -496,7 +496,7 @@ private function generateChanges(
return !( $node instanceof DOMElement ) ||
( !WTUtils::isEncapsulationWrapper( $node ) &&
// Deleting these div wrappers is tantamount to removing the
!DOMUtils::matchTypeOf( $node, '#^mw:(Entity|Placeholder)(/|$)#' ) &&
!DOMUtils::matchTypeOf( $node, '#^mw:(Entity|Placeholder|DisplaySpace)(/|$)#' ) &&
// reference tag encaption wrappers, which results in errors.
!preg_match( '/\bmw-references-wrap\b/', $node->getAttribute( 'class' ) ?? '' )
);
Expand All @@ -520,7 +520,7 @@ private function generateChanges(
// is an uneditable image elt.
// - Entity spans are uneditable as well
// - Placeholder is defined to be uneditable in the spec
return DOMUtils::matchTypeOf( $node, '#^mw:(Image|Video|Audio|Entity|Placeholder)(/|$)#' ) || (
return DOMUtils::matchTypeOf( $node, '#^mw:(Image|Video|Audio|Entity|Placeholder|DisplaySpace)(/|$)#' ) || (
$node->nodeName !== 'figcaption' &&
$node->parentNode &&
$node->parentNode->nodeName !== 'body' &&
Expand Down
8 changes: 2 additions & 6 deletions src/Wt2Html/PP/Handlers/DisplaySpace.php
Expand Up @@ -79,12 +79,8 @@ private static function insertDisplaySpace(

$span = $doc->createElement( 'span' );
$span->appendChild( $doc->createTextNode( "\u{00A0}" ) );
// FIXME(T254502): Do away with the mw:Placeholder and the associated
// data-parsoid.src
$span->setAttribute( 'typeof', 'mw:DisplaySpace mw:Placeholder' );
DOMDataUtils::setDataParsoid( $span, (object)[
'src' => ' ', 'dsr' => $dsr,
] );
$span->setAttribute( 'typeof', 'mw:DisplaySpace' );
DOMDataUtils::setDataParsoid( $span, (object)[ 'dsr' => $dsr ] );
$node->parentNode->insertBefore( $span, $post );
}

Expand Down
4 changes: 2 additions & 2 deletions tests/parser/parserTests-knownFailures.json
Expand Up @@ -648,7 +648,7 @@
"html2wt": "; '''bold'''"
},
"Definition lists: ignore colons inside tags": {
"wt2html": "<dl data-parsoid='{\"dsr\":[0,38,0,0]}'><dt data-parsoid='{\"dsr\":[0,38,1,0]}'>one <b data-parsoid='{\"stx\":\"html\",\"dsr\":[5,34,3,4]}'>two<span typeof=\"mw:DisplaySpace mw:Placeholder\" data-parsoid='{\"src\":\" \",\"dsr\":[11,12,0,0]}'> </span>: tag <i data-parsoid='{\"stx\":\"html\",\"dsr\":[18,29,3,4]}'>fun:</i>:</b>:def</dt></dl>",
"wt2html": "<dl data-parsoid='{\"dsr\":[0,38,0,0]}'><dt data-parsoid='{\"dsr\":[0,38,1,0]}'>one <b data-parsoid='{\"stx\":\"html\",\"dsr\":[5,34,3,4]}'>two<span typeof=\"mw:DisplaySpace\" data-parsoid='{\"dsr\":[11,12,0,0]}'> </span>: tag <i data-parsoid='{\"stx\":\"html\",\"dsr\":[18,29,3,4]}'>fun:</i>:</b>:def</dt></dl>",
"wt2wt": ";one <b>two : tag <i>fun:</i>:</b><nowiki>:def</nowiki>",
"html2wt": "; one '''two : tag ''fun:'':'''\n: def",
"selser [[[3,[2,0,3,3,0],0]]]": ";<b>1uz6j1ntwo :</b>:def",
Expand Down Expand Up @@ -760,7 +760,7 @@
"html2wt": " <\n"
},
"Escaping of interlanguage links (T129218, T156308)": {
"wt2html": "<p data-parsoid='{\"dsr\":[0,51,0,0]}'>Blah blah blah\n<a rel=\"mw:WikiLink/Interwiki\" href=\"http://es.wikipedia.org/wiki/Spanish\" title=\"es:Spanish\" data-parsoid='{\"stx\":\"simple\",\"a\":{\"href\":\"http://es.wikipedia.org/wiki/Spanish\"},\"sa\":{\"href\":\":es:Spanish\"},\"isIW\":true,\"dsr\":[15,30,2,2]}'>es:Spanish</a>\n<a rel=\"mw:WikiLink\" href=\"./Zh_:_Chinese\" title=\"Zh : Chinese\" data-parsoid='{\"stx\":\"simple\",\"a\":{\"href\":\"./Zh_:_Chinese\"},\"sa\":{\"href\":\" : zh : Chinese \"},\"dsr\":[31,51,2,2]}' class=\"new\"> : zh<span typeof=\"mw:DisplaySpace mw:Placeholder\" data-parsoid='{\"src\":\" \",\"dsr\":[38,39,0,0]}'> </span>: Chinese </a></p>",
"wt2html": "<p data-parsoid='{\"dsr\":[0,51,0,0]}'>Blah blah blah\n<a rel=\"mw:WikiLink/Interwiki\" href=\"http://es.wikipedia.org/wiki/Spanish\" title=\"es:Spanish\" data-parsoid='{\"stx\":\"simple\",\"a\":{\"href\":\"http://es.wikipedia.org/wiki/Spanish\"},\"sa\":{\"href\":\":es:Spanish\"},\"isIW\":true,\"dsr\":[15,30,2,2]}'>es:Spanish</a>\n<a rel=\"mw:WikiLink\" href=\"./Zh_:_Chinese\" title=\"Zh : Chinese\" data-parsoid='{\"stx\":\"simple\",\"a\":{\"href\":\"./Zh_:_Chinese\"},\"sa\":{\"href\":\" : zh : Chinese \"},\"dsr\":[31,51,2,2]}' class=\"new\"> : zh<span typeof=\"mw:DisplaySpace\" data-parsoid='{\"dsr\":[38,39,0,0]}'> </span>: Chinese </a></p>",
"html2wt": "Blah blah blah\n[[:es:Spanish]]\n[[:zh:Chinese| zh : Chinese ]]"
},
"Expansion of multi-line templates in attribute values (T8255 sanity check 2)": {
Expand Down
18 changes: 9 additions & 9 deletions tests/parser/parserTests.txt
Expand Up @@ -3372,7 +3372,7 @@ Templates parameters with special tokenizing behavior dont get modified because
<p>a&#160;: b
</p>
!! html/parsoid
<p about="#mwt1" typeof="mw:Transclusion" data-mw='{"parts":[{"template":{"target":{"wt":"1x","href":"./Template:1x"},"params":{"1":{"wt":"a : b"}},"i":0}}]}'>a<span typeof="mw:DisplaySpace mw:Placeholder"> </span>: b</p>
<p about="#mwt1" typeof="mw:Transclusion" data-mw='{"parts":[{"template":{"target":{"wt":"1x","href":"./Template:1x"},"params":{"1":{"wt":"a : b"}},"i":0}}]}'>a<span typeof="mw:DisplaySpace"> </span>: b</p>
!! end

## T73412
Expand Down Expand Up @@ -9327,7 +9327,7 @@ Interwiki links that cannot be represented in wiki syntax
!! html/parsoid
<p><a rel="mw:WikiLink/Interwiki" href="http://www.usemod.com/cgi-bin/mb.pl?ok" title="meatball:ok">meatball:ok</a>
<a rel="mw:WikiLink/Interwiki" href="http://www.usemod.com/cgi-bin/mb.pl?ok#foo" title="meatball:ok">ok with fragment</a>
<a rel="mw:WikiLink/Interwiki" href="http://www.usemod.com/cgi-bin/mb.pl?ok_as_well%3F" title="meatball:ok as well?">ok ending with<span typeof="mw:DisplaySpace mw:Placeholder"> </span>? mark</a>
<a rel="mw:WikiLink/Interwiki" href="http://www.usemod.com/cgi-bin/mb.pl?ok_as_well%3F" title="meatball:ok as well?">ok ending with<span typeof="mw:DisplaySpace"> </span>? mark</a>
<a rel="mw:ExtLink" href="http://de.wikipedia.org/wiki/Foo?action=history" class="external text">has query</a>
<a rel="mw:ExtLink" href="http://de.wikipedia.org/wiki/#foo" class="external text">is just fragment</a></p>
!! end
Expand Down Expand Up @@ -9504,7 +9504,7 @@ Blah blah blah
!! html/parsoid
<p>Blah blah blah
<a rel="mw:WikiLink/Interwiki" href="http://es.wikipedia.org/wiki/Spanish" title="es:Spanish">es:Spanish</a>
<a rel="mw:WikiLink/Interwiki" href="http://zh.wikipedia.org/wiki/Chinese" title="zh:Chinese"> zh<span typeof="mw:DisplaySpace mw:Placeholder"> </span>: Chinese </a></p>
<a rel="mw:WikiLink/Interwiki" href="http://zh.wikipedia.org/wiki/Chinese" title="zh:Chinese"> zh<span typeof="mw:DisplaySpace"> </span>: Chinese </a></p>
!! end

!! test
Expand Down Expand Up @@ -20205,7 +20205,7 @@ C'est grave !
<p>C'est grave&#160;!
</p>
!! html/parsoid
<p>C'est grave<span typeof="mw:DisplaySpace mw:Placeholder"> </span>!</p>
<p>C'est grave<span typeof="mw:DisplaySpace"> </span>!</p>
!! end

!! test
Expand Down Expand Up @@ -25784,9 +25784,9 @@ Hello : this ; is « something ‹ else › again »
</p><p>Hello&#160;: this&#160;; is «&#160;something ‹&#160;else&#160;› again&#160;»
</p>
!! html/parsoid
<p>foo<span typeof="mw:DisplaySpace mw:Placeholder"> </span>! bar<span typeof="mw:DisplaySpace mw:Placeholder"> </span>? bat 50<span typeof="mw:DisplaySpace mw:Placeholder"> </span>% is less than 75<span typeof="mw:DisplaySpace mw:Placeholder"> </span>%.</p>
<p>foo<span typeof="mw:DisplaySpace"> </span>! bar<span typeof="mw:DisplaySpace"> </span>? bat 50<span typeof="mw:DisplaySpace"> </span>% is less than 75<span typeof="mw:DisplaySpace"> </span>%.</p>

<p>Hello<span typeof="mw:DisplaySpace mw:Placeholder"> </span>: this<span typeof="mw:DisplaySpace mw:Placeholder"> </span>; is «<span typeof="mw:DisplaySpace mw:Placeholder"> </span>something ‹<span typeof="mw:DisplaySpace mw:Placeholder"> </span>else<span typeof="mw:DisplaySpace mw:Placeholder"> </span>› again<span typeof="mw:DisplaySpace mw:Placeholder"> </span>»</p>
<p>Hello<span typeof="mw:DisplaySpace"> </span>: this<span typeof="mw:DisplaySpace"> </span>; is «<span typeof="mw:DisplaySpace"> </span>something ‹<span typeof="mw:DisplaySpace"> </span>else<span typeof="mw:DisplaySpace"> </span>› again<span typeof="mw:DisplaySpace"> </span>»</p>
!! end

!! test
Expand Down Expand Up @@ -30209,7 +30209,7 @@ parsoid=html2wt
!! html/parsoid
<p>foo<span typeof="mw:DisplaySpace"> </span>: bar</p>

<p>foo<span typeof="mw:DisplaySpace mw:Placeholder"> </span>: bar</p>
<p>foo<span typeof="mw:DisplaySpace"> </span>: bar</p>

<span typeof="mw:Extension/ref" data-mw="{&quot;name&quot;:&quot;ref&quot;,&quot;body&quot;:{&quot;html&quot;:&quot;foo<span typeof=\&quot;mw:DisplaySpace\&quot;>&amp;nbsp;</span>: bar&quot;}}"><sup>[1]</sup></span>ok</p>

Expand Down Expand Up @@ -32758,8 +32758,8 @@ wgFragmentMode=[ 'html5', 'legacy' ]

<h2 id="тест"><span id=".D1.82.D0.B5.D1.81.D1.82" typeof="mw:FallbackId"></span>тест</h2>

<h2 id="Hey_&lt;_#_&quot;_>_%_:_'"><span id="Hey_.3C_.23_.22_.3E_.25_:_.27" typeof="mw:FallbackId"></span>Hey &lt; # " ><span typeof="mw:DisplaySpace mw:Placeholder"> </span>%<span typeof="mw:DisplaySpace mw:Placeholder"> </span>: '</h2>
<p><a rel="mw:WikiLink" href="./Parser_test#Foo_bar">#Foo bar</a> <a rel="mw:WikiLink" href="./Parser_test#foo_Bar">#foo Bar</a> <a rel="mw:WikiLink" href="./Parser_test#Тест">#Тест</a> <a rel="mw:WikiLink" href="./Parser_test#тест">#тест</a> <a rel="mw:WikiLink" href="./Parser_test#Hey_&lt;_#_&quot;_>_%_:_'" data-parsoid='{"stx":"simple","a":{"href":"./Parser_test#Hey_&lt;_#_\"_>_%_:_&apos;"},"sa":{"href":"#Hey &lt; # \" > % : &apos;"}}'>#Hey &lt; # " ><span typeof="mw:DisplaySpace mw:Placeholder"> </span>%<span typeof="mw:DisplaySpace mw:Placeholder"> </span>: '</a></p>
<h2 id="Hey_&lt;_#_&quot;_>_%_:_'"><span id="Hey_.3C_.23_.22_.3E_.25_:_.27" typeof="mw:FallbackId"></span>Hey &lt; # " ><span typeof="mw:DisplaySpace"> </span>%<span typeof="mw:DisplaySpace"> </span>: '</h2>
<p><a rel="mw:WikiLink" href="./Parser_test#Foo_bar">#Foo bar</a> <a rel="mw:WikiLink" href="./Parser_test#foo_Bar">#foo Bar</a> <a rel="mw:WikiLink" href="./Parser_test#Тест">#Тест</a> <a rel="mw:WikiLink" href="./Parser_test#тест">#тест</a> <a rel="mw:WikiLink" href="./Parser_test#Hey_&lt;_#_&quot;_>_%_:_'" data-parsoid='{"stx":"simple","a":{"href":"./Parser_test#Hey_&lt;_#_\"_>_%_:_&apos;"},"sa":{"href":"#Hey &lt; # \" > % : &apos;"}}'>#Hey &lt; # " ><span typeof="mw:DisplaySpace"> </span>%<span typeof="mw:DisplaySpace"> </span>: '</a></p>

<p><span about="#mwt1" typeof="mw:Transclusion" data-mw='{"parts":[{"template":{"target":{"wt":"anchorencode:💩","function":"anchorencode"},"params":{},"i":0}}]}'>💩</span> <span id="💩" about="#mwt3" typeof="mw:ExpandedAttrs" data-mw='{"attribs":[[{"txt":"id"},{"html":"&lt;span about=\"#mwt2\" typeof=\"mw:Transclusion\" data-parsoid=&#39;{\"pi\":[[]],\"dsr\":[178,197,null,null]}&#39; data-mw=&#39;{\"parts\":[{\"template\":{\"target\":{\"wt\":\"anchorencode:💩\",\"function\":\"anchorencode\"},\"params\":{},\"i\":0}}]}&#39;>💩&lt;/span>"}]]}'></span></p>

Expand Down

0 comments on commit 275cb60

Please sign in to comment.