Extension:Poem
| This code base is maintained by the Reader Experience team. Code review only for UBNs or security fixes. |
リリースの状態: 安定 |
|
|---|---|
| 実装 | タグ |
| 説明 | Adds <poem> tag for poem formatting |
| 作者 | Nikola Smolenskiトーク |
| 最新バージョン | 継続的な更新 |
| MediaWiki | 1.25+ |
| データベースの変更 | いいえ |
<poem> |
|
| ライセンス | クリエイティブ・コモンズ CC0 1.0 全世界 |
| ダウンロード | |
| translatewiki.net で翻訳を利用できる場合は、Poem 拡張機能の翻訳にご協力ください | |
| 問題点 | 未解決のタスク · バグを報告 |
The Poem extension allows easy formatting of poems and similar material within ウィキテキスト.
Once the extension is enabled, you can put any block of text within <poem></poem> tags, which has the following effects:
- All newlines are preserved by converting them into
<br />tags
- The block of text is enclosed in
<p>...</p>tags (as well as a div of class "poem")
- Colons at the beginning of a line are converted into 1 em indentation
- Spaces at the beginning of a line are preserved and no longer invoke the
<pre>tag
The extension preserves wikilinks, bolding, etc. if they are present in the poem.
使用法
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.
例
| 入力テキスト | 出力 |
|---|---|
<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 |
インデント付きの例
| 入力テキスト | 出力 |
|---|---|
<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 |
スタイル
The poem text is wrapped in a div, which has no style by default; but inherits any style or class option passed to the poem.
例えば、インデントされたテキストは、簡単な例では塗りつぶし防止やきれいな青枠を描くために使用できますが、長い行は改行されないので、場合によっては読みにくくなります。 同様の効果が得られますが、やや劣ります。
<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" オプション
Applying the <poem> tag with the compact option to a text of more than two lines, every line becomes a separate paragraph.
(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, Three? |
<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, Three? |
<poem compact>
One,
Two.
Extra.
</poem>
<poem compact>
Three?
Four!
Extra.
</poem>
|
One,
Two. Three?
Four! |
問題点と解決策
- 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
#tagmagic word:{{#tag:poem| ... |style="{{{1}}}"}}.- NB: this would however seem not to work with the "compact" option.
| 入力(内はOK、外はNG) | 出力 |
|---|---|
<poem style="{{{1|border: 1px solid Black;}}}">
One,
{{{2|Two.}}}
</poem>
|
One, |
| 入力(内と外の両方OK) | 出力 |
<div style="{{{1|border: 1px solid Black;}}}">
<poem>
One,
{{{2|Two.}}}
</poem>
</div>
|
One, |
{{#tag:poem|
One,
{{{2|Two.}}}
|style="{{{1|border: 1px solid Black;}}}"
}}
|
One, |
インストール
- ダウンロードして、ファイルを
extensions/フォルダー内のPoemという名前のディレクトリ内に配置します。
開発者とコード寄稿者は、上記の代わりに以下を使用してGitからインストールします:cd extensions/ git clone https://gerrit.wikimedia.org/r/mediawiki/extensions/Poem
- 以下のコードを LocalSettings.php ファイルの末尾に追加します:
wfLoadExtension( 'Poem' );
完了 – ウィキの「Special:Version」に移動して、拡張機能が正しくインストールされたことを確認します。
Vagrantでのインストール:
- Vagrantを使用している場合は、
vagrant roles enable poem --provisionでインストールしてください。
| この拡張機能は 1 つ以上のウィキメディアのプロジェクトで使用されています。 これはおそらく、この拡張機能が安定していて高いトラフィックのウェブサイトでも十分に動作することを意味します。 この拡張機能がインストールされている場所を確認するには、ウィキメディアの設定ファイル CommonSettings.php および InitialiseSettings.php 内で、この拡張機能の名前を探してください。 特定のウィキにインストールされている拡張機能の完全な一覧は、そのウィキの Special:Version ページにあります。 |
| この拡張機能は以下のウィキ ファーム/ウィキ ホスト/パッケージに含まれています: |
- Extensions bundled with MediaWiki 1.21/ja
- Stable extensions/ja
- Tag extensions/ja
- ParserFirstCallInit extensions/ja
- Public domain licensed extensions/ja
- Extensions in Wikimedia version control/ja
- All extensions/ja
- Extensions used on Wikimedia/ja
- Extensions included in BlueSpice/ja
- Extensions included in Canasta/ja
- Extensions available as Debian packages/ja
- Extensions included in Fandom/ja
- Extensions included in Miraheze/ja
- Extensions included in MyWikis/ja
- Extensions included in ProWiki/ja
- Extensions included in semantic::core/ja
- Extensions included in ShoutWiki/ja
- Extensions included in Telepedia/ja
- Extensions included in wiki.gg/ja
