<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="zh-Hans-CN">
	<id>https://www.wikiw.cn/index.php?action=history&amp;feed=atom&amp;title=%E6%A8%A1%E5%9D%97%3AHatnote%2Fdoc</id>
	<title>模块:Hatnote/doc - 版本历史</title>
	<link rel="self" type="application/atom+xml" href="https://www.wikiw.cn/index.php?action=history&amp;feed=atom&amp;title=%E6%A8%A1%E5%9D%97%3AHatnote%2Fdoc"/>
	<link rel="alternate" type="text/html" href="https://www.wikiw.cn/index.php?title=%E6%A8%A1%E5%9D%97:Hatnote/doc&amp;action=history"/>
	<updated>2026-04-08T16:34:09Z</updated>
	<subtitle>本wiki上该页面的版本历史</subtitle>
	<generator>MediaWiki 1.44.0</generator>
	<entry>
		<id>https://www.wikiw.cn/index.php?title=%E6%A8%A1%E5%9D%97:Hatnote/doc&amp;diff=2360&amp;oldid=prev</id>
		<title>imported&gt;Dabao qian：​/* 格式页面 */ // Edit via Wikiplus</title>
		<link rel="alternate" type="text/html" href="https://www.wikiw.cn/index.php?title=%E6%A8%A1%E5%9D%97:Hatnote/doc&amp;diff=2360&amp;oldid=prev"/>
		<updated>2024-10-31T05:51:10Z</updated>

		<summary type="html">&lt;p&gt;&lt;span class=&quot;autocomment&quot;&gt;格式页面：​&lt;/span&gt; // Edit via Wikiplus&lt;/p&gt;
