This commit is contained in:
2025-05-12 05:38:44 +09:00
parent dced21c3f8
commit 6d78bfa46e
8120 changed files with 1161564 additions and 0 deletions

36
book/node_modules/@honkit/html/lib/dom.d.ts generated vendored Normal file
View File

@ -0,0 +1,36 @@
import * as cheerio from "cheerio";
/**
* Load an HTML string and return a cheerio instance
* @param html
*/
export declare function loadHtml(html: string): cheerio.CheerioAPI;
/**
Parse an HTML string and return its content
@param html
@return {cheerio.Root}
*/
export declare function parse(html: string): cheerio.CheerioAPI;
/**
Return main element for a DOM
@param {cheerio.DOM}
@return {cheerio.Node}
*/
export declare function root($: any): any;
/**
Return text node of an element
@param {cheerio.Node}
@return {string}
*/
export declare function textNode($el: any): any;
/**
Cleanup a DOM by removing all useless divs
@param {cheerio.Node}
@param {cheerio.DOM}
@return {cheerio.Node}
*/
export declare function cleanup($el: any, $: any): any;
//# sourceMappingURL=dom.d.ts.map

1
book/node_modules/@honkit/html/lib/dom.d.ts.map generated vendored Normal file
View File

@ -0,0 +1 @@
{"version":3,"file":"dom.d.ts","sourceRoot":"","sources":["../src/dom.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,OAAO,MAAM,SAAS,CAAC;AAOnC;;;GAGG;AACH,wBAAgB,QAAQ,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,UAAU,CAEzD;AACD;;;;;GAKG;AACH,wBAAgB,KAAK,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,UAAU,CAKtD;AAED;;;;;GAKG;AACH,wBAAgB,IAAI,CAAC,CAAC,KAAA,OAGrB;AAED;;;;;GAKG;AACH,wBAAgB,QAAQ,CAAC,GAAG,KAAA,OAS3B;AAED;;;;;;GAMG;AACH,wBAAgB,OAAO,CAAC,GAAG,KAAA,EAAE,CAAC,KAAA,OAS7B"}

91
book/node_modules/@honkit/html/lib/dom.js generated vendored Normal file
View File

@ -0,0 +1,91 @@
"use strict";
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
var desc = Object.getOwnPropertyDescriptor(m, k);
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
desc = { enumerable: true, get: function() { return m[k]; } };
}
Object.defineProperty(o, k2, desc);
}) : (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
o[k2] = m[k];
}));
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
Object.defineProperty(o, "default", { enumerable: true, value: v });
}) : function(o, v) {
o["default"] = v;
});
var __importStar = (this && this.__importStar) || function (mod) {
if (mod && mod.__esModule) return mod;
var result = {};
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
__setModuleDefault(result, mod);
return result;
};
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.loadHtml = loadHtml;
exports.parse = parse;
exports.root = root;
exports.textNode = textNode;
exports.cleanup = cleanup;
const lodash_1 = __importDefault(require("lodash"));
const cheerio = __importStar(require("cheerio"));
/**
* Load an HTML string and return a cheerio instance
* @param html
*/
function loadHtml(html) {
return cheerio.load(html, { _useHtmlParser2: true });
}
/**
Parse an HTML string and return its content
@param html
@return {cheerio.Root}
*/
function parse(html) {
const $ = cheerio.load(html, { _useHtmlParser2: true });
const $el = $("html, body").first();
return ($el.length > 0 ? $el : $);
}
/**
Return main element for a DOM
@param {cheerio.DOM}
@return {cheerio.Node}
*/
function root($) {
const $el = $("html, body, > div").first();
return $el.length > 0 ? $el : $.root();
}
/**
Return text node of an element
@param {cheerio.Node}
@return {string}
*/
function textNode($el) {
return lodash_1.default.reduce($el.children, (text, e) => {
if (e.type == "text")
text += e.data;
return text;
}, "");
}
/**
Cleanup a DOM by removing all useless divs
@param {cheerio.Node}
@param {cheerio.DOM}
@return {cheerio.Node}
*/
function cleanup($el, $) {
$el.find("div").each(function () {
const $div = $(this);
cleanup($div, $);
$div.replaceWith($div.html());
});
return $el;
}

