wangsisi 发表于 2011-1-2 15:36:23

Mediawiki中允许的html代码

允许的HTML以下HTML元素目前允许使用:       


[*]<b>
[*]<big>
[*]<blockquote>
[*]<br>
[*]<caption>
[*]<center>
[*]<cite>
[*]<code>
[*]<dd>
[*]<div>
[*]<dl>
[*]<dt>
[*]<em>
[*]<font>
[*]<h1>

[*]<h2>
[*]<h3>
[*]<h4>
[*]<h5>
[*]<h6>
[*]<hr>
[*]<i>
[*]<li>
[*]<ol>
[*]<p>
[*]<pre>
[*]<rb>
[*]<rp>
[*]<rt>
[*]<ruby>

[*]<s>
[*]<small>
[*]<strike>
[*]<strong>
[*]<sub>
[*]<sup>
[*]<table>
[*]<td>
[*]<th>
[*]<tr>
[*]<tt>
[*]<u>
[*]<ul>
[*]<var>
[*]<!-- ... -->

对很多HTML元素,维基标记反而更加方便,参见:Help:编辑。不过,HTML允许使用id,这样就变化无穷了。
接下来从wikipedia/phpwiki/newcodebase/OutputPage.php]OutputPage.php摘录的源代码附加的说明了什么属性是可用的。
        /* private */ function removeHTMLtags( $text )
        {
                wfProfileIn( "OutputPage::removeHTMLtags" );
                $htmlpairs = array( # Tags that must be closed
                        "b", "i", "u", "font", "big", "small", "sub", "sup", "h1",
                        "h2", "h3", "h4", "h5", "h6", "cite", "code", "em", "s",
                        "strike", "strong", "tt", "var", "div", "center",
                        "blockquote", "ol", "ul", "dl", "table", "caption", "pre",
                        "ruby", "rt" , "rb" , "rp"
                );
                $htmlsingle = array(
                        "br", "p", "hr", "li", "dt", "dd"
                );
                $htmlnest = array( # Tags that can be nested--??
                        "table", "tr", "td", "th", "div", "blockquote", "ol", "ul",
                        "dl", "font", "big", "small", "sub", "sup"
                );
                $tabletags = array( # Can only appear inside table
                        "td", "th", "tr"
                );

                $htmlsingle = array_merge( $tabletags, $htmlsingle );
                $htmlelements = array_merge( $htmlsingle, $htmlpairs );

                $htmlattrs = array( # Allowed attributes--no scripting, etc.
                        "title", "align", "lang", "dir", "width", "height",
                        "bgcolor", "clear", /* BR */ "noshade", /* HR */
                        "cite", /* BLOCKQUOTE, Q */ "size", "face", "color",
                        /* FONT */ "type", "start", "value", "compact",
                        /* For various lists, mostly deprecated but safe */
                        "summary", "width", "border", "frame", "rules",
                        "cellspacing", "cellpadding", "valign", "char",
                        "charoff", "colgroup", "col", "span", "abbr", "axis",
                        "headers", "scope", "rowspan", "colspan", /* Tables */
                        "id", "class", "name", "style" /* For CSS */
                );

比如元素“a”在维基代码中被禁止使用,因此
<a href="http://meta.wikimedia.org/wiki/Main_Page">Main Page</a>
生成HTML代码
&lt;a href="http://meta.wikimedia.org/wiki/Main_Page"&gt;Main Page&lt;/a&gt;
是文字而不是链接。
Span<span>,通用内联文字容器,目前可以默认使用。span可以使用id,class,style:
<span style="color:red">style</span>

<span id="randomfooid">id</span>

<span class="importantmessage">class</span>

生成:
styleidclass注意到,更多修饰符可被运用。比如,<strong>(可以加上class、id、style)用于显示强调文字。比如,上例更好的表达就是
<em style="color:red;font-style:normal">style</em>
style这不仅仅吸引用户的注意力,还可以提醒使用非可视化浏览器或有视力障碍的用户。
Font注意,此元素不推荐使用,而wiki%E4%B8%AD%E5%85%81%E8%AE%B8%E7%9A%84html%E4%BB%A3%E7%A0%81#span]<span>是替代。对于一些属性,比如颜色,只能这么用:
<font color="red">红</font>字。
生成
红字。
Div例如让文字是“red”类,可以这么运用:
<div class="red">样例</div>
生成样例
,如果有“red”类则是红的。.red {color:red}
可使用。

梦露 发表于 2011-6-30 11:00:54

顶一个,正想总结这些内容呢!这回省事了!
页: [1]
查看完整版本: Mediawiki中允许的html代码

美国主机评测网站