插件:Heading Anchors

插件Heading Anchors的功能是为<h1> …… <h6>标签自动生成锚链接,当我们在编辑日志的时候,只要出现<hn>标签,系统就会自动生成一个链接,具体的情况如下:
如果你的标签为:<h2>Download</h2>
生成后为:<h2 id="attributes">Download<a href=http://www.movabletype.com.cn/mt/plugins/heading_anchors.html#download> ¶</a></h2>

1、下载地址

zip:http://github.com/beausmith/mt-plugin-heading-anchors/zipball/master
tar:http://github.com/beausmith/mt-plugin-heading-anchors/tarball/master
源文件:http://github.com/beausmith/mt-plugin-heading-anchors/

2、使用方法

把heading_anchors="1"加到<$mt:EntryBody$>和<$mt:EntryMore$>标签中,比如<$mt:EntryMore heading_anchors="1"$>这种格式就行。

3、安装说明

解压压缩文件,然后把文件放入相应的文件夹中即可。

4、注意事项

这个插件暂时不支持中文,可能和MT本身也有关,因为 MT 在生成页面的basename的时候也是不支持中文的,可以使用上面的数字加中文的办法,这点可能有点不方便,注意中文之后要没有空格一类的,如果有空格,会生成一个"-"。

5、对锚链接进行修饰

MT.org官方网站就有使用该插件,他们有写了点CSS对锚链接进行修饰,就是可以隐藏“¶”,在鼠标摆在那行的时候才显示。
下面是需要用到的CSS代码,这些代码来自MT.org,稍微做了点修改,第一部分是隐藏“¶”:


.anchor:link,
.anchor:visited {
    border: none;
    color: #d7d7d7;
    font-size: .8em;
    vertical-align: text-top;
    text-decoration: none;
}
* > .anchor:link,
* > .anchor:visited {
    visibility: hidden;
}
h1:hover .anchor,
h2:hover .anchor,
h3:hover .anchor,
h4:hover .anchor,
h5:hover .anchor,
h6:hover .anchor {
    visibility: visible;
}


第二部分是修饰一下<hn>的字体,这里以<h3>为例:

#content .entry-content h3 {
    color: #000;
    font-size: 15px;
    line-height: 18px;
    margin-bottom: .5em;
    font-weight: bold;
}