12
book/node_modules/@honkit/html/lib/glossary.d.ts generated vendored Normal file
View File

@ -0,0 +1,12 @@
/**
Parse an HTML content into a list of glossary entry
@param {string} html
@return {Array}
*/
declare function parseGlossary(html: string): {
name: string;
description: any;
}[];
export default parseGlossary;
//# sourceMappingURL=glossary.d.ts.map

1
book/node_modules/@honkit/html/lib/glossary.d.ts.map generated vendored Normal file
View File

@ -0,0 +1 @@
{"version":3,"file":"glossary.d.ts","sourceRoot":"","sources":["../src/glossary.ts"],"names":[],"mappings":"AAGA;;;;;EAKE;AACF,iBAAS,aAAa,CAAC,IAAI,EAAE,MAAM;UAGF,MAAM;iBAAe,GAAG;IAgBxD;AACD,eAAe,aAAa,CAAC"}

48
book/node_modules/@honkit/html/lib/glossary.js generated vendored Normal file
View File

@ -0,0 +1,48 @@
"use strict";
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
var desc = Object.getOwnPropertyDescriptor(m, k);
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
desc = { enumerable: true, get: function() { return m[k]; } };
}
Object.defineProperty(o, k2, desc);
}) : (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
o[k2] = m[k];
}));
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
Object.defineProperty(o, "default", { enumerable: true, value: v });
}) : function(o, v) {
o["default"] = v;
});
var __importStar = (this && this.__importStar) || function (mod) {
if (mod && mod.__esModule) return mod;
var result = {};
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
__setModuleDefault(result, mod);
return result;
};
Object.defineProperty(exports, "__esModule", { value: true });
// const dom = require("./dom");
const dom = __importStar(require("./dom"));
/**
Parse an HTML content into a list of glossary entry
@param {string} html
@return {Array}
*/
function parseGlossary(html) {
const $ = dom.parse(html);
const entries = [];
$("h2").each(function () {
const $heading = $(this);
const $next = $heading.next();
const $p = $next.is("p") ? $next.first() : $next.find("p").first();
const entry = {};
entry.name = $heading.text();
entry.description = $p.text();
entries.push(entry);
});
return entries;
}
exports.default = parseGlossary;

46
book/node_modules/@honkit/html/lib/index.d.ts generated vendored Normal file
View File

@ -0,0 +1,46 @@
import { SummaryPart } from "./summary";
/**
* Utility for loading HTML content
*/
export { loadHtml } from "./dom";
export type ToHTMLOptions = {
baseDirectory: string;
};
export type ToHTMLFunction = (content: string, options?: ToHTMLOptions) => string;
export type ToTextFunction = (content: any) => string;
export type { SummaryPart };
export type ParserSummary = ((content: string, options?: ToHTMLOptions) => {
parts: SummaryPart[];
}) & {
toText: ToTextFunction;
};
export type ParserGlossary = ((content: string, options?: ToHTMLOptions) => string[]) & {
toText: ToTextFunction;
};
export type ParserLangs = ((content: string, options?: ToHTMLOptions) => string[]) & {
toText: ToTextFunction;
};
export type ParserREADME = (content: string, options?: ToHTMLOptions) => {
title: string;
description: string;
};
export type ParserPage = ((content: string, options?: ToHTMLOptions) => {
content: string;
}) & {
prepare?: (content: string, options?: ToHTMLOptions) => string;
};
export type ParserInline = (content: string, options?: ToHTMLOptions) => {
content: string;
};
export type Parsers = {
summary: ParserSummary;
glossary: ParserGlossary;
langs: ParserLangs;
readme: ParserREADME;
page: ParserPage;
inline: ParserInline;
};
declare function createParser(toHTML: any, toText?: any): Parsers;
declare const defaultParser: Parsers;
export { defaultParser as default, createParser };
//# sourceMappingURL=index.d.ts.map

