Jump to content

扩展:Poem

From mediawiki.org
This page is a translated version of the page Extension:Poem and the translation is 64% complete.
This extension comes with MediaWiki 1.21 and above. 因此您无需另外下载。 但是,您仍需遵循此页面提供的其他使用说明。
MediaWiki扩展手册
Poem
发行状态: 稳定版
实现 标签
描述 添加‎<poem>标签用于格式化诗歌
作者 Nikola Smolenski留言
最新版本 持续更新
MediaWiki 1.25+
数据库更改
许可协议 知识共享零 v1.0 通用
下載
‎<poem>
季度下載量 47 (Ranked 90th)
正在使用的公开wiki数 10,039 (Ranked 12th)
前往translatewiki.net翻譯Poem扩展
問題 开启的任务 · 报告错误

Poem扩展允许在Wiki文本中轻松格式化诗歌或类似的文段。 一旦该扩展被开启,您可以将任何文本段落放在‎<poem>‎</poem>标签内,这将导致以下效果:

  • 所有的换行符都会保留,它们将会转换为‎<br />标签
  • 文本块包含在‎<p>...‎</p>标签中(以及一个带有“poem”类的div标签)
  • 行首的冒号转换为1em的缩进
  • 保留行首的空格,不再调用‎<pre>标签

The extension preserves wikilinks, bolding, etc. if they are present in the poem.

用法

示例

输入文本 输出
<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.

带有缩进的例子

输入文本 输出
<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 ;

Style

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.

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. A similar, but somewhat better effect can be obtained with:

<poem style="border: 2px solid #d6d2c5; background-color: #f9f4e6; padding: 1em;">

When applied to the above example, the result is as follows:

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" option

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,
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.
输入(标签内正常,标签中不正常) 输出
<poem style="{{{1|border: 1px solid Black;}}}">
One,
{{{2|Two.}}}
</poem>

One,
Two.

输入(标签内和标签中都正常) 输出
<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.


安裝

  • 下载文件,并将解压后的Poem文件夹移动到extensions/目录中。
    开发者和代码贡献人员应从Git安装扩展,输入:cd extensions/
    git clone https://gerrit.wikimedia.org/r/mediawiki/extensions/Poem
  • 将下列代码放置在您的LocalSettings.php 的底部:
    wfLoadExtension( 'Poem' );
    
  • Yes 完成 – 在您的wiki上导航至Special:Version,以验证已成功安装扩展。


使用Vagrant安装:

  • 如果使用Vagrant ,请通过vagrant roles enable poem --provision安装