&lt;p&gt;&lt;b&gt;新页面&lt;/b&gt;&lt;/p&gt;&lt;div&gt;{{high-risk|162777}}&lt;br /&gt;
{{module rating|protected}}&lt;br /&gt;
&lt;br /&gt;
This is a meta-module that provides various functions for making [[Wikipedia:Hatnote|hatnotes]]. It implements the {{tl|hatnote}} template, for use in hatnotes at the top of pages, and the {{tl|format link}} template, which is used to format a wikilink for use in hatnotes. It also contains a number of helper functions for use in other Lua hatnote modules.&lt;br /&gt;
&lt;br /&gt;
== 通过wikitext使用 ==&lt;br /&gt;
&lt;br /&gt;
The functions in this module cannot be used directly from #invoke, and must be used through templates instead. Please see [[Template:Hatnote]] and [[Template:Format link]] for documentation.&lt;br /&gt;
&lt;br /&gt;
== 通过其他Lua模块调用==&lt;br /&gt;
&lt;br /&gt;
To load this module from another Lua module, use the following code.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;&lt;br /&gt;
local mHatnote = require(&amp;#039;Module:Hatnote&amp;#039;)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
You can then use the functions as documented below.&lt;br /&gt;
&lt;br /&gt;
=== 题注 ===&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;&lt;br /&gt;
mHatnote._hatnote(s, options)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Formats the string &amp;lt;var&amp;gt;s&amp;lt;/var&amp;gt; as a hatnote. This encloses &amp;lt;var&amp;gt;s&amp;lt;/var&amp;gt; in the tags {{tag|div|params=class=&amp;quot;hatnote&amp;quot;}}. Options are provided in the &amp;lt;var&amp;gt;options&amp;lt;/var&amp;gt; table. Options include:&lt;br /&gt;
* &amp;lt;var&amp;gt;options.extraclasses&amp;lt;/var&amp;gt; - a string of extra classes to provide&lt;br /&gt;
* &amp;lt;var&amp;gt;options.selfref&amp;lt;/var&amp;gt; - if this is not nil or false, adds the class &amp;quot;selfref&amp;quot;, used to denote self-references to Wikipedia (see [[Template:Selfref]]))&lt;br /&gt;
The CSS of the hatnote class is defined in [[MediaWiki:Common.css]].&lt;br /&gt;
&lt;br /&gt;
; 例甲&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;&lt;br /&gt;
mHatnote._hatnote(&amp;#039;This is a hatnote.&amp;#039;)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Produces:&lt;br /&gt;
{{tag|div|content=This is a hatnote.|params=class=&amp;quot;hatnote&amp;quot;}}&lt;br /&gt;
&lt;br /&gt;
Displays as:&lt;br /&gt;
{{hatnote|This is a hatnote.}}&lt;br /&gt;
&lt;br /&gt;
; 例乙&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;&lt;br /&gt;
mHatnote._hatnote(&amp;#039;This is a hatnote.&amp;#039;, {extraclasses = &amp;#039;boilerplate seealso&amp;#039;, selfref = true})&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Produces:&lt;br /&gt;
{{tag|div|content=This is a hatnote.|params=class=&amp;quot;hatnote boilerplate seealso selfref&amp;quot;}}&lt;br /&gt;
&lt;br /&gt;
Displayed as:&lt;br /&gt;
{{hatnote|This is a hatnote.|extraclasses=boilerplate seealso|selfref=true}}&lt;br /&gt;
&lt;br /&gt;
=== 查找名字空间id ===&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;&lt;br /&gt;
mHatnote.findNamespaceId(link, removeColon)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Finds the [[WP:NS|namespace id]] of the string &amp;lt;var&amp;gt;link&amp;lt;/var&amp;gt;, which should be a valid page name, with or without the section name. This function will not work if the page name is enclosed with square brackets. When trying to parse the namespace name, colons are removed from the start of the link by default. This is helpful if users have specified colons when they are not strictly necessary. If you do not need to check for initial colons, set &amp;lt;var&amp;gt;removeColon&amp;lt;/var&amp;gt; to false.&lt;br /&gt;
&lt;br /&gt;
;Examples:&lt;br /&gt;
: {{code|mHatnote.findNamespaceId(&amp;#039;Lion&amp;#039;)|lua}} &amp;amp;rarr; 0&lt;br /&gt;
: {{code|mHatnote.findNamespaceId(&amp;#039;Category:Lions&amp;#039;)|lua}} &amp;amp;rarr; 14&lt;br /&gt;
: {{code|mHatnote.findNamespaceId(&amp;#039;:Category:Lions&amp;#039;)|lua}} &amp;amp;rarr; 14&lt;br /&gt;
: {{code|mHatnote.findNamespaceId(&amp;#039;:Category:Lions&amp;#039;, false)|lua}} &amp;amp;rarr; 0 (the namespace is detected as &amp;quot;:Category&amp;quot;, rather than &amp;quot;Category&amp;quot;)&lt;br /&gt;
&lt;br /&gt;
=== 显示wikitext错误 ===&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;&lt;br /&gt;
mHatnote.makeWikitextError(msg, helpLink, addTrackingCategory)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Formats the string &amp;lt;var&amp;gt;msg&amp;lt;/var&amp;gt; as a red wikitext error message, with optional link to a help page &amp;lt;var&amp;gt;helpLink&amp;lt;/var&amp;gt;. Normally this function also adds {{clc|有错误的顶注模板}}; however, if &amp;lt;var&amp;gt;addTrackingCategory&amp;lt;/var&amp;gt; is not false after being passed through [[Module:Yesno]], then the category is suppressed. This means that the category can be suppressed with &amp;lt;var&amp;gt;addTrackingCategory&amp;lt;/var&amp;gt; values including &amp;quot;no&amp;quot;, &amp;quot;n&amp;quot;, 0, &amp;quot;false&amp;quot;, and {{code|false|lua}}.&lt;br /&gt;
&lt;br /&gt;
样例:&lt;br /&gt;
:{{code|mHatnote.makeWikitextError(&amp;#039;an error has occurred&amp;#039;)|lua}} &amp;amp;rarr; &amp;lt;strong class=&amp;quot;error&amp;quot;&amp;gt;错误：出现了一个错误。&amp;lt;/strong&amp;gt;&lt;br /&gt;
:{{code|mHatnote.makeWikitextError(&amp;#039;an error has occurred&amp;#039;, &amp;#039;Template:Example#Errors&amp;#039;)|lua}} &amp;amp;rarr; &amp;lt;strong class=&amp;quot;error&amp;quot;&amp;gt;错误：出现了一个错误（[[Template:Example#Errors|帮助]]）。&amp;lt;/strong&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== 样例 ==&lt;br /&gt;
&lt;br /&gt;
For examples of how this module is used in other Lua modules, see the following (listed in order of complexity):&lt;br /&gt;
* [[Module:Main]]&lt;br /&gt;
&amp;lt;includeonly&amp;gt;{{Sandbox other||&lt;br /&gt;
&amp;lt;!-- Categories go here and interwikis go in Wikidata. --&amp;gt;&lt;br /&gt;
[[Category:顶注模块| ]]&lt;br /&gt;
[[Category:添加追踪分类的模块]]&lt;br /&gt;
}}&amp;lt;/includeonly&amp;gt;&lt;/div&gt;</summary>
		<author><name>imported&gt;Dabao qian</name></author>
	</entry>
</feed>