1
book/node_modules/@honkit/html/lib/index.d.ts.map generated vendored Normal file
View File

@ -0,0 +1 @@
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAGA,OAAgB,EAAE,WAAW,EAAE,MAAM,WAAW,CAAC;AAcjD;;GAEG;AACH,OAAO,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AACjC,MAAM,MAAM,aAAa,GAAG;IACxB,aAAa,EAAE,MAAM,CAAC;CACzB,CAAC;AACF,MAAM,MAAM,cAAc,GAAG,CAAC,OAAO,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,aAAa,KAAK,MAAM,CAAC;AAElF,MAAM,MAAM,cAAc,GAAG,CAAC,OAAO,EAAE,GAAG,KAAK,MAAM,CAAC;AACtD,YAAY,EAAE,WAAW,EAAE,CAAC;AAC5B,MAAM,MAAM,aAAa,GAAG,CAAC,CACzB,OAAO,EAAE,MAAM,EACf,OAAO,CAAC,EAAE,aAAa,KACtB;IACD,KAAK,EAAE,WAAW,EAAE,CAAC;CACxB,CAAC,GAAG;IACD,MAAM,EAAE,cAAc,CAAC;CAC1B,CAAC;AACF,MAAM,MAAM,cAAc,GAAG,CAAC,CAAC,OAAO,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,aAAa,KAAK,MAAM,EAAE,CAAC,GAAG;IACpF,MAAM,EAAE,cAAc,CAAC;CAC1B,CAAC;AACF,MAAM,MAAM,WAAW,GAAG,CAAC,CAAC,OAAO,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,aAAa,KAAK,MAAM,EAAE,CAAC,GAAG;IACjF,MAAM,EAAE,cAAc,CAAC;CAC1B,CAAC;AACF,MAAM,MAAM,YAAY,GAAG,CACvB,OAAO,EAAE,MAAM,EACf,OAAO,CAAC,EAAE,aAAa,KACtB;IACD,KAAK,EAAE,MAAM,CAAC;IACd,WAAW,EAAE,MAAM,CAAC;CACvB,CAAC;AACF,MAAM,MAAM,UAAU,GAAG,CAAC,CACtB,OAAO,EAAE,MAAM,EACf,OAAO,CAAC,EAAE,aAAa,KACtB;IACD,OAAO,EAAE,MAAM,CAAC;CACnB,CAAC,GAAG;IAGD,OAAO,CAAC,EAAE,CAAC,OAAO,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,aAAa,KAAK,MAAM,CAAC;CAClE,CAAC;AACF,MAAM,MAAM,YAAY,GAAG,CACvB,OAAO,EAAE,MAAM,EACf,OAAO,CAAC,EAAE,aAAa,KACtB;IACD,OAAO,EAAE,MAAM,CAAC;CACnB,CAAC;AACF,MAAM,MAAM,OAAO,GAAG;IAClB,OAAO,EAAE,aAAa,CAAC;IACvB,QAAQ,EAAE,cAAc,CAAC;IACzB,KAAK,EAAE,WAAW,CAAC;IACnB,MAAM,EAAE,YAAY,CAAC;IACrB,IAAI,EAAE,UAAU,CAAC;IACjB,MAAM,EAAE,YAAY,CAAC;CACxB,CAAC;AAYF,iBAAS,YAAY,CAAC,MAAM,KAAA,EAAE,MAAM,MAAY,GAAG,OAAO,CAwBzD;AAED,QAAA,MAAM,aAAa,SAA2B,CAAC;AAC/C,OAAO,EAAE,aAAa,IAAI,OAAO,EAAE,YAAY,EAAE,CAAC"}

60
book/node_modules/@honkit/html/lib/index.js generated vendored Normal file
View File

