| This template uses Lua: |
This is a template to produce graphical mahjong tiles inline with text. It is intended to simplify making these diagrams considering the somewhat extreme number of images involved, and their less-than-friendly systematic names. If a reader selects some text including some tiles and copies to clipboard, the tiles will be represented with Unicode Mahjong Tiles.
Mahjong has many variants and this template is intended to be agnostic to them. You can specify your desired variant (see table). The tiles do have minor visual differences between variants, and some features are only enabled for certain variants.
Tile illustrations by User:Cangjie6.
Usage
[edit]This template is to be used inline. The first parameter specifies the variant and the second is the MPSZ notation of the tiles to be displayed.
Supported variants
[edit]| Variant | Example hand |
|---|---|
hk – Old Hong Kong mahjong (default)
|
{{mahjong|hk|456p 111s 789s 55z 66z-5z}} |
jp – Japanese mahjong
|
{{mahjong|jp|456p 111s 789s 55z 66z-5z}} |
us – American mahjong
|
{{mahjong|us|456p 111s 789s 55z 66z-5z}} |
MPSZ notation
[edit]In MPSZ, you put a list of numbers of a given suit followed by a letter that indicates which suit they are. These are m for kraks/man, p for dots/pin, and s for bams/sou. z is for unnumbered tiles. Here is an example:
45m 4555899p 88s 12z: 











If you don't want to show them in any sorted order, you don't have to do that. Here is the same example before it is sorted:
5p 4s 5p 8p 1z 5m 5p 4m 8s 9p 4p 9p 1z: 











If you are showing sorted tiles or sets, please group them together (e.g. 456p, not 4p 5p 6p).
The honors are notated as though they were a fourth suit, z, numbered 1 through 7. The winds are 1 to 4 (east, south, west, north) and the dragons are 5 to 7 (white, green, red).
1z:
east2z:
south3z:
west4z:
north5z:
white6z:
green7z:
red
Other tiles are typically not supported in MPSZ. This template has some non-standard extensions to deal with this. Bonus tiles are added under q. The seasons are 1 to 4 and the flowers are 5 to 8.
1q:
spring2q:
summer3q:
autumn4q:
winter5q:
plum blossom6q:
orchid7q:
chrysanthemum8q:
bamboo
Use X in place of a number for stolen kong (555Xp ![]()
![]()
![]()
) or any other situation where you need to show a flipped tile. Visually split off exposed sets, bonuses and the drawn tile from the rest of the hand by separating them with dashes (-) instead of spaces:
9m 67p 9s-456p-222Xp-5555z-8q: 










Custom extensions
[edit]Append @ to a number for the corresponding tile to be grayed out. You can use this to highlight an important part of a hand (like the part being discussed) apart from an irrelevant part (1@1@1@2233445@6@m 7@7@z-7@m ![]()
![]()
![]()
![]()
![]()
![]()
![]()
![]()
![]()
![]()
![]()
![]()
). Do not convey information solely through this tinting feature; assume that it will not work on older browsers and screen readers. Alternatively, to show an unspecified tile, use ? instead of a number (
).
Japanese mahjong
[edit]For Japanese mahjong, make sure you are using jp as the first parameter or the tiles won't display correctly. jp will enable the unusual tilted tiles in called groups, and recolor the tiles to Japanese standards.
To show red fives, use zero as the rank (0m 0p 0s ![]()
![]()
). Unfortunately, there is no indication that they are red if they are copied as text to the clipboard.
For called groups, add an apostrophe (') after the number to turn the tile sideways (7'77z ![]()
![]()
). For closed kan, use X in place of a number to show a concealed tile (X88Xp ![]()
![]()
![]()
). For added kan, add a quote (") after one number for it to appear as two stacked tiles (11"1m ![]()
![]()
). Remember to split off calls by separating them with dashes (-) instead of spaces:
679p 5z-222'm-66'6z-777"z: 








When using " on a red five, only one of the stacked tiles will be red (this is intentional). Do not use " on flowers or seasons as these tiles cannot form added kans. If you are using @ to gray out a rotated tile, this goes after ' or " (as in 3'@z
).
American mahjong
[edit]Use the variant us to use American colors for the tiles, and the illustrated dragons ![]()
.
To show jokers, use J instead of a number. You can put J in any group, regardless of suit (88Js ![]()
![]()
). If you have a group with only jokers, you do not need to specify a suit (JJJ ![]()
![]()
).
Big mode
[edit]Use big=yes for a large, illustrative size. This is for showing what individual tiles look like, or easily readable hands that are the object of discussion. Not for use inline.
{{mahjong|big=yes|19m 19p 19s 1234567z-4z}}
If you just show one big tile, that will be handled differently. The tile will be clickable like a normal image, and have an alt text about its appearance instead of type. This behavior is for introducing tiles in articles, like in tables with each type shown.
{{mahjong|big=yes|8p}}
Parameters
[edit]- 1
- The variant (one of
hk,jporus). If no valid code is provided, {{{1}}} will instead be used for the MPSZ data (which is {{{2}}} otherwise). - 2
- The list of tiles to display, in MPSZ format (with some modifications to support versions besides Japanese mahjong).
- big
- Set to
yesto enable big mode, for much larger tiles not intended for inline display.
Complete tile reference
[edit]| Complete tile reference | |||
|---|---|---|---|
hk
|
jp
|
us
| |
X
|
|||
?
|
|||
1m
|
|||
2m
|
|||
3m
|
|||
4m
|
|||
5m
|
|||
6m
|
|||
7m
|
|||
8m
|
|||
9m
|
|||
1p
|
|||
2p
|
|||
3p
|
|||
4p
|
|||
5p
|
|||
6p
|
|||
7p
|
|||
8p
|
|||
9p
|
|||
1s
|
|||
2s
|
|||
3s
|
|||
4s
|
|||
5s
|
|||
6s
|
|||
7s
|
|||
8s
|
|||
9s
|
|||
1z
|
|||
2z
|
|||
3z
|
|||
4z
|
|||
5z
|
|||
6z
|
|||
7z
|
|||
1q
|
|||
2q
|
|||
3q
|
|||
4q
|
|||
5q
|
|||
6q
|
|||
7q
|
|||
8q
|
|||
0m
|
N/a | N/a | |
0p
|
N/a | N/a | |
0s
|
N/a | N/a | |
J
|
N/a | N/a | |
Current issues
[edit]-
and
do not display correctly when turned sideways - The red fives (


) are indistinguishable from regular fives (

) on screen readers and to some types of colorblindness - The US dragons (

) are indistinguishable to some types of colorblindness - The non-standard
@notation looks very confusing and a better way to highlight tiles is needed