MediaWiki/Extension/Labeled Section Transclusion: Unterschied zwischen den Versionen

Aus Foxwiki
Die Seite wurde neu angelegt: „<languages/> {{Extension |author=Steve Sanbeg |image= |type1=tag |type2=parser function |update= |compatibility policy=rel |license=GPL-2.0-or-later |download={{WikimediaDownload|LabeledSectionTransclusion|phab=ELST}} |needs-updatephp = No |readme= |description=<translate><!--T:1--> Enables marked sections of text to be transcluded</translate> |parameters= |rights= |status=stable |phabricator= mediawiki-extensions-labeledsectiontransclusion |CheckUsageNam…“
 
K Textersetzung - „Kurzbeschreibung“ durch „Beschreibung“
 
(12 dazwischenliegende Versionen desselben Benutzers werden nicht angezeigt)
Zeile 1: Zeile 1:
<languages/>
'''topic''' - Beschreibung
{{Extension
== Beschreibung ==
|author=Steve Sanbeg
|image=
|type1=tag
|type2=parser function
|update=
|compatibility policy=rel
|license=GPL-2.0-or-later
|download={{WikimediaDownload|LabeledSectionTransclusion|phab=ELST}}
|needs-updatephp = No
|readme=
|description=<translate><!--T:1--> Enables marked sections of text to be transcluded</translate>
|parameters=
|rights=
|status=stable
|phabricator= mediawiki-extensions-labeledsectiontransclusion
|CheckUsageNameOverride = LabeledSectionTransclusion
}}
<translate>
<!--T:2-->
The '''Labeled Section Transclusion''' extension allows selective [[w:Wikipedia:transclusion|transclusion]] of marked-off sections of text, parsing wikitext as normal. Its functionality is similar to an enhanced version of the <tvar name=onlyinclude>{{tag|onlyinclude|open}}</tvar> tag with normal wiki transclusion, which selects sections for inclusion. It is enabled on all Wikimedia wikis.


<!--T:3-->
<noinclude>
While normal transclusion is primarily intended to transclude large portions of small templates, labeled section transclusion is intended for small portions of large pages.
== Anhang ==
=== Siehe auch ===
{{Special:PrefixIndex/{{BASEPAGENAME}}}}
==== Links ====
===== Weblinks =====
# https://www.mediawiki.org/wiki/Extension:Labeled_Section_Transclusion


<!--T:4-->
[[Kategorie:MediaWiki/Extension]]
However, there are some differences. In the native template transclusion, sections are marked by behavior; thus you can have only one (possibly non-contiguous) section to be included or skipped.
</noinclude>
 
<!--T:5-->
Here, sections are marked by name, and behavior is chosen by the caller, which can 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.
 
<!--T:6-->
Marking sections by name rather than behavior allows edit section links to be rendered more appropriately for getting excerpts from larger texts, since the extension can now account for sections that are skipped in the beginning of the page, allowing transcluded sections to be offset appropriately.
 
== Installation == <!--T:61-->
</translate>
{{ExtensionInstall
|LabeledSectionTransclusion
|registration=required
}}
 
<translate><!--T:80--> There is also a [[<tvar name=ext>Special:MyLanguage/Extension:Gadgets</tvar>|Gadget]] in use on Wikisource.org wikis that makes it possible to define sections with a simplified <tvar name=code><code>## label ##</code></tvar> syntax.</translate>
<translate><!--T:81--> Its code can be found at [[:Wikisource:MediaWiki:Gadget-Easy_LST.js]].</translate>
<translate>
==Functions == <!--T:7-->
 
=== Transclude any marked part  === <!--T:86-->
 
==== Step 1: Mark off sections ==== <!--T:8-->
 
<!--T:9-->
Mark off sections in the text using <tvar name=section>{{tag|section|open}}</tvar> tags like this:
</translate>
 
<syntaxhighlight lang="html">
<section begin="chapter1" />this is a chapter 1<section end="chapter1" />
</syntaxhighlight>
 
<translate><!--T:79--> Note that these tags are not HTML/XML, and do not use the normal attribute syntax.</translate>
<translate><!--T:10--> For this reason, and because the <tvar name=begin><code>begin</code></tvar> and <tvar name=end><code>end</code></tvar> markers are individual, rather than normal XML open/close tags, this allows nested or overlapping sections. This allows you to insert section tags without worrying about interfering with other sections.</translate>
 
<translate>
==== Step 2a: Transclude the section ==== <!--T:11-->
 
<!--T:12-->
Call the parser function <tvar name=lst>''#lst''</tvar> to transclude it, i.e. to transclude a section called <tvar name=section>''chapter1''</tvar> from a page called <tvar name=page>''articleX''</tvar>:
</translate>
 
<nowiki>{{#lst:articleX|chapter1}}</nowiki>
 
<translate>
<!--T:13-->
The target article defines the location of the section; its behavior is determined by the parser function.
 
==== Step 2b: Transclude the page but excluding the section ==== <!--T:14-->
 
<!--T:15-->
To transclude a page, but exclude a specified section, use the <tvar name=lstx>''#lstx''</tvar> function:
</translate>
 
<nowiki>{{#lstx:articleX|chapter1}}</nowiki>
 
<translate>
<!--T:16-->
Optionally, you may add replacement text to the excluded section.
</translate>
 
<nowiki>{{#lstx:articleX|chapter1|replacement_text}}</nowiki>
 
<translate>
<!--T:17-->
Example:
</translate>
 
<nowiki>{{#lstx:articleX|chapter1|See chapter 1 in [[articleX]].}}</nowiki>
 
<translate>
<!--T:18-->
The replacement text will appear in the area where the section is skipped (excluded).
 
=== Discontiguous sections === <!--T:20-->
 
<!--T:21-->
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 === <!--T:22-->
 
<!--T:23-->
These functions have an additional, optional argument to specify a section range; i.e. <nowiki>{{#lst:articleX|chapter1|chapter3}}</nowiki>, 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. A similar mechanism is currently used at the French Wikisource.
 
=== Substitution === <!--T:24-->
 
<!--T:25-->
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 <tvar name=code1><syntaxhighlight lang=html inline><section begin=archive /></syntaxhighlight></tvar>, etc. Then create an archive page with the text, using <tvar name=code2><nowiki>{{subst:#lst:talk_page|archive}}</nowiki></tvar>, which copies archived sections. Lastly, replace the contents of talk_page with <tvar name=code3><nowiki>{{subst:#lstx:talk_page|archive}}</nowiki></tvar> to remove those sections.
 
<!--T:28-->
There is optional support for transcluding sections of text marked with the normal headings, i.e. <tvar name=code><code>==this section==</code></tvar>. If installed, this is done with the ''lsth'' function.
 
=== Transclude before the first heading === <!--T:29-->
 
<!--T:30-->
To transclude the introduction of a page (i.e. the content before the first heading), use
</translate>
 
<nowiki>{{#lsth:pagename}}</nowiki>
 
<translate>
=== Transclude a specific section === <!--T:31-->
 
<!--T:32-->
You can also transclude the whole content of the <tvar name=section1>''sectionX''</tvar> (which includes all its sub-sections but excludes the heading of <tvar name=section2>''sectionX''</tvar> itself).
</translate>
 
<nowiki>{{#lsth:pagename|sectionX}}</nowiki>
 
<translate>
<!--T:33-->
Things to note:
 
<!--T:34-->
# Only the first occurrence of the <tvar name=section>''sectionX''</tvar> is transcluded if you have more than one section with the same name.</translate>
<translate>
<!--T:35-->
# Make sure you type what the heading of <tvar name=section>''sectionX''</tvar> is <u>in wikitext</u>, not how it is displayed. For example if the heading of the section is <tvar name=code1><code><nowiki>==List of [[Extension]]==</nowiki></code></tvar>, you should type "<tvar name=code2><code><nowiki>List of [[Extension]]</nowiki></code></tvar>" not "<tvar name=code3><code><nowiki>List of Extension</nowiki></code></tvar>".</translate>
<translate>
<!--T:82-->
# When transcluding a section from a page marked for translation using the translate extension, transclude from the language-specific version.</translate> <translate><!--T:83--> E.g. from ''pagename/en'' rather than from ''pagename''.</translate>
<translate>
<!--T:36-->
# The matching is case '''in'''sensitive, to prevent links from breaking due to case changes.
 
===Transclude multiple sections=== <!--T:37-->
 
<!--T:38-->
You can also transclude from the first occurrence of <tvar name=section1>''sectionX''</tvar> (excluding the heading of <tvar name=section2>''sectionX''</tvar> itself) until it reaches the next occurrence of <tvar name=section3>''sectionY''</tvar>. Note that <tvar name=section4>''sectionY''</tvar> acts as a stop point so the transclusion doesn't contain the content of <tvar name=section5>''sectionY''</tvar>.
</translate>
 
<nowiki>{{#lsth:pagename|sectionX|sectionY}}</nowiki>
 
<translate>
== Notes about skipped headings == <!--T:39-->
 
<!--T:40-->
Since the traditional transclusion in MediaWiki isn't intended to transclude sections, it doesn't account for skipped headings. As a result, if you were to transclude a template with multiple headings, and skip the first heading, then all of the edit sections links would point to the wrong section in the template.
 
<!--T:41-->
When this extension is used (with MediaWiki 1.9 or later), the <tvar name=lst>''#lst''</tvar> and <tvar name=lsth>''#lsth''</tvar> functions count headings in the "skipped" beginning part, and offset transcluded headings appropriately. This will allow these links to point to the correct section in the simple case.
 
<!--T:42-->
Note that <tvar name=lstx>''#lstx''</tvar> does not count skipped headings, and that skipped headings within discontiguous sections are not offset. </translate>'''<translate><!--T:43--> But it seems it has been fixed now (likely when ported to MediaWiki's new preprocessor). The transcluded headings can be linked to the correct sections</translate>'''. <!-- Please could anyone confirm this? -->
 
<translate>
== Localisation == <!--T:44-->
 
<!--T:45-->
Internally, the parser functions all use the <tvar name=lst>''lst''</tvar> 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.
</translate>
 
{|class="wikitable"
! <translate><!--T:46--> function</translate>
! {{#language:en|{{PAGELANGUAGE}}}}
! {{#language:de|{{PAGELANGUAGE}}}}
! {{#language:he|{{PAGELANGUAGE}}}} (RTL)
! {{#language:pt|{{PAGELANGUAGE}}}}
|-
| #lst || #section || #Abschnitt || <div dir="RTL">#קטע</div> || #trecho
|-
| #lstx || #section-x || #Abschnitt-x || <div dir="RTL">#בלי קטע</div> || #trecho-x
|-
| #lsth || #section-h || || ||
|}
<translate>
<!--T:51-->
Additionally, the tag can now be localised; currently:</translate> {{#language:en|{{PAGELANGUAGE}}}}, {{#language:de|{{PAGELANGUAGE}}}}, {{#language:he|{{PAGELANGUAGE}}}}, {{#language:pt|{{PAGELANGUAGE}}}}; <translate><!--T:84--> i.e.:</translate>
 
;{{#language:en|{{PAGELANGUAGE}}}}: <syntaxhighlight lang=html inline><section begin=x/> ... <section end=x/></syntaxhighlight>
;{{#language:de|{{PAGELANGUAGE}}}}: <syntaxhighlight lang=html inline><Abschnitt Anfang=x/> ... <Abschnitt Ende=x/></syntaxhighlight>
;{{#language:he|{{PAGELANGUAGE}}}} (RTL): <syntaxhighlight lang=html inline><קטע התחלה=א> ... <קטע סוף=א></syntaxhighlight> (<translate><!--T:55--> "start" code to the right and "end" code to the left</translate>)
;{{#language:pt|{{PAGELANGUAGE}}}}: <syntaxhighlight lang=html inline><trecho começo=x/> ... <trecho fim=x/></syntaxhighlight>
 
<translate>
<!--T:85-->
Each localization is enabled only if the page matches the respective content language.
 
==Limitations== <!--T:57-->
 
<!--T:58-->
* <nowiki>{{#lsth:pagename|sectionX}}</nowiki> only works on the first section if multiple sections have name ''sectionX''. Only the first occurrence of ''sectionX'' is transcluded if an article has more than one section with the same name.</translate>
* <translate><!--T:87--> While it is possible to use this extension across namespaces, [[<tvar name=EnableScaryTranscluding>Special:MyLanguage/Manual:$wgEnableScaryTranscluding</tvar>|interwiki references]] are not resolved.</translate> <translate><!--T:88--> It is not yet possible, for example, to include part of a Wikisource page into a remote MediaWiki installation.</translate>
<translate>
<!--T:59-->
* Section tags cannot themselves be transcluded in order to work on other pages. <tvar name=code><code><nowiki>{{#lst:}}</nowiki></code> and <code><nowiki>{{#lstx:}}</nowiki></code></tvar> work only if section tags appear directly in the wikitext of the transcluded page. This means, for instance, that these tags cannot be embedded in a template using [[<tvar name=tl-params>Special:MyLanguage/Help:Templates#Parameters</tvar>|template parameters]] and [[<tvar name=parser-fns>Special:MyLanguage/Parser functions</tvar>|parser functions]]. The <tvar name=tag1><code>#tag</code></tvar> magic word does not work with section tags.</translate>
<translate>
<!--T:78-->
* As of 2014, section tags don't have any effect when used inside a template parameter. If page A contains a text <nowiki>{{B|X}}</nowiki>, there's no way <nowiki>{{#lst:A|...}}</nowiki> can access X.
 
==Examples== <!--T:72-->
 
<!--T:73-->
* [[wikisource:user:sanbeg/Includer]] is an early demonstration that shows several of the basic features.
 
== See also== <!--T:74-->
 
<!--T:75-->
*[[<tvar name=dpl2>Special:MyLanguage/Extension:DynamicPageList (third-party)</tvar>|DynamicPageList (third-party)]] includes a slightly modified built-in version of Labeled Section Transclusion
</translate>
 
{{OnWikimedia}}
{{Used by}}
{{Parser functions nav}}
 
[[Category:Parser function extensions{{#translation:}}|Labeled Section Transclusion]]

Aktuelle Version vom 19. Oktober 2024, 13:48 Uhr