@ -0,0 +1,60 @@
"use strict";
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.default = exports.loadHtml = void 0;
exports.createParser = createParser;
const lodash_1 = __importDefault(require("lodash"));
const totext_1 = __importDefault(require("./totext"));
// import
const summary_1 = __importDefault(require("./summary"));
const glossary_1 = __importDefault(require("./glossary"));
const langs_1 = __importDefault(require("./langs"));
const readme_1 = __importDefault(require("./readme"));
const page_1 = __importDefault(require("./page"));
const htmlParser = {
summary: summary_1.default,
glossary: glossary_1.default,
langs: langs_1.default,
readme: readme_1.default,
page: page_1.default
};
/**
* Utility for loading HTML content
*/
var dom_1 = require("./dom");
Object.defineProperty(exports, "loadHtml", { enumerable: true, get: function () { return dom_1.loadHtml; } });
// Compose a function with a transform function for the first argument only
function compose(toHTML, fn) {
return function (content, options) {
// e.g. convert asciidoc to html
const html = toHTML(content, options);
return fn.call(this, html);
};
}
// Create a HonKit parser from an HTML converter
function createParser(toHTML, toText = undefined) {
if (typeof toHTML === "function") {
toHTML = {
inline: toHTML,
block: toHTML
};
}
const parser = {
summary: compose(toHTML.block, htmlParser.summary),
glossary: compose(toHTML.block, htmlParser.glossary),
langs: compose(toHTML.block, htmlParser.langs),
readme: compose(toHTML.block, htmlParser.readme),
page: compose(toHTML.block, htmlParser.page),
inline: compose(toHTML.inline, htmlParser.page)
};
// @ts-expect-error
const _toText = new totext_1.default(toText);
parser.summary.toText = _toText.summary;
parser.langs.toText = _toText.langs;
parser.glossary.toText = _toText.glossary;
return parser;
}
const defaultParser = createParser(lodash_1.default.identity);
exports.default = defaultParser;

9
book/node_modules/@honkit/html/lib/langs.d.ts generated vendored Normal file
View File

@ -0,0 +1,9 @@
/**
Parse an HTML content into a list of language
@param {string} html
@return {Array}
*/
declare function parseLangs(content: string): any[];
export default parseLangs;
//# sourceMappingURL=langs.d.ts.map

1
book/node_modules/@honkit/html/lib/langs.d.ts.map generated vendored Normal file
View File

@ -0,0 +1 @@
{"version":3,"file":"langs.d.ts","sourceRoot":"","sources":["../src/langs.ts"],"names":[],"mappings":"AAEA;;;;;EAKE;AACF,iBAAS,UAAU,CAAC,OAAO,EAAE,MAAM,SAOlC;AAED,eAAe,UAAU,CAAC"}

20
book/node_modules/@honkit/html/lib/langs.js generated vendored Normal file
View File

@ -0,0 +1,20 @@
"use strict";
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
const summary_1 = __importDefault(require("./summary"));
/**
Parse an HTML content into a list of language
@param {string} html
@return {Array}
*/
function parseLangs(content) {
const parts = (0, summary_1.default)(content).parts;
if (parts.length > 0) {
return parts[0].articles;
}
return [];
}
exports.default = parseLangs;

11
book/node_modules/@honkit/html/lib/page.d.ts generated vendored Normal file
View File

@ -0,0 +1,11 @@
/**
Parse content of a page
@param {string} html
@return {Object}
*/
declare function parsePage(html: any): {
content: any;
};
export default parsePage;
//# sourceMappingURL=page.d.ts.map

1
book/node_modules/@honkit/html/lib/page.d.ts.map generated vendored Normal file
View File

@ -0,0 +1 @@
{"version":3,"file":"page.d.ts","sourceRoot":"","sources":["../src/page.ts"],"names":[],"mappings":"AAAA;;;;;EAKE;AACF,iBAAS,SAAS,CAAC,IAAI,KAAA;;EAItB;AACD,eAAe,SAAS,CAAC"}

14
book/node_modules/@honkit/html/lib/page.js generated vendored Normal file
View File

@ -0,0 +1,14 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
/**
Parse content of a page
@param {string} html
@return {Object}
*/
function parsePage(html) {
return {
content: html
};
}
exports.default = parsePage;

