Bản mẫu:Routemap/doc

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:Bản mẫu sơ đồ tuyến because diagrams created by  load faster.

**Cách sử dụng**

**Đánh dấu cho tham số bản đồ**
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).

**Cơ bản**
 Icons are separated by the backslash \.- Each group of icons is centered in its row. The nameless icon (at the start of row 5 in the diagram) can be used as a spacer.- The ID of each icon can be seen in its tooltip. Move your cursor over the icons to see them.

**Văn bản thanh bên**
or- The third and fourth pairs of tildes can be omitted if there is no content following either of them.- After the last icon ID, if there is only one set of "tilde-tilde" (~~), the following text will be displayed in the main text cell instead of dist./time.- Separating text cells requires at least one empty space; otherwise the tildes will be treated as a signature.

**Văn bản các ô trong hàng biểu tượng**
The asterisk indicating a text cell can be preceded by one of the BSicons' width prefixes. (Normal BSicons are square.)

**Lớp phủ biểu tượng, liên kết biểu tượng, màu nền và colspan**
 Overlay separator "exclamation mark-tilde" (!~) must follow the icon ID which is to be overlaid.- Overlay is practically unlimited, but legibility should be taken into account.- When using icon overlay and icon link for the same icon cell, the icon link separator (!@) must follow the last (top) overlaying icon ID.- The background color parameter (bg=) requires 5 sets of preceding text separators to be recognizable even if there is no text on that row whatsoever.

**Tùy chọn định dạng khác**

**Hàng**
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.

**Các ô/biểu tượng cá nhân**
 Parameters for all of a stack of multiple overlaid icons and/or text boxes (or a single icon or text box with no overlays) are separated to the left by an exclamation mark and an underscore (!_). This must go after the link (if any).- Parameters for part of a stack of multiple overlaid items are separated to the left by two underscores (__).- For the last overlaid item in a stack, the individual item parameters (if any) must go before the stack parameters.- Most of the parameters are the same as those for rows, but there are a few additional ones. Additionally, the values for align=, bg= and color= can override those of the row parameters.

**Đóng mở**
 Adjust text-width (or tw) parameter until there is no break.
** Unit is "px" by default, but other units such as "em" are acceptable.
** Check the map in different browser and increase text-width if it breaks.- The icon number of the first row of collapsible section must be equal to or greater than the icon number of the widest non-collapsible row.
** As in example 3.2, use half-width empty icon d as filler when you are mixing both odd and even rows in the same map.- Changing "collapsed" to "nil" will change the default state of the collapible section to uncollapsed.

**Thay thế đóng mở**
 Both replacement and replaced rows must be as wide as the widest non-collapsible row in the diagram.- If you want to hide the replaced row after expanding the collapsible, use icon leer as empty filler as in example 4.2.- In any case, mind to provide a sufficient text-width. Here, using text-width=120 would break the alignment of the icons.- Collapsible elements are intentionally disabled in mobile view, so the replaced row will never be visible. Keep this in mind while creating a diagram.

**Hai văn bản thanh bên**
For larger and more complicated diagrams, it often helps to have a text sidebar on the left as well as the right.
or- Left text cells require "exclamation mark-space-exclamation mark" (! !) separating them from icon cells.- If there is no "tilde-tilde" (~~) 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.

**Hai văn bản thanh bên đóng mở**
 Apply text-width to eliminate the break:
** Only 1 value: right main text+right remark
** 3 values, separated by commas: right dist./time,right main text+right remark,right-right remark
** 6 values: Left-left remark,left remark+left main text,left dist./time,right dist./time,right main text+right remark,right-right remark
** If the amount of values does not equal to 1, 3 or 6, the whole parameter will be ignored.- If the text width of right-right remark is shorter to some degree, its width definition can be omitted, as in example 6.1.- If the entire map never uses a specific text cell, that width definition can be omitted, as in example 6.2.- Define the general table width in  parameter as well if  alone is ineffective to prevent the break.- If the empty icon cell of the collapsible row is being squashed, use empty icon leer to fixate the icon columns.

**Chuyển đổi từ bản mẫu hàng BS kế thừa đến đánh dấu Routemap**

**Chính sách chuyển đổi**
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: 
*The map of the legacy BS row template design has exceeded template size limit in the transcluding page, which means the template does not expand into its intended appearance but only the link to the template page is shown, so there is an imminent need to translate the map into Routemap design to reduce post-expand include size. 
*If there is no template size issue, respect the preference of the initial contributor of the first completed version of the diagram. If that contributor contests the change to Routemap, retain the BS row template design.

**Tùy chọn kỹ thuật**
All BS row templates have been amended with safesubst commands, hence conversion can be easily done by adding the safesubst: markup before every BS row template name in the map. For example, change  in the map to , then save change, it will produce . 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 be specified to the number of icon columns in order to avoid templates with similar name 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 Notepad++ and Sublime Text.
You can also use the "convertbs" function of Modeule:Routemap or an Unix script.

**Hàm convertbs**
Copy/paste the following code to any edit area of this wiki, maybe the map page you are working on:
Then copy/paste the original BS-map or Railway line header map code between the  tags (alternatively paste the invoke convertbs header before the original map code and the }} 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 #gọi:Routemap|convertbs if the preview of the new code works properly.

**Kịch bản Unix**
 Mind all non subst-ed templates, that require the ! protection of their first bar.
#! /bin/bash
cat  tmp_sed

s¶