跳转到内容

用户:XComhghall/IT

维基百科,自由的百科全书
主页 用户页留言 讨论页简介 关于在下基本 编辑、社群、方针进阶 技术、膜板、膜术字索引 用户子页面刷新 清除快取

进阶的 Wikitext、膜板、膜术字相关的一些基本知识,与我对 MediaWiki,资讯科技其他语言、领域、方面仅有的一点了解。

表格

[编辑]
参见:EN: Help: Table

并列

[编辑]
<div style = 'display: inline-table'>
. . . Table . . .
</div>
<div style = 'display: inline-table'>
. . . Table . . .
</div>

若 1. 前表 ‎</div> 与后表 ‎<div> 间无空格或字符,且 2.1. 无 margin,或 2.2. class = wikitable,则二表紧贴,无间距,相邻的边看似宽度为二者之和。

‎</div>‎<div> 间空一格或换行,则二表间距增加。

Border

[编辑]

以下表格的代码为

<div style = 'display: inline-table'>
{| border = 1 style = 'border-style: solid; border-color: #000 #03c #0c3 #c30; margin: 1px'
| text || text
|-
| text || text
|}</div>
. . .
{| border = 1 style = 'border-color: #000 #03c #0c3 #c30; margin: 1px'
. . .
{| border = 1 style = 'border-style: solid; border-color: #000 #03c #0c3 #c30; border-collapse: collapse; margin: 3px'
. . .
{| border = 1 style = 'border-color: #000 #03c #0c3 #c30; border-collapse: collapse; margin: 3px'
. . .

三个方形的颜色分别为 #C30, #0C3, #03C。

表格内,格的左边,颜色较暗。

省略 border-style: solid 时,外侧右、下,或右、下、左(border-collapse: collapse)边,颜色较暗。

text text
text text
text text
text text
text text
text text
text text
text text

border-width: 5px 属性仅定义外侧边框的宽度。

text text
text text
text text
text text

Wikitable

[编辑]

Wikitable 不能修改默认的全局边框形式,但可以修改单独格的边框形式。Every cell has 4 borders (top, right, bottom, and left). There are 2 borders between adjacent cells. So to remove the border between 2 cells, it is necessary to remove the corresponding borders of both cells.

模板

[编辑]

编写

[编辑]

In a parameter {{{x|default}}}, x ignores spaces, default is sensitive to spaces.

'{{{1|default}}}' → 'default'.

'{{{ 1 |default}}}' → 'default'.

'{{{1| default }}}' → ' default '.

' {{{1| default }}} ' → ' default '.

嵌入

[编辑]

transclusion

{{template | xxx || xxx}} 定义 {{{2|default}}} 为空,不产生默认值 default

巫术字

[编辑]

magic word

{{#if:1|1|0}} = {{ #if: 1 | 1 | 0}}

替换

[编辑]

substitution

例:T: Trim

若键入 {{safesubst: #if: 1 | {{{1|}}}}},发布后,仅保存 {{{1|}}}

the <includeonly>...</includeonly> keeps it from being expanded. Other techniques are to use something like safes<noinclude></noinclude>ubst: or the version that I replaced with that edit. The problem with using {{{|safesubst:}}} is that if someone uses a bare equal sign, it won't work properly.

Plastikspork, 2021-10-08 19:32 (UTC)

可写作 <includeonly>{{safesubst: #if: 1 | {{{1|}}}}}</includeonly>{{<includeonly>safesubst:</includeonly> #if: 1 | {{{1|}}}}}

符号

[编辑]
  • 管道符,竖线,|
  • 等号,=

等符号,如在模板、巫术字(magic word)等参数中使用,可能导致语法分析错误。若需要,建议以 HTML 代码代替。但若符号需被理解为 Wikitext,如模板中 Wiki 表格的定界、分隔符,||,须以模板代替

  • Pipes, vertical bars, |,
  • Equal signs, =,

and other characters, when used in the parameters of templates or magic words, may cause errors when parsing. If necessary, it is recommended to use HTML code to replace a character. If a character needs to be interpreted as wikitext, i.e., the table cell separator, delimiter, ||, it must be escaped by a template.

HTML

[编辑]

Character Entities

&amp; &#38; &

&lt; &#60; <

&gt; &#62; >

&#91; [

&#93; ]

&#61; =

&#124; |

&#63; ?

&nbsp; non-breaking space

&#32; regular space

Help:如何输入间隔号

代码

[编辑]

空一格,执行模板,功能与 <code> 相似,以 <syntaxhighlight><pre> 形式显示。

{{markup}} 好像展开但不执行模板,以 <syntaxhighlight><pre> 形式显示。

Code 标签

[编辑]
代码 效果
<code> text </code> =
text =
<code> text </code><nowiki /> =
text =
<code> text </code><nowiki> </nowiki>=
text =
<code> text </code>-{}- =
text =
<code> text </code>-{ }-=
text =
<code> text </code>&#32;=
text =
<code> text </code>&nbsp;=
text  =

SyntaxHighlight 标签

[编辑]

mw:Extension:SyntaxHighlight

<syntaxhighlight> . . .

<syntaxhighlight inline> . . .

<syntaxhighlight enclose = 'none'> . . .

<syntaxhighlight enclose = 'paragraph'> . . .

The enclose attribute is deprecated.

Unlike the ‎<pre> and ‎<code> tags, HTML character entities such as &nbsp; need not (and should not) have the & character escaped as &amp;. Like the ‎<pre> tag but unlike the ‎<code> tag, tags within the range (other than its own closing tag) need not have the < symbol escaped as &lt;<, nor does Wikitext need to be escaped with a ‎<nowiki> tag.

Furthermore, while ‎<pre> assumes tab stops every 8 characters and renders tabs using actual spaces when the rendered text is copied, ‎<syntaxhighlight> uses 4-space tab stops (except Internet Explorer, which uses 8) and preserves the tab characters in the rendered text; the latter may be changed using an enclosing ‎<span style = '-moz-tab-size: nn; -o-tab-size: nn; tab-size: nn'> tag (not ‎<div>, and not using its own style attribute). The -moz- prefix is required for Firefox (from version 4.0), and the -o- prefix is required for Opera (from version 10.60 to version 15).[1] Note that the wiki editing box assumes 8-space tabs.) This applies only to actual saved pages; previews generated through an edit box or Special:ExpandTemplates may differ.

<syntaxhighlight lang = html> . . .

Languages: html, css, python, php, xml, moin, cpp.

Wikitext, mediawiki: html+handlebars or moin.

The line attribute enables line numbers.

Line breaks can occur at any space between the opening and closing tags, i.e., style = 'white-space: -moz-pre-wrap; white-space: -pre-wrap; white-space: -o-pre-wrap; white-space: pre-wrap; word-wrap: break-word'. The source code can be marked non-breakable with class = 'nowrap' (on those wikis that support it) or style = 'white-space: nowrap'.

Source 标签

[编辑]

In older versions (before MediaWiki 1.16), the SyntaxHighlight extension used the tag ‎<source>. This is still supported, but is deprecated. ‎<syntaxhighlight> should be used instead.

‎<code class = 'mw-highlight'> . . . ‎</code>

[编辑]

若页面没有使用 ‎<syntaxhighlight> . . . ‎</syntaxhighlight>,需以

{{#tag: syntaxhighlight || lang = text | class = wds-is-hidden | style = display: none}}
{{#tag: syntaxhighlight || lang = text | class = wds-is-hidden}}

{{#tag: syntaxhighlight || lang = text | style = display: none}}

启用语法标示扩展,否则 ‎<code class = 'mw-highlight'> . . . ‎</code> 不会标示语法。

音乐

[编辑]

en: Help: Score

乐谱功能之前下线了很长时间,现在在夏文、English Wikipedia 都能用。

{ a'4. f''8 e''4. d''8 c''1 \bar "|." }


{ \set Score.tempoHideNote = ##t \tempo 4 = 80 \set Staff.midiInstrument = #"trumpet" \partial 4 c''8. b'16
a'4. f''8 e''4. d''8
c''2. \bar "|." }


{ \new Staff \with {midiInstrument = #"string ensemble 1"} << { \set Score.tempoHideNote = ##t \tempo 4 = 80 \language "english" \partial 4 <d' e' g' a' c''>8. <d' e' fs' gs' b'>16
<b c' e' g' a'>4 <f' af' b' d'' f''>4 <e' fs' a' c'' e''>4 <d' f' af' b' d''>4
<d' e' g' a' c''>2. \hideNotes r4 \bar "|." }
\new Staff \with {midiInstrument = #"string ensemble 1"} { \clef bass \partial 4 c,8. e,16
a,4 af,4 fs,4 f,4
c,2. \hideNotes r4 }
>> }


{ \new StaffGroup \with {midiInstrument = #"string ensemble 1"} <<
\new Staff { \set Score.tempoHideNote = ##t \tempo 4 = 80 \language "english" \partial 4 <d' e' g' a' c''>8. <d' e' fs' gs' b'>16
<b c' e' g' a'>4 <f' af' b' d'' f''>4 <e' fs' a' c'' e''>4 <d' f' af' b' d''>4
<d' e' g' a' c''>2. \hideNotes r4 \bar "|." }
\new Staff { \clef bass \partial 4 c,8. e,16
a,4 af,4 fs,4 f,4
c,2. \hideNotes r4 }
>> }

歌词仅限 English,不支持夏文。

{ \new PianoStaff <<
 \new Staff <<
  \new Voice { \set Score.tempoHideNote = ##t \tempo 4 = 120 \time 6/8 \stemDown \partial 8 c''8 <d' e' g' a' c''>2~ <d' e' g' a' c''>8  <fis' gis' b' d'' e''>8 <g' a' b' c'' e''>4 <fis' gis' a' c'' dis''>8 <g' a' b' c'' e''>4 <g' a' cis'' e'' f''>8 <g' a' c'' e'' g''>2~ <g' a' c'' e'' g''>8 <g' a' c'' e''>8 <f' g' a'>4. <c' dis' fis' a'>4 <d' e' g'>8 <d' e' g' a' c''>2~ <d' e' g' a' c''>8 \hideNotes r8 \bar "|." }
  \new Voice { \stemUp s8 s1. s2. d''4 c''8 }>>
 \new Staff { \clef bass s8 c,4. c4 e,8 a,4. a4 cis8 d4. e4 f8 <g, g>4. <aes, aes>4 <bes, bes>8 <c, c>2~ <c, c>8 \hideNotes r8 }
>> }

2021-08-24 作品。

HTML

[编辑]

<p> are paragraph tags and defines the format of the paragraph.

EN: Div and span tags.

‎<br>, ‎<br/>, or ‎<br />?

In HTML, use ‎<br>.

In XHTML, use ‎<br/> or ‎<br>‎</br>, according to the XHTML guidelines.

For XHTML documents to render on existing HTML user agents, use ‎<br />, according to the W3C recommendation. According to the recommendation, a space should be before the trailing / and > of empty elements.

<ref>[https://www.tutorialspoint.com/What-is-the-correct-way-of-using-br-br-or-br-in-HTML]</ref>

形式

[编辑]

外语

[编辑]

应将粗体与斜体标示于 {{lang}} 模板之外。

Div

[编辑]
<div style="clear: both; overflow: auto; border: 1px solid gray; padding: 4px; text-align: left; background: #FFFFE7;">text
text
text</div>
text

text

text

适用于移动自其他页面的讨论。

标签

[编辑]

W3C 鼓励以 ‎<span> 取代 ‎<font> 标签,但 Wikipedia:签名#长度(态度指引)认为,在浏览器仍然兼容的情况下,可以使用 ‎<font>

字体

[编辑]

Bold: <b>, <strong> (less preferable). Italics: <i>, <b>. Underline: <u>. Strikethrough: <s>, <del>, <strike>.

‎<strike> is deprecated in HTML 4 and XHTML 1, and obsoleted in HTML5. If semantically appropriate, i.e., if it represents deleted content, use ‎<del>.

<tt>: monospace. Not supported in HTML5.

style = 'font-weight: normal'

Values: lighter, bold, bolder. From light to bold: 100 [thin], 200, 300, 400 [normal] . . . 700 [bold], 800, 900 [heavy].

若选择 lighterbolder,则以主(parent)元素为基准,选 thin, normal, bold, heavy 中更细或更粗,最近的一个字重。

style = 'font-size: medium'

Values: xx-small, x-small, small, large, x-large, xx-large, smaller, larger, nnpx, nn%.

font-family: "Times New Roman", Times, serif, font-family: Arial, Helvetica, sans-serif.

The font-family property specifies the font for an element.

The font-family property can hold several font names as a "fallback" system. If the browser does not support the first font, it tries the next font.

Align

[编辑]

style = 'text-allign: center'

Values: left, right, center, justify.

align = 'center'

Values: left, right, center, middle, justify.

Deprecated in HTML5, and does not work well in MediaWiki software. For example, it will not override the left alignment of tables via class = 'wikitable'.

align = 'vertical-align: middle'

Values: top, middle, bottom. See more: CSS vertical-align Property

Border

[编辑]
style = "border-width: 1px; border-style: solid none none none; border-color: blue"

元素

[编辑]

文字之外,图片、表格等元素的一些属性。

float,浮动 Text can appear on the sides of the element.

{{clear}}

不同浏览器

[编辑]

{{column-width}}-moz-, -webkit- 等前缀适用于不同的浏览器。

CSS

[编辑]

我只知道如何用 CSS 文件定义文字显示的形式,CSS 应该也可以定义图片的形式与其他属性。

在不同设备上:@media (pointer: fine):游标位置精确,定位装置完备。@media (pointer: coarse):游标位置粗略。(pointer: none):无游标。

xxx defines the tag <xxx>. .xxx defines the class = 'xxx'. #xxx defines the id = 'xxx'.

.a:hover { . . . } 定义游标置于目标(文字或段落等)上时目标的形式。.a::selection { . . . }:目标被选中(刮刮乐)。.a:active { . . . }:目标被点击或长按 [?],由 touchstart 事件触发。.a:focus { . . . } 功能未知。

然而 Wikipedia 没有在必要的元素上监听 touchstart 事件,导致 :active 也不能使用,只能再退用 :hover

在括弧中定义形式,例,color: #ffffff; background: #404040; background: rgba(0, 0, 0, 0.75); transition: color 2s linear

!important 会导致使用者 CSS 无法覆盖。

transition 不适用于 .a::selection{transition: width 2s linear 1s} = {transition-property: width; transition-duration: 2s; transition-timing-function: linear; transition-delay: 1s}transition-property 可以省略,应该默认全部渐变。

Transition timing functions:

  • ease — Default. Specifies a transition effect with a slow start, then fast, then end slowly.
  • linear — Specifies a transition effect with the same speed from start to end.
  • ease-in — Specifies a transition effect with a slow start.
  • ease-out — Specifies a transition effect with a slow end.
  • ease-in-out — Specifies a transition effect with a slow start and end.
  • cubic-bezier(n,n,n,n) — Lets you define your own values in a cubic-bezier function.

transition: transform 2s

Read more: CSS Transitions

隐藏

[编辑]
代码 效果
完全看不見:<span style = "color: transparent">隱藏文字。</span>

完全看不见:隐藏文字。

{{block}}

.block {
	color: transparent;
	background: #333333;
	background: rgba(0, 0, 0, 0.8)
}

.block a,
.block .new {
	color: transparent
}

.block:hover,
.block:active,
.block::selection {
	color: #ffffff;
	transition: 0.15s linear
}

.block:hover a,
.block:active a,
.block a::selection {
	color: #88bbff;
	transition: 0.15s linear
}

.block:hover .new,
.block:active .new,
.block .new::selection {
	color: #ffbb88;
	transition: 0.15s linear
}

.block:hover a:当光标置于 class = 'block'‎<a> 目标上时,其他 class = 'block' 的目标也会被触发(颜色变为 #ffffff)。反之亦同。

.block a:hover:当光标置于其他 class = 'block' 的目标上时, class = 'block'‎<a> 目标不会被触发。

a:hover .block 为错误语法。

.block::selection aa::selection .block 均为错误语法。

更多:我更改的 Template:Block/sandbox/styles.cssTemplate:Block/styles.css 备份

模糊

[编辑]

萌娘百科 § Template: 文字模糊

看得我眼花。

MediaWiki

[编辑]

扩充

[编辑]

extension

MW: Extension: TemplateStyles Special: ChangeContentModel

首页

[编辑]

Miraheze 上的多数 wiki,如已删百科,首页都会显示“已删百科: 首页”这样的标题。

夏文 Wikipedia 如何隐藏首页的标题?

W: MediaWiki: Vector.css

W: MediaWiki: Monobook.css[2]

小工具

[编辑]

gadget

Special: Gadgets 所有小工具的列表。

MediaWiki: Gadgets-definition 所有小工具的代码页。

MediaWiki: Gadget-section-edit Edit 类小工具的类别、章节名称,“编辑工具”。

MediaWiki: Gadget-large-font 使用者设定中,large font 小工具的描述。

MediaWiki: Gadget-large-font.css[2]

参考资料

[编辑]