12
book/node_modules/@honkit/html/lib/readme.d.ts generated vendored Normal file
View File

@ -0,0 +1,12 @@
/**
Parse an HTML content into metadata about a readme
@param {string} html
@return {Object}
*/
declare function parseReadme(html: any): {
title: string;
description: string;
};
export default parseReadme;
//# sourceMappingURL=readme.d.ts.map

1
book/node_modules/@honkit/html/lib/readme.d.ts.map generated vendored Normal file
View File

@ -0,0 +1 @@
{"version":3,"file":"readme.d.ts","sourceRoot":"","sources":["../src/readme.ts"],"names":[],"mappings":"AAEA;;;;;EAKE;AACF,iBAAS,WAAW,CAAC,IAAI,KAAA;;;EAOxB;AAED,eAAe,WAAW,CAAC"}

40
book/node_modules/@honkit/html/lib/readme.js generated vendored Normal file
View File

@ -0,0 +1,40 @@
"use strict";
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
var desc = Object.getOwnPropertyDescriptor(m, k);
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
desc = { enumerable: true, get: function() { return m[k]; } };
}
Object.defineProperty(o, k2, desc);
}) : (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
o[k2] = m[k];
}));
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
Object.defineProperty(o, "default", { enumerable: true, value: v });
}) : function(o, v) {
o["default"] = v;
});
var __importStar = (this && this.__importStar) || function (mod) {
if (mod && mod.__esModule) return mod;
var result = {};
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
__setModuleDefault(result, mod);
return result;
};
Object.defineProperty(exports, "__esModule", { value: true });
const dom = __importStar(require("./dom"));
/**
Parse an HTML content into metadata about a readme
@param {string} html
@return {Object}
*/
function parseReadme(html) {
const $ = dom.parse(html);
return {
title: $("h1:first-child").text().trim(),
description: $("div.paragraph,p").first().text().trim()
};
}
exports.default = parseReadme;

15
book/node_modules/@honkit/html/lib/summary.d.ts generated vendored Normal file
View File

@ -0,0 +1,15 @@
export type SummaryPart = {
title: string;
articles: any[];
};
/**
Parse an HTML content into a tree of articles/parts
@param {string} html
@return {Object}
*/
declare function parseSummary(html: string): {
parts: SummaryPart[];
};
export default parseSummary;
//# sourceMappingURL=summary.d.ts.map

1
book/node_modules/@honkit/html/lib/summary.d.ts.map generated vendored Normal file
View File

@ -0,0 +1 @@
{"version":3,"file":"summary.d.ts","sourceRoot":"","sources":["../src/summary.ts"],"names":[],"mappings":"AA6HA,MAAM,MAAM,WAAW,GAAG;IACtB,KAAK,EAAE,MAAM,CAAC;IACd,QAAQ,EAAE,GAAG,EAAE,CAAC;CACnB,CAAC;AAEF;;;;;GAKG;AACH,iBAAS,YAAY,CAAC,IAAI,EAAE,MAAM,GAAG;IAAE,KAAK,EAAE,WAAW,EAAE,CAAA;CAAE,CAoB5D;AAED,eAAe,YAAY,CAAC"}

161
book/node_modules/@honkit/html/lib/summary.js generated vendored Normal file
View File

