Extension:HTML Tags/ru
Статус релиза: стабильно |
|
|---|---|
| Реализация | Тег |
| Описание | Назначает и описывает тег <htmltag>, который позволяет размещать HTML-теги на странице из набора разрешенных тегов и атрибутов, предварительно заданных администратором. |
| Автор(ы) | Yaron Koren <yaron57@gmail.com> |
| Последняя версия | 0.4.1 (2025-04-23) |
| MediaWiki | 1.29+ |
| Изменения в БД | Нет |
| Лицензия | GNU General Public License 2.0 или позднее |
| Скачать | |
| Пример | A demonstration of the HTML Tags extension |
|
|
|
|
|
| Переведите расширение HTML Tags, если оно доступно на translatewiki.net | |
Расширение HTML Tags определяет тег <htmltag>, который может использоваться для отображения на вики-страницах тегов HTML‑кода, которые обычно запрещены MediaWiki-парсером.
HTML Tags was initially developed in order to allow support the use of LRMI (Learning Resource Metadata Initiative) tags within MediaWiki pages. See Implementing LRMI for how to implement such a thing using HTML Tags.
Another potential usage of HTML Tags is to embed microdata (especially the kind that can't be embedded already).
Вы можете ознакомиться с базовой демонстрацией этого расширения here.
Код и загрузка
You can download the HTML Tags code, in .zip format, here.
You can also download the code directly via Git from the MediaWiki source code repository. Из командной строки выполните следующее:
git clone https://gerrit.wikimedia.org/r/mediawiki/extensions/HTMLTags.git
Чтобы просмотреть код онлайн, включая историю версий для каждого файла, перейдите по ссылке here.
Установка
После того, как вы получили каталог "HTMLTags" (либо путем извлечения сжатого файла, либо путем загрузки с помощью Git), поместите этот каталог в папку "extensions" — она обычно расположена в корне установки системы и является основным местом для расширений в MediaWiki. Затем откройте файл "LocalSettings.php", находящийся в корневом каталоге установки MediaWiki, и добавьте в него следующую строку:
wfLoadExtension( 'HTMLTags' );
Затем вам нужно указать разрешенный набор HTML-тегов и разрешенный набор атрибутов для каждого из них, используя глобальную переменную $wgHTMLTagsAttributes.
For instance, to allow the <a> tag, and to allow only the attributes "href" and "class" for it, you would add the following to LocalSettings.php, after the inclusion of LocalSettings.php:
$wgHTMLTagsAttributes['a'] = [ 'href', 'class' ];
If you wanted to allow the tag <fieldset>, but without any allowed attributes, you would add the following:
$wgHTMLTagsAttributes['fieldset'] = [];
Использование
Once a set of allowed tags and attributes are specified, you can use <htmltag> to place those tags on the page.
You use the attribute "tagname" to specify the actual tag, and then add the other attributes exactly as you want them to appear.
The "contents" of the tag become the contents of <htmltag>.
For instance, if the above lines are added, and you want to add a link on some page using the <a> tag, you could add something to the page like:
<htmltag tagname="a" href="http://en.wikipedia.org/wiki/Antarctica" class="my-links">Read about Antarctica</htmltag>
This will add the following to the page's HTML source:
<a href="http://en.wikipedia.org/wiki/Antarctica" class="my-links">Read about Antarctica</a>
Calling <htmltag> with a tag name that is not allowed will result in an error message; calling it with an attribute that is not allowed will simply lead to the attribute being ignored.
See Implementing LRMI for a full description of how this extension, along with some templates, can be used to allow for easy adding of LRMI metadata to pages.
Авторы
HTML Tags was written by Yaron Koren, reachable at yaron57 -at- gmail.com.
This extension was funded by Creative Commons as part of the LRMI project.
История версий
The version history is:
- 0.1 - - Initial version
- 0.2 - - i18n messages moved into JSON files; various fixes
- 0.3 - - converted to extension registration
- 0.4 - - Removed PHP entry point; code improvements
- 0.4.1 - - Added support for MediaWiki 1.44
См. также
- Ограничения HTML - list of extensions that allow for the inclusion of raw HTML
- Extension:AnchorHandler – Allows inserting
<a>anchor tags into wikitext
| Это расширение включено в следующие вики-фермы/хостинги и/или пакеты: |
