Extensión:Transclusión de sección etiquetada
![]() Estado de la versión: estable |
|
---|---|
Implementación | Etiqueta , Función del analizador |
Descripción | Permite transcluir secciones marcadas de texto |
Autor(es) | Steve Sanbeg |
Política de compatibilidad | Lanza instantáneas junto con MediaWiki. La rama maestra no es retrocompatible. |
MediaWiki | 1.19+ |
Cambios en la base de datos | No |
Licencia | Licencia Pública General de GNU 2.0 o posterior |
Descargar | |
Wikis públicos que lo utilizan | 6,919 (Ranked 26th) |
Traduce la extensión Labeled Section Transclusion si está disponible en translatewiki.net | |
Incidentes | Tareas abiertas · Reportar un error |
The Labeled Section Transclusion extension allows selective transclusion of marked-off sections of text, parsing wikitext as normal. Its functionality is similar to an enhanced version of the <onlyinclude>
tag with normal wiki transclusion, which selects sections for inclusion. It is enabled on all Wikimedia wikis.
While normal transclusion is primarily intended to transclude large portions of small templates, labeled section transclusion is intended for small portions of large pages.
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.
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.
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.
Instalación
- Descarga y extrae los archivos en un directorio denominado «
LabeledSectionTransclusion
» dentro de la carpetaextensions/
.
Developers and code contributors should install the extension from Git instead, using:cd extensions/
git clone https://gerrit.wikimedia.org/r/mediawiki/extensions/LabeledSectionTransclusion - Añade el siguiente código en la parte final de tu archivo LocalSettings.php :
wfLoadExtension( 'LabeledSectionTransclusion' );
- Hecho – Navega a Special:Version en el wiki para verificar que la extensión se haya instalado correctamente.
There is also a Gadget in use on Wikisource.org wikis that makes it possible to define sections with a simplified ## label ##
syntax.
Its code can be found at Wikisource:MediaWiki:Gadget-Easy_LST.js.
Funciones
Transcluir cualquier parte marcada
Paso 1: marque las secciones
Marca secciones en el texto utilizando etiquetas <section>
como ésta:
<section begin="chapter1" />this is chapter 1<section end="chapter1" />
Observa que estas etiquetas no son HTML/XML y no usan la sintaxis de atributo normal.
Por este motivo, y debido a que los marcadores begin
y end
son individuales, en lugar de etiquetas XML de apertura y cierre normales, esto permite secciones anidadas o superpuestas. Esto te permite insertar etiquetas de sección sin preocuparte de interferir con otras secciones.
Paso 2a: transcluir la sección
Llama a la función del analizador #lst para transcluirla, es decir, para transcluir una sección llamada chapter1 de una página llamada articleX:
{{#lst:articleX|chapter1}}
El artículo de destino define la ubicación de la sección; su comportamiento está determinado por la función del analizador.
Paso 2b: Transcluir la página pero excluyendo la sección
Para transcluir una página pero excluir una sección específica, utilice la función #lstx:
{{#lstx:articleX|chapter1}}
Opcionalmente, puedes añadir texto de reemplazo a la sección excluida.
{{#lstx:articleX|chapter1|replacement_text}}
Ejemplo:
{{#lstx:articleX|chapter1|See chapter 1 in [[articleX]].}}
El texto de reemplazo aparecerá en el área donde la sección está omitida (excluida).
Secciones discontinuas
Es posible tener varias secciones con el mismo nombre; en este caso, cada sección con ese nombre será incluida/excluida. Esto es especialmente útil para marcar varias discusiones.
Rangos de secciones
Estas funciones tienen un argumento adicional, opcional, para especificar un rango de secciones; es decir, {{#lst:artículoX|capítulo1|capítulo3}}, para incluir todo desde el principio del capítulo 1 hasta el final del capítulo 3. Esto permite utilizar pares de marcadores vacíos para marcar un cierre de la sección, posiblemente en una plantilla. Un mecanismo similar se usa actualmente en la Wikisource francesa.
Sustitución
Esto también funciona con la sustitución; incluso es posible que un artículo sustituya una sección de sí mismo. Un uso de esto proporciona una forma limipia de archivar páginas de discusión: Marca el texto que se archivará usando <section begin=archive />
, etc. Luego crea una página de archivado con el texto, usando {{subst:#lst:talk_page|archive}}, que copia las secciones archivadas. Por último, sustituye el contenido de talk_page
por {{subst:#lstx:talk_page|archive}} para quitar esas secciones.
Existe un soporte opcional para transcluir secciones de texto marcadas con los encabezados normales, es decir ==this section==
. Si está instalado, esto se hace con la función lsth
.
Transcluir la introducción
Para transcluir la introducción de una página (es decir, el contenido antes del primer encabezado), utiliza
{{#lsth:pagename}}
Transcluir una sección específica
También puedes transcluir todo el contenido de la sectionX (que incluye todas sus subsecciones pero excluye el encabezado de la propia sectionX).
{{#lsth:pagename|sectionX}}
Cosas para notar:
- Only the first occurrence of the sectionX is transcluded if you have more than one section with the same name.
- Make sure you type what the heading of sectionX is in wikitext, not how it is displayed. For example if the heading of the section is
==List of [[Extension]]==
, you should type "List of [[Extension]]
" not "List of Extension
".
- When transcluding a section from a page marked for translation using the translate extension, transclude from the language-specific version.
E.g. from pagename/en rather than from pagename.
- The matching is case insensitive, to prevent links from breaking due to case changes.
Transcluir múltiples secciones
You can also transclude from the first occurrence of sectionX (excluding the heading of sectionX itself) until it reaches the next occurrence of sectionY. Note that sectionY acts as a stop point so the transclusion doesn't contain the content of sectionY.
{{#lsth:pagename|sectionX|sectionY}}
Notas sobre los encabezados omitidos
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.
When this extension is used (with MediaWiki 1.9 or later), the #lst and #lsth 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.
Note that #lstx does not count skipped headings, and that skipped headings within discontiguous sections are not offset.
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.
Localización
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.
función | inglés | alemán | hebreo (RTL) | portugués |
---|---|---|---|---|
#lst | #section | #Abschnitt | #קטע |
#trecho |
#lstx | #section-x | #Abschnitt-x | #בלי קטע |
#trecho-x |
#lsth | #section-h |
Additionally, the tag can now be localised; currently:
inglés, alemán, hebreo, portugués; i.e.:
- inglés
<section begin=x/> ... <section end=x/>
- alemán
<Abschnitt Anfang=x/> ... <Abschnitt Ende=x/>
- hebreo (RTL)
<קטע התחלה=א> ... <קטע סוף=א>
("start" code to the right and "end" code to the left)- portugués
<trecho começo=x/> ... <trecho fim=x/>
Each localization is enabled only if the page matches the respective content language.
Limitaciones
- {{#lsth:pagename|sectionX}} only works on the first section if multiple sections have the name sectionX. Only the first occurrence of sectionX is transcluded if an article has more than one section with the same name.
- While it is possible to use this extension across namespaces, interwiki references are not resolved. It is not yet possible, for example, to include part of a Wikisource page into a remote MediaWiki installation.
- Section tags cannot themselves be transcluded in order to work on other pages.
{{#lst:}}
and{{#lstx:}}
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 template parameters and parser functions. The#tag
magic word does not work with section tags.
- As of 2014, section tags don't have any effect when used inside a template parameter. If page A contains a text {{B|X}}, there's no way {{#lst:A|...}} can access X.
Ejemplos
- wikisource:user:sanbeg/Includer - an early demonstration that shows several of the basic features.
Véase también
- DynamicPageList (third-party) includes a slightly modified built-in version of Labeled Section Transclusion
Esta extensión está siendo usada en uno o más proyectos de Wikimedia. Esto significa probablemente que la extensión es estable y funciona lo suficientemente bien como para ser usada en sitios con gran cantidad de visitas. Puedes buscar el nombre de esta extensión en los archivos CommonSettings.php e InitialiseSettings.php de Wikimedia para ver dónde se instala. Encontrarás la lista completa de extensiones instaladas en un wiki en particular en la página Special:Version del wiki. |
Esta extensión está incluida en los siguientes anfitriones/granjas wiki y/o paquetes: No se trata de una lista oficial. Algunas granjas/hosts wiki y/o paquetes pueden tener disponible esta extensión aunque no estén listados aquí. Siempre compruébelo con su anfitrión o granja wiki para confirmarlo. |