@ -0,0 +1,161 @@
"use strict";
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
var desc = Object.getOwnPropertyDescriptor(m, k);
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
desc = { enumerable: true, get: function() { return m[k]; } };
}
Object.defineProperty(o, k2, desc);
}) : (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
o[k2] = m[k];
}));
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
Object.defineProperty(o, "default", { enumerable: true, value: v });
}) : function(o, v) {
o["default"] = v;
});
var __importStar = (this && this.__importStar) || function (mod) {
if (mod && mod.__esModule) return mod;
var result = {};
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
__setModuleDefault(result, mod);
return result;
};
Object.defineProperty(exports, "__esModule", { value: true });
const dom = __importStar(require("./dom"));
const SELECTOR_LIST = "ol, ul";
const SELECTOR_LINK = "> a, p > a";
const SELECTOR_PART = "h2, h3, h4";
/**
Find a list
@param {cheerio.Node}
@return {cheerio.Node}
*/
function findList($parent) {
const $container = $parent.children(".olist");
if ($container.length > 0)
$parent = $container.first();
return $parent.children(SELECTOR_LIST);
}
/**
Parse a ul list and return list of chapters recursvely
@param {cheerio.Node}
@param {cheerio.DOM}
@return {Array}
*/
function parseList($ul, $) {
const articles = [];
$ul.children("li").each(function () {
const article = {};
const $li = $(this);
// Get text for the entry
const $p = $li.children("p");
article.title = ($p.text() || dom.textNode($li.get(0))).trim();
// Parse link
const $a = $li.find(SELECTOR_LINK);
if ($a.length > 0) {
article.title = $a.first().text();
article.ref = $a.attr("href").replace(/\\/g, "/").replace(/^\/+/, "");
}
// Sub articles
const $sub = findList($li);
article.articles = parseList($sub, $);
if (!article.title)
return;
articles.push(article);
});
return articles;
}
/**
Find all parts and their corresponding lists
@param {cheerio.Node}
@param {cheerio.DOM}
@return {Array<{title: String, list: cheerio.Node}>}
*/
function findParts($parent, $) {
// Find parts and lists
// TODO asciidoc compatibility
const partsAndLists = $parent.children(`${SELECTOR_LIST}, ${SELECTOR_PART}`);
// Group each part with the list after
const parts = [];
let previousPart = null;
partsAndLists.each((i, el) => {
if (isPartNode(el)) {
if (previousPart !== null) {
// The previous part was empty
parts.push(previousPart);
}
previousPart = {
title: getPartTitle(el, $),
list: null
};
}
else {
// It is a list
if (previousPart !== null) {
previousPart.list = el;
}
else {
previousPart = {
title: "",
list: el
};
}
parts.push(previousPart);
previousPart = null;
}
});
// Last part might be empty
if (previousPart !== null) {
parts.push(previousPart);
}
return parts;
}
/**
True if the element is a part
@param el
@return {boolean}
*/
function isPartNode(el) {
return SELECTOR_PART.indexOf(el.name) !== -1;
}
/**
Parse the title of a part element
@param el
@param {cheerio.DOM} $
@return {string}
*/
function getPartTitle(el, $) {
return $(el).text().trim();
}
/**
Parse an HTML content into a tree of articles/parts
@param {string} html
@return {Object}
*/
function parseSummary(html) {
const $ = dom.parse(html);
const $root = dom.cleanup(dom.root($), $);
const parts = findParts($root, $);
// Parse each list
const parsedParts = [];
let part;
for (let i = 0; i < parts.length; ++i) {
part = parts[i];
parsedParts.push({
title: part.title,
articles: parseList($(part.list), $)
});
}
return {
parts: parsedParts
};
}
exports.default = parseSummary;

3
book/node_modules/@honkit/html/lib/totext.d.ts generated vendored Normal file
View File

@ -0,0 +1,3 @@
declare function ToText(markup: any): any;
export default ToText;
//# sourceMappingURL=totext.d.ts.map

1
book/node_modules/@honkit/html/lib/totext.d.ts.map generated vendored Normal file
View File

@ -0,0 +1 @@
{"version":3,"file":"totext.d.ts","sourceRoot":"","sources":["../src/totext.ts"],"names":[],"mappings":"AAOA,iBAAS,MAAM,CAAC,MAAM,KAAA,OAQrB;AAkKD,eAAe,MAAM,CAAC"}

144
book/node_modules/@honkit/html/lib/totext.js generated vendored Normal file
View File

