Help:扩展语法与格式示例:修订间差异

删除的内容 添加的内容
Maintenance​(留言 | 贡献)
小 修复格式示例并补充示例块
Maintenance script​(留言 | 贡献)
订正页面语法:避免嵌套 syntaxhighlight 示例提前闭合
 
(未显示4个用户的12个中间版本)
第1行:
本页汇总本站常用扩展语法的最小可用示例,便于快速复制与排错。
== 重定向 (Redirect) ==
 
== 重定向(Redirect) ==
* [[Redirect Test]]
用于将当前页面跳转到目标页面。
<syntaxhighlight lang="wikitext">
#REDIRECT [[目标页面]]
</syntaxhighlight>
 
== 代码高亮(SyntaxHighlight) ==
== timeline ==
<pre><nowiki><syntaxhighlight lang="bash">
php -v
mysql --version
</syntaxhighlight></nowiki></pre>
 
== 输入框(InputBox) ==
使用 EasyTimeline 或 <nowiki><timeline></nowiki> 语法展示事件。
<syntaxhighlight lang="wikitext">
<inputbox>
type=search
arialabel=Search the Wiki
</inputbox>
</syntaxhighlight>
 
== 时间线(EasyTimeline) ==
 
<syntaxhighlight lang="wikitext">
=== 苏联领导人 ===
<timeline>
# All measures are in pixels
 
ImageSize = width:160 height:550
PlotArea = left:50 right:0 bottom:10 top:10
AlignBars = justify
 
DateFormat = yyyy
Period = from:19172000 till:19912026
PlotData =
TimeAxis = orientation:vertical
bar:阶段 from:2000 till:2010 text:起步
ScaleMajor = unit:year increment:5 start:1920
bar:阶段 from:2010 till:2020 text:建设
 
bar:阶段 from:2020 till:2026 text:优化
# there is no automatic collision detection,
# so shift texts up or down manually to avoid overlap
 
Define $dx = 25 # shift text to right side of bar
 
PlotData=
bar:Leaders color:red width:25 mark:(line,white) align:left fontsize:S
 
from:start till:1924 shift:($dx,15) text:Vladimir~Ilyich~[[Special:MyLanguage/Lenin|Lenin]]
from:1924 till:1953 shift:($dx,5) text:[[Special:MyLanguage/Stalin|Josef~Stalin]]
from:1953 till:1964 shift:($dx,5) text:Nikita~[[Special:MyLanguage/Khrushchev|Khrushchev]]
from:1964 till:1982 shift:($dx,5) text:Leonid~[[Special:MyLanguage/Brezhnev|Brezhnev]]
from:1982 till:1984 shift:($dx,-12) text:Yuri~[[Special:MyLanguage/Andropov|Andropov]]
from:1984 till:1985 shift:($dx,4) text:Konstantin~[[Special:MyLanguage/Chernenko|Chernenko]] fontsize:XS
from:1985 till:end shift:($dx,10) text:Mikhail~[[Special:MyLanguage/Gorbachev|Gorbachev]]
</timeline>
</syntaxhighlight>
 
== 图片热区(ImageMap) ==
* https://www.mediawiki.org/wiki/Extension:EasyTimeline
<syntaxhighlight lang="wikitext">
== ImageMap ==
 
ImageMap 扩展允许在图片中定义可点区域,适合交互式说明。
 
 
=== 最后的晚餐 ===
<imagemap>
File:Example.jpg|thumb|center|400px|alt=Example image300px|示例图片(可点击区域)
rect 100 100 200150 200100 [[w帮助:Example|Example图片指南]]
rect 210 10 390 200 [[w:Help:Contents|Help]]
</imagemap>
</syntaxhighlight>
 
== 地图(Kartographer / mapframe) ==
=== 参见 ===
<syntaxhighlight lang="wikitext">
* https://www.mediawiki.org/wiki/Extension:ImageMap
<mapframe latitude="39.9042" longitude="116.4074" zoom="12" width="600" height="400" />
* https://meta.wikimedia.org/wiki/ImageMapEdit_Howto
</syntaxhighlight>
* https://www.familysearch.org/en/wiki/Help:Image_maps
说明:若地图不显示,请检查 Kartographer 与地图服务配置。
* https://commons.wikimedia.org/wiki/Commons:Image_map_resources/zh
* https://en.wikipedia.org/wiki/Category:Wikipedia_image_maps
 
== 公式与化学式(Math) ==
* https://meta.wikimedia.org/wiki/User:Dapete/ImageMapEdit#English
<syntaxhighlight lang="wikitext">
 
<math>x = \frac{-b \pm \sqrt{b^2 - 4ac}}{2a}</math>
* https://www.maschek.hu/imagemap/* https://www.image-maps.com/* https://summerstyle.github.io/summer/* https://summerstyle.github.io/summer/== inputbox ==
<chem>Hg^2+ ->[I-] HgI2</chem>
 
InputBox 扩展可以生成搜索或创建界面,便于用户快速跳转。
 
 
<inputbox>
type=search
arialabel=Search the Wiki
</inputbox>
 
* https://www.mediawiki.org/wiki/Extension:InputBox
 
== syntaxhighlight ==
 
高亮示例(bash):
<syntaxhighlight lang="bash">
php -v
mysql --version
</syntaxhighlight>
 
== mapframe乐谱(Score) ==
<syntaxhighlight lang="wikitext">
 
<score>
Kartographer 扩展根据 OpenStreetMap 提供交互地图,适合展示地理位置。
\relative c' { c d e f | g2 g }
 
 
=== 北京市地图 ===
<mapframe latitude="39.9042" longitude="116.4074" zoom="12" width="600" height="400">
</mapframe>
 
