Manual:Parser.php/ru

Описание
Этот файл содержит класс  , который содержит метод, который преобразует викитекст в HTML. Выполняет, среди прочего, следующие действия:


 * 1) Вызов вспомогательной функции, которая в свою очередь вызывает
 * , который заменяет магические переменные, шаблоны и аргументы шаблона соответствующим текстом.
 * 1) Он вызывает, который выполняет предварительную обработку некоторого викитекста и возвращает дерево документа.
 * 2) Далее он создает объект  и вызывает метод , чтобы сделать фактическую магию шаблона.
 * , which cleans up HTML, removes dangerous tags and attributes, and removes HTML comments.
 * , which handles and renders the wikitext for tables.
 * , which removes valid double-underscore items, like, and records them in array.
 * , which parses and renders section headers.
 * , which processes internal links and stores them in   (a object),
 * , which replaces single quotes with HTML markup (,, etc).
 * , which replaces and renders external links.
 * , which replaces special strings like "ISBN xxx" and "RFC xxx" with magic external links.
 * , which:
 * 1) * auto numbers headings if that options is enabled,
 * 2) * adds an [edit] link to sections for users who have enabled the option and can edit the page,
 * 3) * adds a Table of contents on the top for users who have enabled the option, and
 * 4) * auto-anchors headings.
 * 5) Next,   calls, which renders lists from lines starting with ':', '*', '#', etc.
 * 6)  is called, which calls  on  to replace link placeholders with actual links, in the buffer Placeholders created in Skin::makeLinkObj
 * 7) Next, the text is language converted (when applicable) using the   method of the appropriate Language object.
 * 8)  is called, which replaces transparent tags with values which are provided by the callback functions in . Transparent tag hooks are like regular XML-style tag hooks, except they operate late in the transformation sequence, on HTML instead of wikitext.
 * 9)  is called, which ensures that any entities and character references are legal for XML and XHTML specifically.
 * 10) If HTML tidy is enabled,  is called to do the tidying.
 * 11) Finally the rendered HTML result of the parse process is stored in the   object, which is returned to the caller of.

How to get a new parser
Since MediaWiki 1.36 you can't construct a Parser class directly. You should use instead, and then call its   method.

The constructor of the ParserFactory takes several arguments. To create a ParserFactory with default options, use.

One-liner for getting a new Parser instance:

Accessors

 * Accessor for $mDefaultSort. Unlike getDefaultSort, it will return false if none is set.
 * Accessor for $mDefaultSort. Will use the empty string if none is set.
 * Get the ParserOptions object.
 * Get the ParserOutput object.
 * Get a preprocessor object.
 * Get the ID of the revision we are parsing.
 * Get the timestamp associated with the current revision, adjusted for the default server-local timestamp.
 * Get the name of the user that edited the last revision.
 * Accessor.
 * Get the target language for the content being parsed.
 * Accessor for the Title object.
 * Get a User object either from $this->mUser, if set, or from the ParserOptions object otherwise.

Set

 * Create a function, e.g. . The callback function should have the form:.
 * Create a tag function, e.g. . Unlike tag hooks, tag functions are parsed at preprocessor level. Unlike parser functions, their content is not preprocessed.
 * Create an HTML-style tag, e.g. . The callback should have the following form:



См. также

 * – Overview of the key files and directories in the MediaWiki source code