@ -0,0 +1,144 @@
"use strict";
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
const lodash_1 = __importDefault(require("lodash"));
/*
This class is extended by gitbook-markdown and gitbook-asciidoc
to generate back markdown/asciidoc from HonKit metadata.
*/
function ToText(markup) {
if (!(this instanceof ToText)) {
// @ts-expect-error
return new ToText(markup);
}
lodash_1.default.extend(this, markup || {});
lodash_1.default.bindAll(this, lodash_1.default.functionsIn(this));
}
// Break line
ToText.prototype.onBL = function () {
return "\n";
};
ToText.prototype.onText = function (text) {
return text;
};
ToText.prototype.onHR = function () {
return "<hr />";
};
// ---- TITLES
ToText.prototype.onTitleStart = function (level) {
return `<h${level}>`;
};
ToText.prototype.onTitleEnd = function (level) {
return `</h${level}>`;
};
// ---- PARAGRAPHS / SECTIONS
ToText.prototype.onParagraphStart = function () {
return "<p>";
};
ToText.prototype.onParagraphEnd = function () {
return "</p>";
};
ToText.prototype.onSection = function () {
return this.onBL();
};
// ---- LINKS
ToText.prototype.onLinkStart = function (href) {
return `<a href="${href}">`;
};
ToText.prototype.onLinkEnd = function (href) {
return "</a>";
};
// ---- LISTS
ToText.prototype.onListItemStart = function (level) {
return `${this._spaces((level + 1) * 4)}<li>`;
};
ToText.prototype.onListItemEnd = function (level) {
return `${this._spaces((level + 1) * 4)}</li>${this.onBL()}`;
};
ToText.prototype.onListStart = function (level) {
return `${this._spaces(level * 4)}<ul>${this.onBL()}`;
};
ToText.prototype.onListEnd = function (level) {
return `${this._spaces(level * 4)}</ul>${this.onBL()}`;
};
// ------ LANGS
ToText.prototype.langs = function (languages) {
let content = "";
content += this.onTitleStart(1) + this.onText("Languages") + this.onTitleEnd(1);
content += this.onSection();
content += this._summaryArticles(languages);
return content;
};
// ------ GLOSSARY
ToText.prototype.glossary = function (glossary) {
const that = this;
let content = "";
content += that.onTitleStart(1) + that.onText("Glossary") + that.onTitleEnd(1);
content += that.onSection();
lodash_1.default.each(glossary, (entry) => {
content += that.onTitleStart(2) + that.onText(entry.name) + that.onTitleEnd(2);
content += that.onParagraphStart();
content += that.onText(entry.description);
content += that.onParagraphEnd();
content += that.onSection();
});
return content;
};
// ------ SUMMARY
ToText.prototype._summaryArticle = function (article, level) {
let content = "";
content += this.onListItemStart(level);
if (article.ref)
content += this.onLinkStart(article.ref);
content += this.onText(article.title);
if (article.ref)
content += this.onLinkEnd(article.ref);
content += this.onBL();
if (article.articles && article.articles.length > 0) {
content += this._summaryArticles(article.articles, level + 1);
}
content += this.onListItemEnd(level);
return content;
};
ToText.prototype._summaryArticles = function (articles, level) {
const that = this;
let content = "";
level = level || 0;
content += that.onListStart(level);
lodash_1.default.each(articles, (article) => {
content += that._summaryArticle(article, level);
});
content += that.onListEnd(level);
return content;
};
ToText.prototype._summaryPart = function (part) {
let content = "";
if (part.title)
content += this.onTitleStart(2) + this.onText(part.title) + this.onTitleEnd(2);
content += this._summaryArticles(part.articles);
return content;
};
ToText.prototype.summary = function (summary) {
const that = this;
let content = "";
content += that.onTitleStart(1) + that.onText("Summary") + that.onTitleEnd(1);
content += that.onSection();
lodash_1.default.each(summary.parts, (part, i) => {
const next = summary.parts[i + 1];
content += that._summaryPart(part);
if (next && !next.title) {
content += that.onBL() + that.onHR() + that.onBL();
}
else {
content += that.onSection();
}
});
return content;
};
// ---- Utilities
ToText.prototype._spaces = function (n, s) {
return Array(n + 1).join(s || " ");
};
exports.default = ToText;