Help:Labeled section transclusion

From Wikipedia, the free encyclopedia
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[edit]

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 English
#lst #section
#lstx #section-h

Markup[edit]

Section marking[edit]

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.

Do not include any text after the <section /> as this will cause the enclosed text to not show.[clarification needed]

Section transclusion[edit]

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

{{#section:articleX|chapter1}}

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[edit]

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

{{#section-x:articleX|chapter1}}

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

{{#section-x:articleX|chapter1|replacement_text}}

Example:

{{#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[edit]

Discontiguous sections[edit]

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[edit]

These functions have an additional, optional argument to specify a section range; i.e. {{#section: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[edit]

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[edit]

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

Templates[edit]

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[edit]