Page MenuHomePhabricator

Proposed spec for Parsoid's gallery implementation

Authored By
Arlolra
Jul 19 2016, 5:40 PM
Size
4 KB
Referenced Files
None
Subscribers
None

Proposed spec for Parsoid's gallery implementation

<!--
Working off: https://github.com/wikimedia/mediawiki/blob/master/includes/parser/Parser.php#L4855-L4867
Params to support (on the extension tag): showfilename, caption, mode, widths, heights, perrow
Content is explode by: \n
A line should match: "/^([^|]+)(\\|(.*))?$/"
If a '%' is found, rawurldecode?
Title is before the first | and needs a namespace: NS_FILE
TODO: Mainly the "mode"s, and their interaction with "widths", "heights", and "perrow".
-->
<gallery caption="Foo [[Main Page]]">
[[x|xx]]]]
File:Nonexistent.jpg|caption
Image:foobar.jpg|some '''caption''' [[Main Page]]
foobar.jpg
Image:foobar.jpg|Blabla|alt=This is a foo-bar.|blabla.
Image:foobar.jpg|link=Main_Page
</gallery>
<gallery showfilename="">
File:Foobar.jpg
Image:Foobar.jpg|some '''caption''' [[Main Page]]
</gallery>
<!-- Renders as -->
<ul typeof="mw:Extension/gallery" about="#mwt3" data-mw='{"name":"gallery","attrs":{},"body":{}}'>
<li class="gallerycaption">Foo <a rel="mw:WikiLink" href="./Main_Page" title="Main Page">Main Page</a></li>
<li class="gallerybox"><figure class="mw-default-size mw-halign-none" typeof="mw:Error mw:Image/Thumb" data-mw='{"errors":[{"key":"missing-image","message":"This image does not exist."}]}'><a href="./File:Nonexistent.jpg"><img resource="./File:Nonexistent.jpg" src="./Special:FilePath/Nonexistent.jpg" height="220" width="220"/></a><figcaption>caption</figcaption></figure></li>
<li class="gallerybox"><figure class="mw-default-size mw-halign-none" typeof="mw:Image/Thumb"><a href="./File:Foobar.jpg"><img resource="./File:Foobar.jpg" src="//example.com/images/thumb/3/3a/Foobar.jpg/220px-Foobar.jpg" data-file-width="1941" data-file-height="220" data-file-type="bitmap" height="25" width="220"/></a><figcaption>some <b>caption</b> <a rel="mw:WikiLink" href="./Main_Page" title="Main Page">Main Page</a></figcaption></figure></li>
<li class="gallerybox"><figure class="mw-default-size mw-halign-none" typeof="mw:Image/Thumb"><a href="./File:Foobar.jpg"><img resource="./File:Foobar.jpg" src="//example.com/images/thumb/3/3a/Foobar.jpg/220px-Foobar.jpg" data-file-width="1941" data-file-height="220" data-file-type="bitmap" height="25" width="220"/></a></figure></li>
<li class="gallerybox"><figure class="mw-default-size mw-halign-none" typeof="mw:Image/Thumb"><a href="./File:Foobar.jpg"><img alt="This is a foo-bar." resource="./File:Foobar.jpg" src="//example.com/images/thumb/3/3a/Foobar.jpg/220px-Foobar.jpg" data-file-width="1941" data-file-height="220" data-file-type="bitmap" height="25" width="220"/></a><figcaption>blabla.</figcaption></figure></li>
<li class="gallerybox"><figure class="mw-default-size mw-halign-none" typeof="mw:Image/Thumb"><a href="./Main_Page"><img resource="./File:Foobar.jpg" src="//example.com/images/thumb/3/3a/Foobar.jpg/220px-Foobar.jpg" data-file-width="1941" data-file-height="220" data-file-type="bitmap" height="25" width="220"/></a></figure></li>
</ul>
<ul typeof="mw:Extension/gallery" about="#mwt4" data-parsoid='{}' data-mw='{"name":"gallery","attrs":{"showfilename":""},"body":{}}'>
<li class="gallerybox"><figure class="mw-default-size mw-halign-none" typeof="mw:Image/Thumb"><a href="./File:Foobar.jpg"><img resource="./File:Foobar.jpg" src="//example.com/images/thumb/3/3a/Foobar.jpg/220px-Foobar.jpg" data-file-width="1941" data-file-height="220" data-file-type="bitmap" height="25" width="220"/></a><figcaption><a href="./File:Foobar.jpg" class="galleryfilename galleryfilename-truncate" title="File:Foobar.jpg">File:Foobar.jpg</a></figcaption></figure></li>
<li class="gallerybox"><figure class="mw-default-size mw-halign-none" typeof="mw:Image/Thumb"><a href="./File:Foobar.jpg"><img resource="./File:Foobar.jpg" src="//example.com/images/thumb/3/3a/Foobar.jpg/220px-Foobar.jpg" data-file-width="1941" data-file-height="220" data-file-type="bitmap" height="25" width="220"/></a><figcaption><a href="./File:Foobar.jpg" class="galleryfilename galleryfilename-truncate" title="File:Foobar.jpg">File:Foobar.jpg</a>some <b>caption</b> <a rel="mw:WikiLink" href="./Main_Page" title="Main Page">Main Page</a></figcaption></figure></li>
</ul>

File Metadata

Mime Type
text/plain; charset=utf-8
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
3876181
Default Alt Text
Proposed spec for Parsoid's gallery implementation (4 KB)

Event Timeline