Jump to content

Расширение:Poem

From mediawiki.org
This page is a translated version of the page Extension:Poem and the translation is 71% complete.
Это расширение поставляется с MediaWiki 1.21 и выше, так что вам не нужно загружать его. Остальные инструкции по настройке всё равно необходимо соблюдать.
Справка по расширениям MediaWiki
Poem
Статус релиза: стабильно
Реализация Тег
Описание Добавляет тег ‎<poem> для форматирования стихотворения
Автор(ы) Nikola Smolenskiобсуждение
Последняя версия постоянное обновление
MediaWiki 1.25+
Изменения в БД Нет
Лицензия Creative Commons Zero v1.0 Universal
Скачать
‎<poem>
Переведите расширение Poem, если оно доступно на translatewiki.net
Проблемы Открытые задачи · Сообщить об ошибке

Расширение Poem позволяет легко форматировать стихотворения и аналогичный материал в Викитекст . После включения расширения вы можете поместить любой блок текста в теги ‎<poem>‎</poem> , которые оказывают следующее воздействие:

  • Все символы переноса на новую строку сохраняются путем преобразования их в теги ‎<br />
  • The block of text is enclosed in ‎<p>...‎</p> tags (as well as a div of class "poem")
  • Двоеточия (`:`) в начале строки автоматически преобразуются в отступ размером в 1 em
  • Пробелы в начале строки сохраняются и больше не вызывают ‎‎<pre> тег

Расширение сохраняет вики-ссылки, выделение жирным шрифтом и т. д., если они есть в стихотворении.

Применение

Wikisource provides the best usage model for this extension. It uses several templates and a module to create indentation, line numbers, etc. See Wikisource:Help:Poetry for an explanation of how this is used there. This requires Extension:Scribunto and Extension:TemplateStyles, which are both now bundled as standard.

Пример

Исходный Wiki-текст Результат
<poem>
In [[Wikipedia:Xanadu|Xanadu]] did Kubla Khan
A stately pleasure-dome decree:
Where Alph, the sacred river, ran
Through caverns measureless to man
Down to a sunless sea.

So twice five miles of fertile ground
With walls and towers were girdled round:
And there were gardens bright with sinuous rills,
Where blossomed many an incense-bearing tree;
And here were forests ancient as the hills,
Enfolding sunny spots of greenery.
</poem>

In Xanadu did Kubla Khan
A stately pleasure-dome decree:
Where Alph, the sacred river, ran
Through caverns measureless to man
Down to a sunless sea.

So twice five miles of fertile ground
With walls and towers were girdled round:
And there were gardens bright with sinuous rills,
Where blossomed many an incense-bearing tree;
And here were forests ancient as the hills,
Enfolding sunny spots of greenery.

Пример применения двоеточия (`:`) для получения отступа

Исходный Wiki-текст Результат
<poem>
Une terre au flanc maigre, âpre, avare, inclément
Où les vivants pensifs travaillent tristement, 
::Et qui donne à regret à cette race humaine
Un peu de pain pour tant de labeur et de peine ; 
::Des hommes durs, éclos sur ces sillons ingrats ; 
Des cités d’où s’en vont, en se tordant les bras, 
::La charité, la paix, la foi, sœurs vénérables ; 
L’orgueil chez les puissants et chez les misérables ; 
</poem>

Une terre au flanc maigre, âpre, avare, inclément
Où les vivants pensifs travaillent tristement,
Et qui donne à regret à cette race humaine
Un peu de pain pour tant de labeur et de peine ;
Des hommes durs, éclos sur ces sillons ingrats ;
Des cités d’où s’en vont, en se tordant les bras,
La charité, la paix, la foi, sœurs vénérables ;
L’orgueil chez les puissants et chez les misérables ;

Стиль

Текст стихотворения заключен в div, который по умолчанию не имеет стиля; но наследует любые параметры style или class, предназначенные для стилизации стихотворения.

