Jump to content
MediaWiki

Extension:TextExtracts

From mediawiki.org
This page is a translated version of the page Extension:TextExtracts and the translation is 28% complete.
Aquesta extensió està sota revisió de gestió de codi i no es manté activament. (T256505) No es tindran en compte sol·licituds de noves funcions durant aquest període.
Per obtenir resums en llocs Wikimedia, s'utilitza Page Content Service. Please do not create new features for code running in Wikimedia production using this API.
Manual d'extensions de MediaWiki
TextExtracts
Notes de la versió: estable
Implementació API
Descripció Proporciona una API amb text pla o extractes HTML limitats del contingut de la pàgina.
Autor(s) Max Semenik (MaxSem discussió )
Política de compatibilitat Es publiquen noves instantànies juntament amb MediaWiki. La branca mestra no manté la retrocompatibilitat
Canvis a la base de dades No
  • $wgExtractsRemoveClasses
  • $wgExtractsExtendOpenSearchXml
  • $wgExtractsExtendRestSearch
Licence Llicència pública general GNU 2.0 o posterior
Descàrrega
Traduir l'extensió TextExtracts si està disponible a translatewiki.net
Incidències Tasques obertes · Informar d'un error

L'extensió TextExtracts proporciona una API que permet la recuperació d'extractes de text sense format o HTML limitat (HTML amb contingut eliminat per a algunes classes CSS) del contingut de la pàgina.

Instal·lació

This extension comes with MediaWiki 1.34 and later, so you do not need to download it. The remaining configuration instructions must still be followed.
  • Download and move the extracted TextExtracts folder to your extensions/ directory.
    Developers and code contributors should install the extension from Git instead, using:
    cdextensions/
    gitclonehttps://gerrit.wikimedia.org/r/mediawiki/extensions/TextExtracts
    
  • Add the following code at the bottom of your LocalSettings.php file:
    wfLoadExtension( 'TextExtracts' );
    
  • Yes Done – Navigate to Special:Version on your wiki to verify that the extension is successfully installed.

Paràmetres de configuració

  • $wgExtractsRemoveClasses is an array of <tag>, <tag>.class, .<class>, #<id> which will be excluded from extraction.
  • For example, $wgExtractsRemoveClasses[] = 'dl'; removes indented text, often used for non-templated hatnotes that are not desired in summaries.
  • extension.json defines the defaults, of which the class "noexcerpt" is one - this may be added to any template to exclude it.
  • $wgExtractsExtendOpenSearchXml defines whether TextExtracts should provide its extracts to the Opensearch API module.

The default is false.

API

extracts
Returns plain-text or limited HTML extracts of the given pages
This module cannot be used as a generator.
Prefix ex
Required rights cap
Post only? No
Generated help Current


The following documentation is the output of Special:ApiHelp/query+extracts, automatically generated by the pre-release version of MediaWiki that is running on this site (MediaWiki.org).

prop=extracts (ex)

(main | query | extracts)

Returns plain-text or limited HTML extracts of the given pages.

Specific parameters:
Other general parameters are available.
exchars

How many characters to return. Actual text returned might be slightly longer.

Type: integer
The value must be between 1 and 1,200.
exsentences

How many sentences to return.

Type: integer
The value must be between 1 and 10.
exlimit

How many extracts to return. (Multiple extracts can only be returned if exintro is set to true.)

Type: integer or max
The value must be between 1 and 20.
Default: 20
exintro

Return only content before the first section.

Type: boolean (details)
explaintext

Return extracts as plain text instead of limited HTML.

Type: boolean (details)
exsectionformat

How to format sections in plaintext mode:

plain
No formatting.
wiki
Wikitext-style formatting (== like this ==).
raw
This module's internal representation (section titles prefixed with <ASCII 1><ASCII 2><section level><ASCII 2><ASCII 1>).
One of the following values: plain, raw, wiki
Default: wiki
excontinue

When more results are available, use this to continue. More detailed information on how to continue queries can be found on mediawiki.org.

Type: integer
Another example
Result
{
"query":{
"pages":{
"9228":{
"pageid":9228,
"ns":0,
"title":"Earth",
"extract":"Earth, also called the world and, less frequently, Gaia, (or Terra in some works of science fiction)..."
}
}
}
}

Caveats

There are various things to be aware of when using the API or software that uses the API e.g. Extension:Popups .

  • We do not recommend the usage of `exsentences`.

It does not work for HTML extracts and there are many edge cases for which it doesn't exist. For example "Arm. gen. Ing. John Smith was a soldier." will be treated as 4 sentences. We do not plan to fix this.

  • Inline images are stripped from the response (even in HTML mode). This means if you are using the Math extension and using formulae in your lead section they may not appear in the summary output.
  • In HTML mode we cannot guarantee well formed HTML. Resulting HTML may be invalid or malformed.
  • In plaintext mode:
    • citations may not be stripped (see phab:T197266)
    • if a paragraph ends with an HTML tag e.g. ref tag, new lines may be dropped (see phab:T201946)
    • new lines may be dropped after lists phab:T208132
    • Articles must begin with the lead paragraph for an extract to be generated. The use of any template, and/or unclosed or empty HTML element may result in no preview for the article. E.g. "<div></div>hello" will give an empty extract.

FAQ

How can I remove content from a page preview/extract?

TextExtracts will strip any element that is marked with the class .noexcerpt. This is provided by the $wgExtractsRemoveClasses configuration variable (which also defines some other excluded elements).

Vegeu també

This extension is being used on one or more Wikimedia projects. This probably means that the extension is stable and works well enough to be used by such high-traffic websites. Look for this extension's name in Wikimedia's CommonSettings.php and InitialiseSettings.php configuration files to see where it's installed. A full list of the extensions installed on a particular wiki can be seen on the wiki's Special:Version page.
This extension is included in the following wiki farms/hosts and/or packages:

AltStyle によって変換されたページ (->オリジナル) /