Help:Labeled section transclusion
![]() | This help page is a how-to guide. It explains concepts or processes used by the Wikipedia community. It is not one of Wikipedia's policies or guidelines, and may reflect varying levels of consensus. |
Labeled section transclusion (LST) is a method of transcluding marked-off sections of one page to another. Transclusions may include or skip sections as needed. Different pages can include or exclude selected sections; there can be arbitrary numbers of sections, which can also overlap arbitrarily.
Markup
Section marking
Mark off sections in the text using <section>
tags; for example:
<section begin=chapter1 />
this is a chapter<section end=chapter1 />
Note that this uses two singular <section />
tags, rather than normal HTML open/close tags, which simplifies nested or overlapping sections. This allows you to insert section tags without worrying about interfering with other sections.
Section transclusion
Use the parser function #lst
to transclude the section. for example, to transclude a section called chapter1 from a page called articleX:
{{#lst:articleX|chapter1}}
The target article defines the location of the section.
Transclude the page but exclude the section
To transclude a page, but exclude a specified section, use the #lstx
parser function:
{{#lstx:articleX|chapter1}}
Optionally, you may add replacement text to the excluded section.
{{#lstx:articleX|chapter1|replacement_text}}
Example:
{{#lstx:articleX|chapter1|See chapter 1 in [[articleX]].}}
The replacement text will appear in the area where the section is skipped (excluded).
Other functions
Discontiguous sections
It is possible to have multiple sections with the same name; in this case, every section with that name will be included/excluded. This is especially useful to mark various discussions.
Section ranges
These functions have an additional, optional argument to specify a section range; i.e. {{#lst:articleX|chapter1|chapter3}}, to include everything from the beginning of chapter 1 to the end of chapter 3. This allows using empty marker pairs to mark one end of the section, possibly in a template.
Substitution
This also works with substitution; it's even possible for an article to substitute a section of itself. One use of this provides a neat way to archive talk pages: Mark the text to be archived using <section begin=archive />, etc. Then create an archive page with the text, using {{subst:#lst:talk_page|archive}}, which copies archived sections. Lastly, replace the contents of talk_page with {{subst:#lstx:talk_page|archive}} to remove those sections.
Templates
In order to include variable data within an extension tag such as <section />
, the #tag
parser function must be used. Currently #tag
only supports balanced tags, not a singular tag, thus <section />
cannot be used in a template unless the content is hard coded. See {{section}}.