Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions build/base64js.min.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

11 changes: 9 additions & 2 deletions build/page-catalogue.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,13 @@
* @desc amWiki 工作端·提取H2-H3为页内目录模块
* @author Tevin
*/

const base64js = require('./base64js.min');

function Base64Encode(str, encoding = 'utf-8') {
var bytes = new (TextEncoder || TextEncoderLite)(encoding).encode(str);
return base64js.fromByteArray(bytes);
}

module.exports = {
//创建
Expand Down Expand Up @@ -56,7 +63,7 @@ module.exports = {
text = lines[i].split('## ')[1];
if (text != undefined) {
lineStr = trimStr(text);
contents += '1. [' + lineStr + '](#' + lineStr.replace(/"/g, '') + ' "' + lineStr + '")\n';
contents += '1. [' + lineStr + '](#' + Base64Encode(lineStr.replace(/"/g, '')) + ' "' + lineStr + '")\n';
} else {
contents += '1.  \n';
}
Expand All @@ -65,7 +72,7 @@ module.exports = {
text = lines[i].split('### ')[1];
if (text != undefined) {
lineStr = trimStr(text);
contents += '\t1. [' + lineStr + '](#' + lineStr.replace(/"/g, '') + ' "' + lineStr + '")\n';
contents += '\t1. [' + lineStr + '](#' + Base64Encode(lineStr.replace(/"/g, '')) + ' "' + lineStr + '")\n';
} else {
contents += '\t1.  \n';
}
Expand Down
12 changes: 9 additions & 3 deletions files/amWiki.docs.js
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,11 @@
.replace(/\[/g, '[') //转义左中括号
.replace(/\]/g, ']'); //转义右中括号
};

function Base64Encode(str, encoding = 'utf-8') {
var bytes = new (TextEncoder || TextEncoderLite)(encoding).encode(str);
return base64js.fromByteArray(bytes);
}

//设置文档h1、h2、h3描记
Docs.prototype._setTitlesAnchor = function () {
Expand All @@ -94,14 +99,15 @@
var $this = $(element);
var text1 = that._tramsformLinkText($this.text());
var text2 = text1.replace(/"/g, ''); //删除双引号
var text3 = Base64Encode(text2);
//提取目录
if ($this.is('h2')) {
contentsMd += '1. [' + text1 + '](#' + text2 + ' "' + text2 + '")\n';
contentsMd += '1. [' + text1 + '](#' + text3 + ' "' + text2 + '")\n';
} else if ($this.is('h3')) {
contentsMd += '\t1. [' + text1 + '](#' + text2 + ' "' + text2 + '")\n';
contentsMd += '\t1. [' + text1 + '](#' + text3 + ' "' + text2 + '")\n';
}
//设置描记
$this.prepend(anchorHtml.replace(/\{title\}/g, text2));
$this.prepend(anchorHtml.replace(/\{title\}/g, text3));
//首次打开页面滚动位置修正
if (hash == $this.text().replace(/"/g, '')) {
if (that.data.pageWidth <= 720) {
Expand Down
1 change: 1 addition & 0 deletions files/amWiki.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,7 @@
</footer>
<!-- js -->
<div class="hidden">
<script type="text/javascript" src="amWiki/js/base64js.min.js"></script>
<script type="text/javascript" src="amWiki/js/gbk.js"></script>
<script type="text/javascript" src="amWiki/js/jquery-compat-3.1.0.min.js"></script>
<script type="text/javascript" src="amWiki/js/marked.min.js"></script>
Expand Down
1 change: 1 addition & 0 deletions files/base64js.min.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.