08-27-周三_17-09-29

This commit is contained in:
2025-08-27 17:10:05 +08:00
commit 86df397d8f
12735 changed files with 1145479 additions and 0 deletions

22
node_modules/gitbook-plugin-ancre-navigation/README.md generated vendored Normal file
View File

@@ -0,0 +1,22 @@
# gitbook-plugin-ancre-navigation
# how to use the plugin?
In your `book. Json` add plugins:
```
{
"plugins": [
"ancre-navigation"
]
}
```
Then install the plugin:
```
$ gitbook install ./
```

View File

@@ -0,0 +1,57 @@
require('./log');
const defaultConfig = {
showLevel: true,
associatedWithSummary: true,
printLog: false,
multipleH1: true,
mode: "float",
float: {
showLevelIcon: false,
level1Icon: "fa fa-hand-o-right",
level2Icon: "fa fa-hand-o-right",
level3Icon: "fa fa-hand-o-right"
},
pageTop: {
showLevelIcon: false,
level1Icon: "fa fa-hand-o-right",
level2Icon: "fa fa-hand-o-right",
level3Icon: "fa fa-hand-o-right"
},
themeDefault: {
showLevel: false
}
}
function handler(defaultConfig, config) {
if (config) {
for (var item in defaultConfig) {
if (item in config) {
defaultConfig[item] = config[item];
}
}
}
}
function handlerAll(bookIns) {
var config = bookIns.config.get('pluginsConfig')['ancre-navigation'];
var themeDefaultConfig = bookIns.config.get('pluginsConfig')['theme-default'];
handler(defaultConfig, config);
handler(defaultConfig.themeDefault, themeDefaultConfig);
if (config.isRewritePageTitle) {
console.error("error:".error +
"plugins[anchor-navigation-ex]isRewritePageTitle" +
"https://github.com/zq99299/gitbook-plugin-anchor-navigation");
console.log("");
console.error("error:".error +
"Please check here https://github.com/zq99299/gitbook-plugin-anchor-navigation for the latest version of the configuration item");
}
}
module.exports = {
config: defaultConfig,
handler: handler,
handlerAll: handlerAll
}

View File

@@ -0,0 +1,16 @@
var colors = require('colors');
colors.setTheme({
silly: 'rainbow',
input: 'grey',
verbose: 'cyan',
prompt: 'grey',
info: 'green',
data: 'grey',
help: 'cyan',
warn: 'yellow',
debug: 'blue',
error: 'red'
});
module.exports = colors;

View File

