jenkins-bot has submitted this change and it was merged. (
https://gerrit.wikimedia.org/r/367807 )
Change subject: T119802: Fix parse of empty param in link in template param
......................................................................
T119802: Fix parse of empty param in link in template param
Change-Id: I475fc7d783da44408062b3fbd65c1e619dff30b4
---
M lib/wt2html/pegTokenizer.pegjs
M tests/parserTests.txt
2 files changed, 22 insertions(+), 23 deletions(-)
Approvals:
Subramanya Sastry: Looks good to me, approved
jenkins-bot: Verified
diff --git a/lib/wt2html/pegTokenizer.pegjs b/lib/wt2html/pegTokenizer.pegjs
index e58dc52..52ce22d 100644
--- a/lib/wt2html/pegTokenizer.pegjs
+++ b/lib/wt2html/pegTokenizer.pegjs
@@ -1297,32 +1297,23 @@
}
// Tables are allowed inside image captions.
-link_text_fragment
- = c:((sol full_table_in_link_caption)
+link_text
+ = & {
+ // Suppress the flag temporarily in this rule to consume the '=' here.
+ stops.push('equal', false);
+ return stops.push('linkdesc', true);
+ }
+ c:((sol full_table_in_link_caption)
/ urltext
/ (!inline_breaks
r:( inline_element / '[' text_char+ ']' $(&(!']' / ']]')) / . ) {
return r; }
)
)+ {
+ stops.pop('equal');
+ stops.pop('linkdesc');
return tu.flattenStringlist(c);
- }
-
-link_text
- = & { return stops.push('linkdesc', true); }
- h:link_text_fragment
- // 'equal' syntaxFlag is set for links in template parameters. Consume the
- // '=' here.
- hs:( '=' link_text_fragment )?
- {
- stops.pop('linkdesc');
- if (hs !== null) {
- return h.concat(hs);
- } else {
- return h;
- }
}
- / & { return stops.pop('linkdesc'); }
-
+ / & { stops.pop('equal'); return stops.pop('linkdesc'); }
/* Generic quote rule for italic and bold, further processed in a token
* stream transformation in doQuotes. Relies on NlTk tokens being emitted
diff --git a/tests/parserTests.txt b/tests/parserTests.txt
index c41b7e9..cfe6735 100644
--- a/tests/parserTests.txt
+++ b/tests/parserTests.txt
@@ -27072,7 +27072,7 @@
<p>123</p>
<figure class="mw-halign-right" typeof="mw:Image/Thumb"><a
href="./File:Foobar.jpg"><img resource="./File:Foobar.jpg"
src="//example.com/images/thumb/3/3a/Foobar.jpg/150px-Foobar.jpg"
data-file-width="1941" data-file-height="220" data-file-type="bitmap"
height="17" width="150"/></a></figure>
<p>456</p>
-!!end
+!! end
!! test
Image: New block level image should have \n before and after (existing content)
@@ -27084,7 +27084,7 @@
<p>123</p>
<figure class="mw-halign-right" typeof="mw:Image/Thumb"
data-parsoid='{"optList":[{"ck":"right","ak":"right"},{"ck":"thumbnail","ak":"thumb"},{"ck":"width","ak":"150x150px"}]}'><a
href="./File:Foobar.jpg"
data-parsoid='{"a":{"href":"./File:Foobar.jpg"}}'><img
resource="./File:Foobar.jpg"
src="//example.com/images/thumb/3/3a/Foobar.jpg/150px-Foobar.jpg"
data-file-width="1941" data-file-height="220" data-file-type="bitmap"
height="17" width="150"
data-parsoid='{"a":{"resource":"./File:Foobar.jpg","height":"17","width":"150"},"sa":{"resource":"File:Foobar.jpg"}}'/></a></figure>
<p>456</p>
-!!end
+!! end
!! test
Image: upright option (parsoid)
@@ -27096,7 +27096,7 @@
<figure class="mw-default-size" typeof="mw:Image/Thumb"><a
href="./File:Foobar.jpg"><img resource="./File:Foobar.jpg"
src="//example.com/images/thumb/3/3a/Foobar.jpg/170px-Foobar.jpg"
data-file-width="1941" data-file-height="220" data-file-type="bitmap"
height="19" width="170"/></a><figcaption>caption</figcaption></figure>
<figure class="mw-default-size" typeof="mw:Image/Thumb"><a
href="./File:Foobar.jpg"><img resource="./File:Foobar.jpg"
src="//example.com/images/thumb/3/3a/Foobar.jpg/110px-Foobar.jpg"
data-file-width="1941" data-file-height="220" data-file-type="bitmap"
height="12" width="110"/></a><figcaption>caption</figcaption></figure>
<figure typeof="mw:Image/Thumb"><a href="./File:Foobar.jpg"><img
resource="./File:Foobar.jpg"
src="//example.com/images/thumb/3/3a/Foobar.jpg/500px-Foobar.jpg"
data-file-width="1941" data-file-height="220" data-file-type="bitmap"
height="57" width="500"/></a><figcaption>caption</figcaption></figure>
-!!end
+!! end
!! test
Image: upright option is ignored on inline and frame images (parsoid)
@@ -27104,7 +27104,15 @@
[[File:Foobar.jpg|500x500px|upright=0.5|caption]]
!! html/parsoid
<p><span typeof="mw:Image" data-mw='{"caption":"caption"}'><a
href="./File:Foobar.jpg"><img resource="./File:Foobar.jpg"
src="//example.com/images/thumb/3/3a/Foobar.jpg/500px-Foobar.jpg"
data-file-width="1941" data-file-height="220" data-file-type="bitmap"
height="57" width="500"/></a></span></p>
-!!end
+!! end
+
+!! test
+Image: in template parameter with empty parameter
+!! wikitext
+{{echo|[[File:Foobar.jpg|link=]]}}
+!! html/parsoid
+<p><span class="mw-default-size" typeof="mw:Transclusion mw:Image"
about="#mwt1"
data-mw='{"parts":[{"template":{"target":{"wt":"echo","href":"./Template:Echo"},"params":{"1":{"wt":"[[File:Foobar.jpg|link=]]"}},"i":0}}]}'><span><img
resource="./File:Foobar.jpg" src="//example.com/images/3/3a/Foobar.jpg"
data-file-width="1941" data-file-height="220" data-file-type="bitmap"
height="220" width="1941"/></span></span></p>
+!! end
!! test
Image: from basic HTML (1)
--
To view, visit https://gerrit.wikimedia.org/r/367807
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: merged
Gerrit-Change-Id: I475fc7d783da44408062b3fbd65c1e619dff30b4
Gerrit-PatchSet: 2
Gerrit-Project: mediawiki/services/parsoid
Gerrit-Branch: master
Gerrit-Owner: Arlolra <[email protected]>
Gerrit-Reviewer: Arlolra <[email protected]>
Gerrit-Reviewer: C. Scott Ananian <[email protected]>
Gerrit-Reviewer: Subramanya Sastry <[email protected]>
Gerrit-Reviewer: jenkins-bot <>
_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits