Ir al contenido

Plantilla:Npt

De Wikisource, la biblioteca libre.
Documentación de la plantilla



npt es {{np}} para las instancias en que una tabla se debe continuar a través de páginas. Funciona por insertar un comentario de HTML seguido por una nueva línea de tal manera que el contenido real (el marcado de la tabla) se fuerza a la línea siguiente.

Uso

Pon…

{{npt}}

…al principio del pie de la primera página, y al principio del contenido de la segunda página (para una tabla que cruza tres o más páginas, lo tendrías en ambos lugares). En la pie de la primera página, previene que se aplaste el |} a la celda de la última celda en el espacio de nombres Página. Al principio del contenido de la segunda página, hace lo mismo para |}, |-, o | (o cualquier otra marcado de wiki de tabla que necesita estar en su propia línea) cuando las páginas se transcluye.

Detalles técnicos

El sintaxis de tabla de MediaWiki y el el funcionamiento de transclusión de ProofreadPage pueden interferirse: la mayoría del marcado de tabla debe estar al principio de una línea para funcionar, y ProofreadPage emplea diversos trucos (comparado con el MediaWiki normal) precisamente para hacer que las junturas entre áreas separados sean sin soldadura, que en algunas situaciones interfiere con el sintaxis de tabla.

There are two main places where this happens: between the content and footer of a single page in the Page: namespace, and between the end of one page and the beginning of the next when they are transcluded together into mainspace.

Entre el contenido y el pie de página

Within a single page in the Page: namespace there are three distinct parts: the header, the main content, and the footer. The header and footer are wrapped in <noinclude>…</noinclude> tags so they will not be included when the page is transcluded to mainspace. Under the hood, these three parts are actually stored as a single wikipage, but ProofreadPage parses out the two special sections and presents them in separate text field when editing for convenience. But this also means that when you are looking at a saved page in the Page: namespace, MediaWiki has to join together these three parts to show them to you. When it does so, it will remove any trailing whitespace from the content area, and any leading whitespace in the footer area, leading to whatever you put at the beginning of the latter getting smushed onto the end of the former. This works fine for most things.

However, when you're dealing with a table that's split over multiple pages, you need to use wikimarkup like this:

{|
|-
| Row one, cell one || Row one, cell two
|-
| Row two, cell one || Row two, cell two
<noinclude>← footer begins here
|}
</noinclude>

When these are joined together for display, the resulting code becomes:

{|
|-
| Row one, cell one || Row one, cell two
|-
| Row two, cell one || Row two, cell two<noinclude>|}</noinclude>

Since this table markup has to be at the beginning of a line to work, what gets displayed is something like this (rendering will vary depending on circumstance):

Row one, cell one Row one, cell two
Row two, cell one Row two, cell two|}

To work around this problem you can use {{nopt}}, like so:

{|
|-
| Row one, cell one || Row one, cell two
|-
| Row two, cell one || Row two, cell two
<noinclude>← footer begins here
{{nopt}}
|}
</noinclude>

{{nopt}} inserts a HTML comment and a newline, that are invisible in the rendered output, but when the content and footer parts are joined together you end up with:

{|
|-
| Row one, cell one || Row one, cell two
|-
| Row two, cell one || Row two, cell two<noinclude><!-- nopt -->
|}</noinclude>

Because of the HTML comment (invisible like whitespace, but not removed by MediaWiki) the table markup is now on its own line and works as usual. The result would be:

Row one, cell one Row one, cell two
Row two, cell one Row two, cell two

Entre páginas posteriores

When a table continues across multiple page you must open the table ({|) in the content part of the first page; close the table (|}) in the footer of the first page, so it renders correctly in the Page: namespace; reopen the table ({|) in the header of the following page; repeat for each intermediate page, if any; and finally close it (|}) in the content part of the last page. When the pages are trancluded together into mainspace the intermediate opening and closing markup is left out, and a single continuous table is rendered.

The transclusion in ProofreadPage is set up primarily for non-table content (running prose), so it will strip out extraneous leading and trailing whitespace and replace them with a single space character. This is so that pages containing "One nation" and "under God!" will end up as "One nation under God!" rather than "One nationunder God!". For tables, however, this creates a problem:

First page
{|
|-
| Row one, cell one || Row one, cell two
<noinclude>← footer begins here
|}
</noinclude>
Second page
<noinclude>← header begins here
{|
</noinclude>
|-
| Row two, cell one || Row two, cell two
|}

When these are transcluded together for display in mainspace, the resulting code becomes:

{|
|-
| Row one, cell one || Row one, cell two|-
| Row two, cell one || Row two, cell two
|}

Since this table markup has to be at the beginning of a line to work, what gets displayed is something like this (rendering will vary depending on circumstance):

Row one, cell one - Row two, cell one Row two, cell two

To work around this problem you can use {{nopt}}, like so:

First page
{|
|-
| Row one, cell one || Row one, cell two
<noinclude>← footer begins here
{{nopt}}
|}
</noinclude>
Second page
<noinclude>← header begins here
{|
</noinclude>
{{nopt}}
|-
| Row two, cell one || Row two, cell two
|}
</noinclude>

{{nopt}} inserts a HTML comment and a newline, that are invisible in the rendered output, but when the two pages are joined together you end up with:

{|
|-
| Row one, cell one || Row one, cell two<!-- nopt -->
|-
| Row two, cell one || Row two, cell two
|}

Because of the HTML comment (invisible like whitespace, but not removed by MediaWiki) the table markup is now on its own line and works as usual. The result would be:

Row one, cell one Row one, cell two
Row two, cell one Row two, cell two

Véase también

  • {{nop}}—The same concept to prevent separate paragraphs of text from running together.
  • {{peh}}—A related template to prevent a hyphen at the end of a page from being removed.
  • {{hws}}/{{hwe}}—Pair of templates to control display of words split across pages.
  • {{lps}}/{{lpe}}—Pair of templates to control display of wikilinked words split across pages.
Esta documentación está transcluida desde Plantilla:Npt/doc.
Los editores pueden experimentar en la zona de pruebas de esta plantilla.
Por favor, añade las categorías e interwikis a la subpágina de documentación. Subpáginas de esta plantilla.