@@ -0,0 +1,227 @@
var cheerio = require('cheerio');
var slug = require('github-slugid');
var Config = require('./config.js');
function handlerTocs($, page) {
var config = Config.config;
var tocs = [];
var count = {
h1: 0,
h2: 0,
h3: 0
};
var titleCountMap = {};
var h1 = 0, h2 = 0, h3 = 0;
$(':header').each(function (i, elem) {
var header = $(elem);
var id = addId(header, titleCountMap);
if (id) {
switch (elem.tagName) {
case "h1":
handlerH1Toc(config, count, header, tocs, page.level);
break;
case "h2":
handlerH2Toc(config, count, header, tocs, page.level);
break;
case "h3":
handlerH3Toc(config, count, header, tocs, page.level);
break;
default:
titleAddAnchor(header, id);
break;
}
}
});
page.content = $.html();
return tocs;
}
function addId(header, titleCountMap) {
var id = header.attr('id') || slug(header.text());
var titleCount = titleCountMap[id] || 0;
titleCountMap[id] = titleCount + 1;
if (titleCount) {
id = id + '_' + titleCount;
}
header.attr("id", id);
return id;
}
function titleAddAnchor(header, id) {
header.prepend('<a name="' + id + '" class="anchor-navigation-ex-anchor" '
+ 'href="#' + id + '">'
+ '<i class="fa fa-link" aria-hidden="true"></i>'
+ '</a>');
}
function handlerH1Toc(config, count, header, tocs, pageLevel) {
var title = header.text();
var id = header.attr('id');
var level = '';
titleAddAnchor(header, id);
tocs.push({
name: title,
level: level,
url: id,
children: []
});
}
function handlerH2Toc(config, count, header, tocs, pageLevel) {
var title = header.text();
var id = header.attr('id');
var level = '';
if (tocs.length <= 0) {
titleAddAnchor(header, id);
return;
}
var h1Index = tocs.length - 1;
var h1Toc = tocs[h1Index];
titleAddAnchor(header, id);
h1Toc.children.push({
name: title,
level: level,
url: id,
children: []
});
}
function handlerH3Toc(config, count, header, tocs, pageLevel) {
var title = header.text();
var id = header.attr('id');
var level = '';
if (tocs.length <= 0) {
titleAddAnchor(header, id);
return;
}
var h1Index = tocs.length - 1;
var h1Toc = tocs[h1Index];
var h2Tocs = h1Toc.children;
if (h2Tocs.length <= 0) {
titleAddAnchor(header, id);
return;
}
var h2Toc = h1Toc.children[h2Tocs.length - 1];
titleAddAnchor(header, id);
h2Toc.children.push({
name: title,
level: level,
url: id,
children: []
});
}
function handlerFloatNavbar($, tocs, page) {
var config = Config.config;
var float = config.float;
var level1Icon = '';
var level2Icon = '';
var level3Icon = '';
if (float.showLevelIcon) {
level1Icon = float.level1Icon;
level2Icon = float.level2Icon;
level3Icon = float.level3Icon;
}
var html = "<div id='anchor-navigation-ex-navbar'><i class='fa fa-anchor'></i><ul>";
for (var i = 0; i < tocs.length; i++) {
var h1Toc = tocs[i];
html += "<li><span class='title-icon " + level1Icon + "'></span><a href='#" + h1Toc.url + "'><b>" + h1Toc.level + "</b>" + h1Toc.name + "</a></li>";
if (h1Toc.children.length > 0) {
html += "<ul>"
for (var j = 0; j < h1Toc.children.length; j++) {
var h2Toc = h1Toc.children[j];
html += "<li><span class='title-icon " + level2Icon + "'></span><a href='#" + h2Toc.url + "'><b>" + h2Toc.level + "</b>" + h2Toc.name + "</a></li>";
if (h2Toc.children.length > 0) {
html += "<ul>";
for (var k = 0; k < h2Toc.children.length; k++) {
var h3Toc = h2Toc.children[k];
html += "<li><span class='title-icon " + level3Icon + "'></span><a href='#" + h3Toc.url + "'><b>" + h3Toc.level + "</b>" + h3Toc.name + "</a></li>";
}
html += "</ul>";
}
}
html += "</ul>"
}
}
html += "</ul></div><a href='#" + tocs[0].url + "' id='anchorNavigationExGoTop'><i class='fa fa-arrow-up'></i></a>";
page.content = html + $.html();
}
function handlerPageTopNavbar($, tocs, page) {
var html = buildTopNavbar($, tocs, page);
html += "<a href='#" + tocs[0].url + "' id='anchorNavigationExGoTop'><i class='fa fa-arrow-up'></i></a>";
page.content = html + $.html();
}
function buildTopNavbar($, tocs, page) {
var config = Config.config;
var pageTop = config.pageTop;
var level1Icon = '';
var level2Icon = '';
var level3Icon = '';
if (pageTop.showLevelIcon) {
level1Icon = pageTop.level1Icon;
level2Icon = pageTop.level2Icon;
level3Icon = pageTop.level3Icon;
}
var html = "<div id='anchor-navigation-ex-pagetop-navbar'><ul>";
for (var i = 0; i < tocs.length; i++) {
var h1Toc = tocs[i];
html += "<li><span class='title-icon " + level1Icon + "'></span><a href='#" + h1Toc.url + "'><b>" + h1Toc.level + "</b>" + h1Toc.name + "</a></li>";
if (h1Toc.children.length > 0) {
html += "<ul>"
for (var j = 0; j < h1Toc.children.length; j++) {
var h2Toc = h1Toc.children[j];
html += "<li><span class='title-icon " + level2Icon + "'></span><a href='#" + h2Toc.url + "'><b>" + h2Toc.level + "</b>" + h2Toc.name + "</a></li>";
if (h2Toc.children.length > 0) {
html += "<ul>";
for (var k = 0; k < h2Toc.children.length; k++) {
var h3Toc = h2Toc.children[k];
html += "<li><span class='title-icon " + level3Icon + "'></span><a href='#" + h3Toc.url + "'><b>" + h3Toc.level + "</b>" + h3Toc.name + "</a></li>";
}
html += "</ul>";
}
}
html += "</ul>"
}
}
html += "</ul></div>";
return html;
}
function start(bookIns, page) {
var $ = cheerio.load(page.content);
var tocs = handlerTocs($, page);
if (tocs.length == 0) {
page.content = $.html();
return;
}
if(!/<!--[ \t]*ex_nonav[ \t]*-->/.test(page.content)){
var config = Config.config;
var mode = config.mode;
if (mode == 'float') {
handlerFloatNavbar($, tocs, page);
} else if (mode == 'pageTop') {
handlerPageTopNavbar($, tocs, page);
}
}
var $x = cheerio.load(page.content);
$x('extoc').replaceWith($x(buildTopNavbar($, tocs, page)));
page.content = $x.html();
}
module.exports = start;

View File

@@ -0,0 +1,203 @@
#anchor-navigation-ex-navbar {
background-color: #fafafa;
border: 1px solid rgba(0, 0, 0, .07);
border-radius: 1px;
-webkit-box-shadow: 0 6px 12px rgba(0, 0, 0, .175);
box-shadow: 0 6px 12px rgba(0, 0, 0, .175);
background-clip: padding-box;
padding: 5px 10px;
position: fixed;
/*background-color: rgba(255,255,255,0.98);*/
right: 50px;
top: 68px;
font-size: 12px;
white-space: nowrap;
z-index: 999;
cursor: pointer;
text-align: right;
max-height: 70%;
overflow-y: auto;
overflow-x: hidden;
}
#anchor-navigation-ex-navbar ul {
display: none;
text-align: left;
padding-right: 10px;
padding-left: 10px;
list-style-type: none;
}
#anchor-navigation-ex-navbar:hover ul {
display: block;
}
#anchor-navigation-ex-navbar ul li a {
text-decoration: none;
border-bottom: none;
font-size: 14px;
color: #364149;
background: 0 0;
text-overflow: ellipsis;
overflow: hidden;
white-space: nowrap;
position: relative;
}
#anchor-navigation-ex-navbar ul li a:hover {
text-decoration: underline;
}
#anchor-navigation-ex-navbar ul li .title-icon {
padding-right: 4px;
}
.book.color-theme-1 #anchor-navigation-ex-navbar {
background-color: #111111;
border-color: #7e888b;
color: #afa790;
}
.book.color-theme-1 #anchor-navigation-ex-navbar ul li a {
color: #877f6a;
}
.book.color-theme-2 #anchor-navigation-ex-navbar {
background-color: #2d3143;
border-color: #272a3a;
color: #bcc1d2;
}
.book.color-theme-2 #anchor-navigation-ex-navbar ul li a {
color: #c1c6d7;
}
#anchorNavigationExGoTop {
position: fixed;
right: 50px;
bottom: 68px;
background-color: #fafafa;
border: 1px solid rgba(0, 0, 0, .07);
border-radius: 1px;
-webkit-box-shadow: 0 6px 12px rgba(0, 0, 0, .175);
box-shadow: 0 6px 12px rgba(0, 0, 0, .175);
background-clip: padding-box;
z-index: 999;
cursor: pointer;
font-size: 12px;
padding: 5px 10px;
color: #364149;
}
.book.color-theme-1 #anchorNavigationExGoTop {
background-color: #111111;
border-color: #7e888b;
color: #afa790;
}
.book.color-theme-2 #anchorNavigationExGoTop {
background-color: #2d3143;
border-color: #272a3a;
color: #bcc1d2;
}
a.anchor-navigation-ex-anchor {
color: inherit !important;
display: none;
margin-left: -30px;
padding-left: 40px;
cursor: pointer;
position: absolute;
top: 0;
left: 0;
bottom: 0;
}
a.anchor-navigation-ex-anchor i {
margin-left: -30px;
vertical-align: middle;
font-size: 16px !important;
}
h1, h2, h3, h4, h5, h6 {
position: relative;
}
h1:hover a.anchor-navigation-ex-anchor, h2:hover a.anchor-navigation-ex-anchor, h3:hover a.anchor-navigation-ex-anchor,
h4:hover a.anchor-navigation-ex-anchor, h5:hover a.anchor-navigation-ex-anchor, h6:hover a.anchor-navigation-ex-anchor {
display: inline-block;
}
.book .book-body .page-wrapper .page-inner section.normal {
overflow: visible;
}
#anchor-navigation-ex-pagetop-navbar{
border: 1px solid rgba(0, 0, 0, .07);
border-radius: 1px;
background-clip: padding-box;
padding: 5px 10px;
background-color: #fafafa;
font-size: 12px;
}
#anchor-navigation-ex-pagetop-navbar ul {
text-align: left;
padding-right: 10px;
padding-left: 10px;
list-style-type: none;
}
#anchor-navigation-ex-pagetop-navbar:hover ul {
display: block;
}
#anchor-navigation-ex-pagetop-navbar ul li a {
text-decoration: none;
border-bottom: none;
font-size: 14px;
color: #364149;
background: 0 0;
text-overflow: ellipsis;
overflow: hidden;
white-space: nowrap;
position: relative;
}
#anchor-navigation-ex-pagetop-navbar ul li a:hover {
text-decoration: underline;
}
#anchor-navigation-ex-pagetop-navbar ul li .title-icon {
padding-right: 4px;
}
.book.color-theme-1 #anchor-navigation-ex-pagetop-navbar {
background-color: #111111;
border-color: #7e888b;
color: #afa790;
}
.book.color-theme-1 #anchor-navigation-ex-pagetop-navbar ul li a {
color: #877f6a;
}
.book.color-theme-2 #anchor-navigation-ex-pagetop-navbar {
background-color: #2d3143;
border-color: #272a3a;
color: #bcc1d2;
}
.book.color-theme-2 #anchor-navigation-ex-pagetop-navbar ul li a {
color: #c1c6d7;
}

