模板:Markup

维基百科,自由的百科全书
文档图示 模板文档[查看] [编辑] [历史] [清除缓存]

说明[编辑]

{{Markup}}可以将代码和其效果显示在同一行里。

使用方法[编辑]

参数:

  • 参数1:第1行第1格的内容
  • 参数2:第1行第2格的内容
如此类推,直到
  • 参数39:第20行第1格的内容
  • 参数40:第20行第2格的内容
  • t1:左面直栏的标题,预设为“代码
  • t2:右面直栏的标题,预设为“效果
  • title标题:表格标题,预设为置空
  • notitle无标题:赋值时会隐藏表格和直栏的标题
  • margin:表格左边的空位大小,单位为em

整个“代码”栏已事先用<pre>格式化,内容会保留断行和空格,同时亦会因应单元格的大小自动换行。通常最好用<nowiki>包围着“代码”栏里的内容,这样子便会显示代码本身。技术上无法将此功能添加进本模板内。

相反地,在“效果”一栏里的内容通常直接复制自“代码”栏,但并不以<nowiki>包围着。不过在这些情况下则不一定:

  • 假如第一行含有必须断行后才生效的维基代码,例如“#”、“*”、“;”,应在第一行之前使用{{crlf2}}。见以下例子。
  • 诸如==的标题代码会出现在页面目录里;要避免的话应使用{{fake heading}}
  • 使用{{reflist}}但没有指定其他参数时,用{{reflist|close}}确保参考资料列表已关闭。
  • 有些模板会将页面放入维护分类中,但这通常不是想要的效果:
  • 有些模板可能有检查错误机制,会将页面放入维护分类中。可以的话应当防止分类:
    • 引文格式1系列模板可以用|template doc demo=true参数,防止将页面放入该维护分类中。

技术限制[编辑]

如果不用<nowiki>包围着代码栏的内容,而里面又有任何模板代码的话,这些代码统统都会展开。

以下例子展示{{tl|tag}}的代码:

效果 本来应显示为
{{[[Template:tag|tag]]}}

{{tl|tag}}

代码栏里的HTML字符编码也会被解析:

用“nowiki”包围着的代码显示为 代码本来应显示为
 –

&nbsp;&ndash;

要避免出现这种情况的话,可以用“&amp;”代替“&”,这样子“&amp;nbsp;”会显示为“&nbsp;”。

范例[编辑]

简单示例:

代码 效果
'''粗體文字'''

粗体文字

''斜體文字''

斜体文字

<del>劃線文字</del>

划线文字

复杂示例:注意{{markup}}的第二个参数用了{{fake heading}}{{fake citation needed}}

代码 效果
The quick brown fox jumps over the lazy dog.{{#tag:ref|這是腳註。<ref>這是腳註的參考資料。</ref>|group=nb}} The cow jumped over the moon.{{fact}}

==註釋==
{{reflist|group=nb}}

==參考資料==
{{reflist}}

The quick brown fox jumps over the lazy dog.[nb 1] The cow jumped over the moon.[来源请求]

注释
  1. ^ 这是脚注。[1]
参考资料
  1. ^ 这是脚注的参考资料。

使用多行:

代码 效果
The quick brown fox jumps over the lazy dog.

The quick brown fox jumps over the lazy dog.

The quick brown fox jumps over the lazy dog.

The quick brown fox jumps over the lazy dog.

The quick brown fox jumps over the lazy dog.

The quick brown fox jumps over the lazy dog.

The quick brown fox jumps over the lazy dog.

The quick brown fox jumps over the lazy dog.

The quick brown fox jumps over the lazy dog.

The quick brown fox jumps over the lazy dog.

使用标题:

Foxes and dogs
代码 效果
The quick brown fox jumps over the lazy dog.

The quick brown fox jumps over the lazy dog.

用{{code}}包围着模板时,会显示所生成的HTML代码:

代码 效果
{{cite book |last=White |first=T. H. |title=The Book of Merlyn |year=1977}}

White, T. H. The Book of Merlyn. 1977. 

{{code|{{cite book |last=White |first=T. H. |title=The Book of Merlyn |year=1977}}}}

<cite class="citation book">White, T. H. The Book of Merlyn. 1977.</cite><span title="ctx_ver=Z39.88-2004&rfr_id=info%3Asid%2Fzh.wikipedia.org%3ATemplate%3AMarkup&rft.aufirst=T.+H.&rft.aulast=White&rft.btitle=The+Book+of+Merlyn&rft.date=1977&rft.genre=book&rft_val_fmt=info%3Aofi%2Ffmt%3Akev%3Amtx%3Abook" class="Z3988"><span style="display:none;">&nbsp;</span></span>

参见[编辑]

Template:Markup templates see also