From Wikipedia, the free encyclopedia
模板:High-use 模板:Lua sidebar
Sṳ́-yung Lua chhàng-sit: |
This template uses TemplateStyles: |
本文檔係模板:Routemap嘅Wikipedia:模板文檔子頁面 (見頁自身)。 本頁包含用法信息、分類撈其他非原頁面嘅內容。 |
This Lua-based template replaces the older parser-function-based {{BS-map}} (and deprecated {{Railway line header}}, {{BS-header}} and {{BS-table}}) templates for Wikipedia:Route diagram templates because diagrams created by {{Routemap}} load faster.
{{{title}}} | ||||||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
{{{top}}} | ||||||||||||||||||||||||||||
| ||||||||||||||||||||||||||||
{{{footnote}}} |
{{Routemap |navbar = |navbar pos = |navbar mini = |title = |title color = |title bg = |bg = |inline = |collapsible = |collapse = |legend = |legend alt = |float = |style = |top = |footnote = |text-width = |map = }}
The markup for composing the diagram in the |map=
parameter is different to the {{BSrow}}-based templates. The major differences are the separators in each row. Subtemplates are not necessary, since a new row in the table is simply created by a carriage return (newline).
<span style="color:blue">{{Routemap <var style="font-family:sans-serif;color:#252525"><small>Add other parameters like <code class="nowrap" >|title=</code> here.</small></var> |map= <var style="font-family:sans-serif;color:#252525"><small>Map markup goes here!</small></var> }}</span>
Example 1.1 | |||||||||||||||||||||||||||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
<span style="color:blue"><var><span class="tmpl-color" style="color:#252525;">icon ID</span></var>\<var><span class="tmpl-color" style="color:#252525;">icon ID</span></var>\<var><span class="tmpl-color" style="color:#252525;">icon ID</span></var></span>
\
.<span style="color:blue"><var><span class="tmpl-color" style="color:#252525;">icon ID</span></var>\<var><span class="tmpl-color" style="color:#252525;">icon ID</span></var>\<var><span class="tmpl-color" style="color:#252525;">icon ID</span></var>~~<var><span class="tmpl-color" style="color:#252525;">dist./time</span></var>~~<var><span class="tmpl-color" style="color:#252525;">main text</span></var>~~<var><span class="tmpl-color" style="color:#252525;">remark</span></var>~~<var><span class="tmpl-color" style="color:#252525;">right remark</span></var></span>
or
<span style="color:blue"><var><span class="tmpl-color" style="color:#252525;">icon ID</span></var>\<var><span class="tmpl-color" style="color:#252525;">icon ID</span></var>\<var><span class="tmpl-color" style="color:#252525;">icon ID</span></var>~~<var><span class="tmpl-color" style="color:#252525;">main text</span></var></span>
{{Routemap |title=Example 1.2 |map= KBHFa~~terminus WASSERq\hKRZWae\WASSERq~~ ~~ ~~ ~~Bridge LDER\INT\~~1 km~~station~~transfer for HSR \KBHFe\BUS~~2 km~~terminus~~bus terminal }} |
|
~~
), the following text will be displayed in the main text cell instead of dist./time.<span style="color:blue">*<var><span class="tmpl-color" style="color:#252525;">text</span></var>\d*<var><span class="tmpl-color" style="color:#252525;">text</span></var>\cd*<var><span class="tmpl-color" style="color:#252525;">text</span></var>~~<var><span class="tmpl-color" style="color:#252525;">main text</span></var></span>
{{Routemap
|title=Example 1.3
|map=
ENDEa~~ ~~ ~~Reversing siding
SPLa
cPLT\vSTR\cPLT~~Station
d*1\cPLT\vSTR\cPLT\d*2~~ ~~ ~~Platform numbers
cPLT\vSTR\cPLT
vCONTfge~~ ~~ ~~''to City''
}}
|
|
The asterisk indicating a text cell can be preceded by one of the BSicons' width prefixes. (Normal BSicons are square.)
Letters | o | c | d | cd | none | b | s | bs | w |
---|---|---|---|---|---|---|---|---|---|
Width | 1⁄8 | 1⁄4 | 1⁄2 | 3⁄4 | 1 | 2 | 4 | 6 | 8 |
{{Routemap
|title=Example 2.1
|map=
-colspan-1
Icon overlay
uSTRq!~STR2!~BHF!~lHUB\\dSTR!~uSTRq\dSTR!~dNULf
-colspan-2-style=border-bottom:5px solid red;
----
icon link
utBHF!@Superhub
-colspan
----
background color
-colspan-end
utSTR~~ ~~ ~~ ~~ ~~bg=#7af
}}
|
|
!~
) must follow the icon ID which is to be overlaid.!@
) must follow the last (top) overlaying icon ID.bg=
) requires 5 sets of preceding text separators to be recognizable even if there is no text on that row whatsoever.Example 2.2 | |||||||||||||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
Aside from bg=
, there are several other parameters, separated by commas (,
), which can be used to customize the display of a row. Only bg=
can be used to change the display of icons; all others only affect text cells.
Row parameters | ||
---|---|---|
Parameter name | Values | Result |
bg= , background= or bgcolor= |
Any X11 color name, RGB hex triplet or other valid values of the CSS background property | Row background is colored |
color= or colour= |
Any X11 color name or RGB hex triplet | Text cells in a row are colored |
b= or bold= |
1 , yes , y or true |
Text cells in a row are emboldened |
i= , it= or italic= |
1 , yes , y or true |
Text cells in a row are italicized |
align= |
No or invalid value | Text in cells is centered horizontally and vertically |
l or left |
Text in cells is aligned to the left | |
r or right |
Text in cells is aligned to the right | |
a , t or top |
Text in cells is aligned to the top | |
e , b or bottom |
Text in cells is aligned to the bottom | |
la , tl , c4 , nw , top-left or topleft |
Text in cells is aligned to the top-left corner | |
ra , tr , c1 , ne , top-right or topright |
Text in cells is aligned to the top-right corner | |
le , bl , c3 , sw , bottom-left or bottomleft |
Text in cells is aligned to the bottom-left corner | |
re , br , c2 , se , bottom-right or bottomright |
Text in cells is aligned to the bottom-right corner | |
fontsize= |
No value | Text in cells is 10px high and is transformed to be narrower (example) |
info or main |
Text in cells is the same size as the large sidebar text (second column from center) | |
cmt or comment |
Text in cells is the same size as the small sidebar text (other columns) | |
Any valid values of the CSS font-size property | Text in cells is a different size (percentages are relative to the large sidebar text) |
<span style="color:blue"><var><span class="tmpl-color" style="color:#252525;">icon</span></var>!_bg=<span style="background:purple;border-radius:0.15em;color:white">purple</span>\*<var><span class="tmpl-color" style="color:#252525;">text</span></var>__align=l!~*<var><span class="tmpl-color" style="color:#252525;">more text</span></var>__align=r,b='''yes'''</span>
BHF
, *Text
) are preceded by two underscores (__
).!_
). This must follow the link (if any).align=
, bg=
and color=
will override the row parameter values.Icon, text box and overlay stack parameters | ||||
---|---|---|---|---|
Parameter name | Values | Result | ||
bg= , background= or bgcolor= |
Any X11 color name, RGB hex triplet or other valid values of the CSS background property | Background is colored This should not be used with overlays above icons. | ||
color= or colour= |
Any X11 color name or RGB hex triplet | All the text of a cell, or the text of an individual text box, is colored | ||
b= or bold= |
1 , yes , y or true |
Boldfaced text | ||
i= , it= or italic= |
1 , yes , y or true |
Italicized text | ||
align= |
No or invalid value | Text is aligned per parameters of its parent (default: centered vertically and horizontally) | ||
l or left |
Text is aligned to… (vertical / horizontal) "Inherit" indicates that the cell will inherit its parent's value for that axis. |
inherit | left | |
r or right |
inherit | right | ||
a , t or top |
top | inherit | ||
e , b or bottom |
bottom | inherit | ||
la , tl , c4 , nw , top-left or topleft |
top | left | ||
ra , tr , c1 , ne , top-right or topright |
top | right | ||
le , bl , c3 , sw , bottom-left or bottomleft |
bottom | left | ||
re , br , c2 , se , bottom-right or bottomright |
bottom | right | ||
c , center or centre |
inherit | center | ||
m or middle |
middle | inherit | ||
ma , tc , top-center , top-centre , topcenter or topcentre |
top | center | ||
me , bc , bottom-center , bottom-centre , bottomcenter or bottomcentre |
bottom | center | ||
lm , ml , middle-left or middleleft |
middle | left | ||
rm , mr , middle-right or middleright |
middle | right | ||
cm , mc , middle-center , middle-centre , middlecenter or middlecentre |
middle | center | ||
fontsize= |
No value | Text is 10px high and is transformed to be narrower (example) | ||
info or main |
Text is the same size as the large sidebar text (second column from center) | |||
cmt or comment |
Text is the same size as the small sidebar text (other columns) | |||
Any valid values of the CSS font-size property | Text is a different size (percentages are relative to the large sidebar text) | |||
abbr= |
Pretty much anything that doesn't mess up the MediaWiki markup | Text has dotted underline and a tooltip containing the text after abbr= This will not have any effect if used on an overlay stack. |
{{Routemap |title=Example 3.1: Basic collapsible |text-width=80 |map= -startCollapsible-collapsed \KBHFa\~~terminus hSTRa@g WASSERq\hKRZW\WASSERq~~ ~~ ~~ ~~bridge hSTRe@f -endCollapsible- LDER\INT\~~ ~~station~~transfer for HSR \KBHFe\BUS~~ ~~terminus~~bus terminal }} |
|
{{Routemap |title=Example 3.2:<br/>Mixed odd and even rows |tw=70 |map= -startCollapsible-collapsed d\KBHFa\d~~terminus hKRZWae~~ ~~ ~~bridge -endCollapsible- BS2+l\BS2+r~~junction }} |
|
|text-width=
(or |tw=
) parameter until there is no break.
{{Routemap |title=Example 4.1 |text-width=150 |map= KBHFa~~terminus -startCollapsible-collapsed-replace \LSTR\~~hidden section \hSTRa@g\ WASSERq\hKRZW\WASSERq~~ ~~ ~~viaduct hSTRe@f -endCollapsible- LDER\INT\~~ ~~station~~transfer for HSR \KBHFe\BUS~~ ~~terminus~~bus terminal }} |
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
{{Routemap |title=Example 4.2: Empty filler |text-width=150 |map= -startCollapsible-collapsed-replace exCONTg~~under construction leer exKBHFa~~future terminus exBHF~~future station -endCollapsible KBHFxa~~terminus KBHFe~~terminus }} |
|
leer
) as empty filler as in example 4.2.For larger and more complicated diagrams, it often helps to have a text sidebar on the left as well as the right.
<span style="color:blue"><var><span class="tmpl-color" style="color:#252525;">left-left remark</span></var>~~<var><span class="tmpl-color" style="color:#252525;">left remark</span></var>~~<var><span class="tmpl-color" style="color:#252525;">left main text</span></var>~~<var><span class="tmpl-color" style="color:#252525;">left dist./time</span></var>! !<var><span class="tmpl-color" style="color:#252525;">icon ID</span></var>~~<var><span class="tmpl-color" style="color:#252525;">right dist./time</span></var>~~<var><span class="tmpl-color" style="color:#252525;">right main text</span></var>~~<var><span class="tmpl-color" style="color:#252525;">right remark</span></var>~~<var><span class="tmpl-color" style="color:#252525;">right-right remark</span></var></span>
or
<span style="color:blue"><var><span class="tmpl-color" style="color:#252525;">left main text</span></var>! !<var><span class="tmpl-color" style="color:#252525;">icon ID</span></var>~~<var><span class="tmpl-color" style="color:#252525;">right main text</span></var></span>
{{Routemap |title=Example 5 |map= ~~km! !~~km~~ commuter terminus~~0! !uKBHFa\\KBHFa~~0~~regional terminus River Boris~~ ~~! !uhKRZWae\WASSERq\hKRZWae~~ ~~ ~~bridge transfer for HSR~~station~~1! !uINT\LDER\LSTR commuter terminus~~2! !uKBHFe\\KBHFe~~2~~regional terminus }} |
|
! !
) separating them from icon cells.~~
) separator to the left of "exclamation mark-space-exclamation mark", the text to the left of the separator will be displayed in the left main text cell.Code | Result | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
{{Routemap |title=Example 6.1: All text cells applied |text-width=,130,,,110, |map= ~~km! !\\~~km~~ -startCollapsible commuter terminus~~0{{0|00}}! !uKBHFa\leer\KBHFa~~{{0|00}}0~~regional terminus River Boris~~ ~~! !uhKRZWae\WASSERq\hKRZWae~~~~ ~~bridge -endCollapsible transfer for HSR~~station~~1! !uINT\LDER\LSTR commuter terminus~~2{{0|00}}! !uKBHFe\\KBHFe~~{{0|00}}2~~regional terminus }} |
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||
{{Routemap |title=Example 6.2: Only main text cell applied |style=width:380px |text-width=,120,,,120, |map= -startCollapsible commuter terminus! !uKBHFa\\KBHFa~~regional terminus River Boris! !uhKRZWae\WASSERq\hKRZWae~~bridge -endCollapsible station! !uINT\LDER\LSTR commuter terminus! !uKBHFe\\KBHFe~~regional terminus }} |
|
|text-width=
to eliminate the break:
right main text+right remark
right dist./time,right main text+right remark,right-right remark
Left-left remark,left remark+left main text,left dist./time,right dist./time,right main text+right remark,right-right remark
leer
) to correct the icon columns.Syntax | Purpose |
---|---|
\ | Icon separator |
!~ | Icon overlay |
!@ | Icon link |
!_ | Precedes icon stack formatting parameters |
__ | Precedes icon formatting parameters |
~~ | Text separator |
! ! | Separator between icons and left-column text |
key=value,... | Formatting parameters |
-startCollapsible | Start of collapsing section |
-endCollapsible | End of collapsing section |
-colspan | Start of non-diagram table cell |
-colspan-end | End of non-diagram table cell |
-colspan-n | Start of non-diagram table cell; next n lines of code are in that cell (n can be any positive whole number) |
Many contributors of the English Route Diagram Template project during the implementation of Routemap have conflicting opinions about the justification of replacing all maps of legacy BS row templates by the Lua-based Routemap. Opponents deem the map markups of Routemap to be too esoteric for editors unfamiliar with Routemap markup to modify. While proponents support a complete conversion for better performance. There is no consensus reached at the moment so any transition without massively updating the map appearance for reflecting service and/or structural change in reality should only be done with the following considerations:
All BS row templates have had substitutable counterparts created; hence conversion can be easily done by prepending subst:
and appending /safesubst
to every BS row template name in the map. For example, change {{BS2|STR|BHF|0|1|2|3|O1=uSTRq}}
in the map to {{subst:BS2/safesubst|STR|BHF|0|1|2|3|O1=uSTRq}}
, then publish changes; it will produce STR!~uSTRq\BHF~~0~~1~~2~~3
. The process can be sped up by using the "replace all" function of advanced edit tool or separate text editor such as Notepad or Notepad++, but the search rule for the BS row templates should ideally be a regular expression, like \{\{(BS\d*(\-2)?)\|
→ 模板:((subst:$1/safesubst|
, in order to avoid templates with similar names such as BSto and BSsplit in case they are present in the map.
"Column mode editing" can avoid the trouble of find and replace to add safesubst:
on all rows efficiently. This function is common in advanced text editors like Geany, Notepad++ and Sublime Text.
You can also use the "convertbs" function of Module:Routemap.
Copy and paste the following code to any edit area of this wiki, maybe the map page you are working on:
{{#invoke:Routemap|convertbs|<nowiki> </nowiki>}}
Then copy and paste the original BS-map or BS-table map code between the <nowiki>
tags (alternatively paste the invoke convertbs header before the original map code and the </nowiki>}}
ending after the map code) and show preview. It will generate the safesubst version and show the original versions (for comparison) of the map code. You copy the safesubst code from the preview area back to the edit area, and you should remove everything of #invoke:Routemap|convertbs
if the preview of the new code works properly.
On the English Wikipedia, the template {{subst:convertbs}} can be used as a shortcut:
{{subst:convertbs|1= }}
If it doesn't work, it's possible that you haven't copied some of the relevant code, such as table markup for BS-table diagrams, or that you've copied code which actually belongs to something else.
Example | ||||||||||||||||||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
{{#invoke:Routemap|convertbs|<nowiki> {{BS-map |title=Demonstration |map= {{BS|KBHFa|0 km|A station|Shuttle bus}} {{BS3|WASSERq|hKRZWae|WASSERq||||{{BSsplit|Suburb|Capital}}}} {{BS|KINTe|10 km|B station|City hub}} {{BS-colspan}} ---- Not to scale }} </nowiki>}} | ||||||||||||||||||||||||||||||||||||||||
Result | ||||||||||||||||||||||||||||||||||||||||
Safe substitution: {{Routemap |title=Demonstration |map= {{safesubst:BS/safesubst|KBHFa|0 km|A station|Shuttle bus}} {{safesubst:BS3/safesubst|WASSERq|hKRZWae|WASSERq||||{{BSsplit|Suburb|Capital}}}} {{safesubst:BS/safesubst|KINTe|10 km|B station|City hub}} -colspan-2 ---- Not to scale }} Original: {{BS-map |title=Demonstration |map= {{BS|KBHFa|0 km|A station|Shuttle bus}} {{BS3|WASSERq|hKRZWae|WASSERq||||{{BSsplit|Suburb|Capital}}}} {{BS|KINTe|10 km|B station|City hub}} {{BS-colspan}} ---- Not to scale }} | ||||||||||||||||||||||||||||||||||||||||
Copy safe substitution markup for actual usage | ||||||||||||||||||||||||||||||||||||||||
|
<includeonly>...</includeonly>
tags. Also {{{navbar pos}}} is helpful to locate the {{Navbar}} better.See the monthly error report for this template.
TemplateData for Routemap
參數 | 描述 | 類型 | 狀態 | |
---|---|---|---|---|
Inline state | inline | Remove title bar and border for transclusion in infobox | 字串 | 非必填 |
Table title | title | Official title of the system. Value «no» will remove the table title row, but this will also disable the table collapsible switch as well | 字串 | 非必填 |
Title font color | title color title-color | Color of the title's text; automatically black or white to contrast with the title background color. Only use colors that contrast well with the background color
| 字串 | 非必填 |
Title background color | title bg color title-bg | Background color of the title
| 字串 | 非必填 |
Collapsibility | collapsible | Whether the whole infobox is collapsible or not | 字串 | 非必填 |
Collapsing state | collapse collapsed | Collapsing state. Shown by default. Any value will make the table collapse by default | 字串 | 非必填 |
Template name for Navbar | navbar | This must exactly match the diagram template page name so the Navbar template will appear and link to the template page | 字串 | 非必填 |
Position of the Navbar | navbar pos | Position of the Navbar template. Float to left in the title bar by default; «1» for top-right corner of the map (just under the title bar); «2» for the middle bottom of the map | 字串 | 非必填 |
Small navbar | navbar mini | If the navbar is not in default position, then this changes whether the navbar displays as "V · T · E" (default for navbar pos 1; values: «1», «y», «yes», «true») or "This diagram: view · talk · edit" (default for navbar pos 2; values: «0», «n», «no», «false»). | 字串 | 非必填 |
Legend appearance | legend | Alias of the legend link. It can be «bus», «canal», «footpath» or «track». «0» or «no» for no legend at all
| 頁面名稱 | 非必填 |
Legend link text | legend alt | Different link name in place of «Legend» if desirable
| 字串 | 非必填 |
Floating state | float | Floating state of the whole box: «right» by default; optionally «left» or «none»
| 字串 | 非必填 |
Background color | bg | Background color of the whole map area
| 字串 | 非必填 |
CSS style values | style | Additional CSS style definition of the whole infobox | 字串 | 非必填 |
Top note | top on top | Space for optional note or infobox above the map | 字串 | 非必填 |
Bottom note | footnote bottom | Space for optional note or infobox below the map | 字串 | 非必填 |
Width of map text cell | text-width tw | Extend the width of the map text cell so the collapsible section within the map does not break | 字串 | 非必填 |
Map markups | map 1 | Map data which uses specific markup/separators to load icon image and arrange the text in the uniform style | 字串 | 必填 |
Seamless Wikipedia browsing. On steroids.
Every time you click a link to Wikipedia, Wiktionary or Wikiquote in your browser's search results, it will show the modern Wikiwand interface.
Wikiwand extension is a five stars, simple, with minimum permission required to keep your browsing private, safe and transparent.