扩展:Poem
| This code base is maintained by the Reader Experience team. Code review only for UBNs or security fixes. |
发行状态: 稳定版 |
|
|---|---|
| 实现 | 标签 |
| 描述 | 添加<poem>标签用于格式化诗歌 |
| 作者 | Nikola Smolenski留言 |
| 最新版本 | 持续更新 |
| MediaWiki | 1.25+ |
| 数据库更改 | 否 |
<poem> |
|
| 许可证 | Creative Commons Zero v1.0 Universal |
| 下載 | |
| 前往translatewiki.net翻譯Poem扩展 | |
| 問題 | 开启的任务 · 报告错误 |
Poem扩展允许在Wiki文本中轻松格式化诗歌或类似的文段。
一旦该扩展被开启,您可以将任何文本段落放在<poem></poem>标签内,这将导致以下效果:
- 所有的换行符都会保留,它们将会转换为
<br />标签 - 文本块包含在
<p>...</p>标签中(以及一个带有“poem”类的div标签) - 行首的冒号转换为1em的缩进
- 保留行首的空格,不再调用
<pre>标签
若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 |
Style
poem文本包裹在一个默认无样式的div中,但会继承传递给poem的任何style或class选项。
例如,虽然缩进文本可用于简单示例以防止填充并绘制漂亮的蓝色框,但在某些情况下可能难以阅读,因为长行不会被换行。 类似但效果稍佳的方法可采用:
<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" 选项
对超过两行的文本应用带有compact选项的<poem>标签时,每一行都会成为独立的段落。
(也就是说,它允许更简洁的标记,而非更紧凑的输出结果。)
随后使用<poem>标签与compact选项(中间最多有两个换行符),在文本之间只会产生单个换行,而不会形成新的段落。
因此,当应用于每段超过两行的文本时,除每段末行与下一段首行会合并为一个段落外,其余每行均自成独立段落。
| 输入 | 输出 | 输入 | 输出 |
|---|---|---|---|
<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! |
Problems and solutions
- Variables和ParserFunctions在
<poem>...</poem>容器内有效,但在<poem ... >标签本身内部无效;这样可以防止模板中出现类似<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.
| 输入(标签内正常,标签中不正常) | 输出 |
|---|---|
<poem style="{{{1|border: 1px solid Black;}}}">
One,
{{{2|Two.}}}
</poem>
|
One, |
| 输入(标签内和标签中都正常) | 输出 |
<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, |
安装
- 下载文件,并解压
Poem文件夹到extensions/目录中。
开发者和代码贡献人员应改从Git安装此扩展,输入:cd extensions/ git clone https://gerrit.wikimedia.org/r/mediawiki/extensions/Poem
- 請新增下列代码到您的LocalSettings.php文件的底部:
wfLoadExtension( 'Poem' );
完成 – 請导航至您的wiki上的Special:Version,以验证此扩展已成功安装。
使用Vagrant安装:
- 如果你有使用Vagrant,请通过
vagrant roles enable poem --provision安装
| 此扩展用于一个或多个维基媒体项目。 这可能意味着扩展足够稳定、运作足够良好,可以用在这样的高流量的网站上。 请在维基媒体的CommonSettings.php和InitialiseSettings.php配置文件中查找此扩展的名称以查看哪些网站安装了该扩展。 特定wiki上的已安装的扩展的完整列表位于Special:Version页面。 |
| 此扩展在以下wiki农场/托管网站和/或软件包中提供: |
- Extensions bundled with MediaWiki 1.21/zh
- Stable extensions/zh
- Tag extensions/zh
- ParserFirstCallInit extensions/zh
- Public domain licensed extensions/zh
- Extensions in Wikimedia version control/zh
- All extensions/zh
- Extensions used on Wikimedia/zh
- Extensions included in BlueSpice/zh
- Extensions included in Canasta/zh
- Extensions available as Debian packages/zh
- Extensions included in Fandom/zh
- Extensions included in Miraheze/zh
- Extensions included in MyWikis/zh
- Extensions included in ProWiki/zh
- Extensions included in semantic::core/zh
- Extensions included in ShoutWiki/zh
- Extensions included in Telepedia/zh
- Extensions included in wiki.gg/zh