For example, while indented text can be used for simple examples to prevent filling and draw a nice blue box, it can be hard to read in some cases, since long lines aren't broken. Аналогичный, но несколько лучший эффект можно получить при помощи:

<poem style="border: 2px solid #d6d2c5; color: var(--color-base, #202122); background-color: var(--background-color-warning-subtle, #fdf2d5); padding: 1em;">

Если применить это к приведённому выше примеру, получится следующее:

In Xanadu did Kubla Khan
A stately pleasure-dome decree:
Where Alph, the sacred river, ran
Through caverns measureless to man
Down to a sunless sea.

So twice five miles of fertile ground
With walls and towers were girdled round:
And there were gardens bright with sinuous rills,
Where blossomed many an incense-bearing tree;
And here were forests ancient as the hills,
Enfolding sunny spots of greenery.


"compact" вариант

Если применять тег‎ ‎<poem> с опцией compact для текста, состоящего более чем из двух строк, то при этом каждая строка становится отдельным параграфом. (That is to say, it allows for more compact markup, not for a more compact output.)

Subsequent use of the ‎<poem> tag with the compact option, with up to two newlines in between, gives just a single newline between texts, not a new paragraph.

Thus, applied to texts of more than two lines each, every line becomes a separate paragraph, except that the last line of each text and the first line of the next text are combined into one paragraph.

Ввод Результат Ввод Результат
<poem>
One,
Two.
</poem>
<poem>
Three?
Four!
</poem>

One,
Two.

Three?
Four!

<poem compact>
One,
Two.
</poem>
<poem compact>
Three?
Four!
</poem>
One,
Two.
Three?
Four!
Ввод Результат Ввод Результат
<poem>
One,
Two.
Extra.
</poem>
<poem>
Three?
Four!
Extra.
</poem>

One,
Two.
Extra.

Three?
Four!
Extra.

<poem compact>
One,
Two.
Extra.
</poem>
<poem compact>
Three?
Four!
Extra.
</poem>
One,

Two.

Extra.
Three?

Four!

Extra.

Problems and solutions

  • Variables and ParserFunctions do work inside the ‎<poem>...‎</poem> container, but NOT within the <poem ... > tag itself; this prevents templates with code such as <poem style="{{{1}}}">.
  • One workaround is to use <div style="{{{1}}}"><poem> ... </poem></div> instead.
  • Another way is to use the #tag magic word: {{#tag:poem| ... |style="{{{1}}}"}}.
    • NB: this would however seem not to work with the "compact" option.
Input (inside OK, within not OK) Output
<poem style="{{{1|border: 1px solid Black;}}}">
One,
{{{2|Two.}}}
</poem>

One,
Two.

Input (both inside and within OK) Результат
<div style="{{{1|border: 1px solid Black;}}}">
<poem>
One,
{{{2|Two.}}}
</poem>
</div>

One,
Two.

{{#tag:poem|
One,
{{{2|Two.}}}
|style="{{{1|border: 1px solid Black;}}}"
}}

One,
Two.


Установка

Это расширение поставляется с MediaWiki 1.21 и выше, так что вам не нужно загружать его. Остальные инструкции по настройке всё равно необходимо соблюдать.
  • Скачайте и распакуйте файл(ы) в папку с названием Poem в вашей папке extensions/.
    Вместо этого разработчикам и соавторам кода следует установить расширение из Git, используя:
    cd extensions/
    git clone https://gerrit.wikimedia.org/r/mediawiki/extensions/Poem
    
  • Добавьте следующий код в конце вашего файла LocalSettings.php :
    wfLoadExtension( 'Poem' );
    
  • Yes Готово – Перейдите на страницу Special:Version на своей вики, чтобы удостовериться в том, что расширение успешно установлено.


Установка Vagrant:

  • Если вы используете Vagrant , установите с помощью vagrant roles enable poem --provision