Help:Labeled section transclusion

From Infogalactic: the planetary knowledge core
Jump to: navigation, search

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.

Function names

Internally, the parser functions all use the #lst prefix, for consistency with the name of the extension. Since this acronym may be confusing to non-developers, readable English variants have been introduced, so the functions can currently be called from either name.

Function Alias Three args: 1) pagename, 2) the source section or a range-start, 3) source-section range-end.
#lsth #section-h Heading/section-title oriented. Ignores <section /> tags if any. Range headings not included, range content is. No section heading given is section 0 (lead). Ignores <onlyinclude> tags.
#lst #section <section /> tags required. (<onlyinclude> tags honored in source.) Range begins at first heading ends at tag. No range given is normal transclusion.
#lstx #section-x With <section /> tags only. One section only. #section-x is the complement of #section.


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 the normal HTML open/close tags <section>...</section> which is invalid for this parser tag. This would be invalid HTML, but <section /> is not a HTML element; it is a parser tag added by the Labeled Section Transclusion software extension. The extension uses this method to simplify the processing of nested or overlapping sections and allow you to insert section tags without worrying about interfering with other sections.

Section transclusion

Use the parser function #section to transclude the section. for example, to transclude a section called chapter1 from a page called articleX:


The target article defines the location of the section.

For namespaces other than articles, include the namespace. For example:

{{#section:Help:Labeled section transclusion|chapter1}}

It is also possible to translude from the same page the section is defined on. The transclusion will not show in an edit preview until the defined section is saved.

Transclude the page but exclude the section

To transclude a page, but exclude a specified section, use the #section-x parser function:


Optionally, you may add replacement text to the excluded section.



{{#section-x: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 can transclude the whole page, so they have the two, optional argument to specify behaviours: 1) a name-tagged section or heading-title, 2) a range of such named section-tags or section titles, and 3) replacement content for a named section.

  • {{#section:articleX|chapter1|chapter3}} includes 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.
  • {{#section-h:articleX|chapter1|chapter3}} includes content of chapter1, heading and content of chapter 2.
  • {{#section-x:articleX|chapter1|chapter3}} replaces chapter1 heading and content with the word "chapter3".


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:#section:talk_page|archive}}, which copies archived sections. Lastly, replace the contents of talk_page with {{subst:#section-x:talk_page|archive}} to remove those sections.

Typing aid

{{lst}} is a typing aid template that renders as labeled section transclusion and links to this help page.


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}}.

See also