22
node_modules/gitbook-plugin-ancre-navigation/index.js generated vendored Normal file
View File

@@ -0,0 +1,22 @@
var _start = require('./assets/lib/plugin');
var Config = require('./assets/lib/config');
require('./assets/lib/log');
module.exports = {
book: {
assets: "./assets",
css: ["style/plugin.css"]
},
hooks: {
"init": function () {
Config.handlerAll(this);
},
"page": function (page) {
if (Config.config.printLog) {
console.info("INFO");
}
var bookIns = this;
_start(bookIns, page);
return page;
}
}
};

View File

@@ -0,0 +1,148 @@
{
"_args": [
[
{
"name": "gitbook-plugin-ancre-navigation",
"raw": "gitbook-plugin-ancre-navigation@1.0.0",
"rawSpec": "1.0.0",
"scope": null,
"spec": "1.0.0",
"type": "version"
},
"F:\\tmp\\gitbook"
]
],
"_from": "gitbook-plugin-ancre-navigation@1.0.0",
"_id": "gitbook-plugin-ancre-navigation@1.0.0",
"_inCache": true,
"_installable": true,
"_location": "/gitbook-plugin-ancre-navigation",
"_nodeVersion": "8.11.1",
"_npmOperationalInternal": {
"host": "s3://npm-registry-packages",
"tmp": "tmp/gitbook-plugin-ancre-navigation_1.0.0_1528794256203_0.3167050946336587"
},
"_npmUser": {
"email": "thomas.ehrhard2@etu.univ-lorraine.fr",
"name": "thomas88100"
},
"_npmVersion": "6.0.1",
"_phantomChildren": {},
"_requested": {
"name": "gitbook-plugin-ancre-navigation",
"raw": "gitbook-plugin-ancre-navigation@1.0.0",
"rawSpec": "1.0.0",
"scope": null,
"spec": "1.0.0",
"type": "version"
},
"_requiredBy": [
"#USER"
],
"_resolved": "https://registry.npmjs.org/gitbook-plugin-ancre-navigation/-/gitbook-plugin-ancre-navigation-1.0.0.tgz",
"_shasum": "96465fe1f895dd9fc32619c2e00869065dfcad47",
"_shrinkwrap": null,
"_spec": "gitbook-plugin-ancre-navigation@1.0.0",
"_where": "F:\\tmp\\gitbook",
"author": {
"name": "EHRHARD Thomas"
},
"bugs": {
"url": "https://github.com/thomas88100/gitbook-plugin-ancre-navigation/issues"
},
"dependencies": {
"cheerio": "*",
"colors": "^1.1.2",
"github-slugid": "1.0.1"
},
"description": "Supports two navigation mode, title, anchor effect is the default theme, style, follow the website",
"devDependencies": {},
"directories": {},
"dist": {
"fileCount": 7,
"integrity": "sha512-A3LgW3hn2tnXcwD7N44qXc/ALmTgUIDmEyajg6dLuqIJ0zDEsYiYYgWdlSi6hwOhNn25ilRg9O3vp3IUSIKyKg==",
"npm-signature": "-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJbH4yQCRA9TVsSAnZWagAAjvcP/3wTVIepyaF74UCpOujz\np32yvacbyh51oZ2cdvsq88Baei66t6RgZiZo1bNEsIcjwLOcahLcuzUczkAh\nRG3m5WMOqCGj8juJbo52nrfNqYzxaeuhCfLCX2YakpFHSYTErPc9ZsxtmzX9\nns0SkhmFeCNWz+0JlCyxZ1lUfVd53R0Js/h9QwwTVu0KPIorClfo7icATVwQ\naGYY+cuUCr8H6t5kuIJIqdhSuHXI/H32rtXclU+quAxj26wpTQBIxEqguz2A\nqCCIxlWLkLeGbq/7cvC5gxqkz6A8l/XYEaqWSvsbKmjNm8YCUl1+eOfxflWC\nXK3d6u8DRCINOBtvaj9Z8h0tLF51A9ecVwGdQNOkqq1fEpd1EdjgU3nMKkGl\nIDViDJMZEn0OH/FhV3qhwciWcNSHXhxEYuxDGef7c2bIBRNTQ4DTIlBhMPCR\ny12y4iysYYVjh1513aVaoxo7k2GekNXjVMsarHMYJw/WKb+bIbdlGMJ4LNsA\noIeZvOs9LN49jBoGVsDhWOUvoTDxJJV03d+39itDYtQw3zaYKuCJ+rzgaq6Q\ns8qAT0vd4COZR42fqTcarccwCCF+MtgulhQMrePJrZkjitX24cMOIbTxgPKV\nD7N/0ILPr6UaRtfg5OlMIMoySDChb9u5DqbI+ao1sKz61kdVqGRBRWsgBJoj\ncd+n\r\n=PkEP\r\n-----END PGP SIGNATURE-----\r\n",
"shasum": "96465fe1f895dd9fc32619c2e00869065dfcad47",
"tarball": "https://registry.npmjs.org/gitbook-plugin-ancre-navigation/-/gitbook-plugin-ancre-navigation-1.0.0.tgz",
"unpackedSize": 16029
},
"engines": {
"gitbook": ">=3.0.0"
},
"gitHead": "2067ccfc2db7b07c0e1844277587b14b7b8be70e",
"gitbook": {
"properties": {
"associatedWithSummary": {
"default": true,
"title": "",
"type": "boolean"
},
"float": {
"default": {
"level1Icon": "",
"level2Icon": "",
"level3Icon": "",
"showLevelIcon": false
},
"title": "",
"type": "object"
},
"mode": {
"default": "float",
"title": "",
"type": "string"
},
"multipleH1": {
"default": true,
"title": "",
"type": "boolean"
},
"pageTop": {
"default": {
"level1Icon": "",
"level2Icon": "",
"level3Icon": "",
"showLevelIcon": false
},
"title": "",
"type": "object"
},
"printLog": {
"default": false,
"title": "",
"type": "boolean"
},
"showLevel": {
"default": true,
"title": "",
"type": "boolean"
}
}
},
"homepage": "https://github.com/thomas88100/gitbook-plugin-ancre-navigation#readme",
"keywords": [
"gitbook",
"plugin",
"anchor-navigation-ex",
"ex"
],
"license": "GPL-3.0",
"main": "index.js",
"maintainers": [
{
"email": "thomas.ehrhard2@etu.univ-lorraine.fr",
"name": "thomas88100"
}
],
"name": "gitbook-plugin-ancre-navigation",
"optionalDependencies": {},
"readme": "ERROR: No README data found!",
"repository": {
"type": "git",
"url": "git+https://github.com/thomas88100/gitbook-plugin-ancre-navigation.git"
},
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
},
"version": "1.0.0"
}