=== 参见 ===
* https://www.mediawiki.org/wiki/Extension:Kartographer
* https://www.openstreetmap.org/== math ==
 
Math 扩展支持 LaTeX 与化学符号,适合数学与科学内容展示。
 
 
=== 根的判别式(math) ===
<math>
x = \frac{-b \pm \sqrt{b^2 - 4ac}}{2a}
</math>
 
=== 化学式(chem) ===
<chem>Hg^2+ ->[I-] HgI2 ->[I-] {[Hg^{II}I4]^2-}</chem>
 
=== 参见 ===
* https://www.mediawiki.org/wiki/Extension:Math
 
== score ==
 
Score 扩展渲染乐谱,需配套 LilyPond 和 ffmpeg。
 
 
=== 义勇军进行曲 ===
<score vorbis="1">
 
\relative g' {
 
\key g \major \time 2/4
 
g8. b16 d8 d8 \bar "|" e4 d4 \bar "|" b8. g16 \times 2/3 {d'8 d d} \bar "|" b4 g4 \bar "|" \times 2/3 {d8 d d} \times 2/3 {d8 d d} \bar "|" g4 r8 d8 \bar "|" \break
 
g4. g8 \bar "|" g8. g16 d8 e16 fis16 \bar "|" g4 g4 \bar "|" r8 b8 g8 a16 b16 \bar "|" d4 d4 \bar "|" \break
 
b8. b16 g8. b16 \bar "|" d8. b16 a4 \bar "|" a2 \bar "|" e'4^> d4^> \bar "|" a4^> b4^> \bar "|" \break
 
d8^> b8^> r8 d8 \bar "|" b8 a16 b16 g4 \bar "|" b4 r4 \bar "|" d,8. e16 g8 g8 \bar "|" b8. b16 d8 d8 \bar "|" \break
 
a8 a16 a16 e4 \bar "|" a4. d,8 \bar "|" ^\< g4. g8 \bar "|" b4. b8 \! \bar "|" d2 \bar "|" \break
 
g,8. b16 d8 d8 \bar "|" e4 d4 \bar "|" b8. g16 \times 2/3 {d'8 d d} \bar "|" b8 r8 g8 r8 \bar "|" d4^> g4^> \bar "|" \break
 
b8. g16 \times 2/3 {d'8 d d} \bar "|" b8 r8 g8 r8 \bar "|" d4^> g4^> \bar "|" d4^> g4^> \bar "|" d4^> g4^> \bar "|" g4^> r4 \bar "|."
 
}
 
\addlyrics {
 
                                        起
 
来! 不 愿 做 奴 隶 的 人 们! 把 我 们 的 血 肉,
 
筑 成 我 们 新 的 长 城! 中 华 民 族
 
到 了 最 危 险 的 时 候, 每 个 人 被 迫 着 发 出
 
最 后 的 吼 声。 起 来! 起 来! 起 来!
 
我 们 万 众 一 心, 冒 着 敌 人 的 炮 火 前 进!
 
冒 着 敌 人 的 炮 火 前 进! 前 进! 前 进! 进!
 
}
 
</score>
</syntaxhighlight>
 
== 古埃及象形文字(WikiHiero) ==
=== 参见 ===
<syntaxhighlight lang="wikitext">
* [https://www.mediawiki.org/wiki/Extension:Score Extension:Score]
* [https://lilypond.org/doc/v2.24/Documentation/web/manuals LilyPond 2.24.4 手册]
* [https://zh.wikipedia.org/wiki/义勇军进行曲 义勇军进行曲 - 维基百科,自由的百科全书]
 
== hiero ==
 
WikiHiero 支持古埃及象形文字排版。
 
 
<hiero>A1</hiero>
</syntaxhighlight>
 
== PDF 预览(PdfHandler) ==
* https://www.mediawiki.org/wiki/Extension:WikiHiero
<syntaxhighlight lang="wikitext">
 
[[File:Example.pdf|thumb|500px|PDF 示例]]
== PdfHandler ==
</syntaxhighlight>
 
PdfHandler 扩展提供 PDF 预览与嵌入,适合文档展示。
 
 
[[File:EXCEL 2016 QUICK START GUIDE.PDF|thumb|500px|EXCEL 2016 QUICK START GUIDE.PDF]]
 
* https://www.mediawiki.org/wiki/Extension:PdfHandler
 
== TimedMediaHandler ==
 
TimedMediaHandler 和相关工具链支持音视频上传与预览。
 
== 音视频(TimedMediaHandler) ==
<syntaxhighlight lang="wikitext">
[[File:Example.ogg|thumb|音频示例]]
[[File:Example.webm|thumb|300px|视频示例]]
</syntaxhighlight>
 
== 使用建议 ==
[[File:Big Buck Bunny 4K.webm|300px|thumb|...]]
* 先在沙盒页验证语法,再发布到正式页面。
[[File:example.ogg|thumb|...]]
* 扩展渲染失败时,先检查扩展是否启用、依赖是否安装。
[[File:example.ogg|30px]]
* 对外链资源优先使用稳定来源。
[[File:example.ogg]]
 
== 参考 ==
* https://www.mediawiki.org/wiki/Extension:TimedMediaHandler
* https://www.mediawiki.org/wiki/Category:Extensions
* https://www.mediawiki.org/wiki/Help:Formatting
 
{{Template:站点帮助文档}}
[[Category:帮助文档]]