hdoc-tools 0.19.7 → 0.20.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/custom_modules/tips.js +88 -86
- package/hdoc-build-db.js +260 -198
- package/hdoc-build-pdf.js +219 -173
- package/hdoc-build.js +1480 -1503
- package/hdoc-bump.js +123 -109
- package/hdoc-create.js +108 -95
- package/hdoc-db.js +97 -125
- package/hdoc-help.js +48 -51
- package/hdoc-init.js +181 -147
- package/hdoc-module.js +708 -723
- package/hdoc-serve.js +390 -361
- package/hdoc-stats.js +187 -184
- package/hdoc-validate.js +956 -717
- package/hdoc-ver.js +43 -43
- package/hdoc.js +142 -124
- package/package.json +60 -60
- package/templates/init/_hdocbook/hdocbook.json +23 -23
- package/templates/init/hdocbook-project.json +10 -10
- package/templates/init/package.json +8 -10
- package/ui/js/doc.hornbill.js +708 -659
- package/validateNodeVer.js +17 -14
package/hdoc-db.js
CHANGED
@@ -1,125 +1,97 @@
|
|
1
|
-
(
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
});
|
99
|
-
} else { */
|
100
|
-
// Convert HTML into plain text
|
101
|
-
let text = response.text = html2text.convert(html_txt, {
|
102
|
-
ignoreHref: true,
|
103
|
-
ignoreImage: true,
|
104
|
-
uppercaseHeadings: false,
|
105
|
-
wordwrap: null
|
106
|
-
});
|
107
|
-
// Convert HTML into preview text
|
108
|
-
let preview = html2text.convert(html_txt, {
|
109
|
-
baseElement: 'p',
|
110
|
-
ignoreHref: true,
|
111
|
-
ignoreImage: true,
|
112
|
-
uppercaseHeadings: false,
|
113
|
-
wordwrap: null
|
114
|
-
});
|
115
|
-
preview = hdoc.truncate_string(preview, 200, true).replace(/(?:\r\n|\r|\n)/g, ' ');
|
116
|
-
response.sections.push({
|
117
|
-
text: text,
|
118
|
-
preview: preview
|
119
|
-
})
|
120
|
-
//}
|
121
|
-
return response;
|
122
|
-
};
|
123
|
-
|
124
|
-
|
125
|
-
})();
|
1
|
+
(() => {
|
2
|
+
const html2text = require("html-to-text");
|
3
|
+
const path = require("node:path");
|
4
|
+
const hdoc = require(path.join(__dirname, "hdoc-module.js"));
|
5
|
+
|
6
|
+
exports.create_table = (db, table_name, columns, virtual, fts5) => {
|
7
|
+
const create_sql = ["CREATE"];
|
8
|
+
if (virtual) create_sql.push("VIRTUAL");
|
9
|
+
create_sql.push("TABLE");
|
10
|
+
create_sql.push(table_name);
|
11
|
+
if (fts5) create_sql.push("USING fts5(");
|
12
|
+
else create_sql.push("(");
|
13
|
+
for (let i = 0; i < columns.length; i++) {
|
14
|
+
if (i !== 0) create_sql.push(`,${columns[i]}`);
|
15
|
+
else create_sql.push(columns[i]);
|
16
|
+
}
|
17
|
+
create_sql.push(");");
|
18
|
+
try {
|
19
|
+
db.exec(create_sql.join("\n"));
|
20
|
+
return null;
|
21
|
+
} catch (e) {
|
22
|
+
return e;
|
23
|
+
}
|
24
|
+
};
|
25
|
+
|
26
|
+
exports.insert_record = (db, table, columns, values) => {
|
27
|
+
const response = {
|
28
|
+
success: false,
|
29
|
+
row_id: 0,
|
30
|
+
error: null,
|
31
|
+
};
|
32
|
+
const queryProps = [];
|
33
|
+
queryProps.push(`INSERT INTO ${table}`);
|
34
|
+
let cols = "(";
|
35
|
+
let vals = "VALUES (";
|
36
|
+
for (let i = 0; i < columns.length; i++) {
|
37
|
+
if (i === 0) {
|
38
|
+
cols += `${columns[i].replace("UNINDEXED", "").replace("INTEGER", "").trim()}`;
|
39
|
+
vals += "?";
|
40
|
+
} else {
|
41
|
+
cols += `, ${columns[i].replace("UNINDEXED", "").replace("INTEGER", "").trim()}`;
|
42
|
+
vals += ", ?";
|
43
|
+
}
|
44
|
+
}
|
45
|
+
cols += ")";
|
46
|
+
vals += ")";
|
47
|
+
queryProps.push(cols);
|
48
|
+
queryProps.push(vals);
|
49
|
+
|
50
|
+
try {
|
51
|
+
const stmt = db.prepare(queryProps.join(" "));
|
52
|
+
const info = stmt.run(values);
|
53
|
+
response.row_id = info.lastInsertRowid;
|
54
|
+
response.success = true;
|
55
|
+
} catch (e) {
|
56
|
+
response.error = e;
|
57
|
+
}
|
58
|
+
return response;
|
59
|
+
};
|
60
|
+
|
61
|
+
exports.transform_html_for_index = (html_txt) => {
|
62
|
+
const response = {
|
63
|
+
fm_props: {},
|
64
|
+
sections: [],
|
65
|
+
};
|
66
|
+
|
67
|
+
// Get frontmatter properties
|
68
|
+
const fm_headers = hdoc.getHTMLFrontmatterHeader(html_txt);
|
69
|
+
response.fm_props = fm_headers.fm_properties;
|
70
|
+
|
71
|
+
// Convert HTML into plain text
|
72
|
+
response.text = html2text.convert(html_txt, {
|
73
|
+
ignoreHref: true,
|
74
|
+
ignoreImage: true,
|
75
|
+
uppercaseHeadings: false,
|
76
|
+
wordwrap: null,
|
77
|
+
});
|
78
|
+
|
79
|
+
// Convert HTML into preview text
|
80
|
+
let preview = html2text.convert(html_txt, {
|
81
|
+
baseElement: "p",
|
82
|
+
ignoreHref: true,
|
83
|
+
ignoreImage: true,
|
84
|
+
uppercaseHeadings: false,
|
85
|
+
wordwrap: null,
|
86
|
+
});
|
87
|
+
preview = hdoc
|
88
|
+
.truncate_string(preview, 200, true)
|
89
|
+
.replace(/(?:\r\n|\r|\n)/g, " ");
|
90
|
+
response.sections.push({
|
91
|
+
text: response.text,
|
92
|
+
preview: preview,
|
93
|
+
});
|
94
|
+
//}
|
95
|
+
return response;
|
96
|
+
};
|
97
|
+
})();
|
package/hdoc-help.js
CHANGED
@@ -1,51 +1,48 @@
|
|
1
|
-
(
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
-
|
15
|
-
|
16
|
-
|
17
|
-
-
|
18
|
-
|
19
|
-
|
20
|
-
-
|
21
|
-
|
22
|
-
|
23
|
-
-
|
24
|
-
|
25
|
-
|
26
|
-
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
-
|
34
|
-
|
35
|
-
|
36
|
-
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
console.log(helpText);
|
50
|
-
};
|
51
|
-
})();
|
1
|
+
(() => {
|
2
|
+
exports.run = () => {
|
3
|
+
// STEVE: The purpose of this function is to output information about hdoc arguments
|
4
|
+
const helpText = `
|
5
|
+
Command Line Usage
|
6
|
+
|
7
|
+
hdoc <command> [switches]
|
8
|
+
|
9
|
+
Commands
|
10
|
+
|
11
|
+
- build
|
12
|
+
Performs a local build of the book, and outputs as a ZIP file. Use non-mandatory argument '--set-version 1.2.3' to set the version number of the built book
|
13
|
+
|
14
|
+
- createDocs
|
15
|
+
Creates folder structure and markdown documents as defined in the HDocBook navigation item links
|
16
|
+
|
17
|
+
- help
|
18
|
+
Outputs available arguments and switches
|
19
|
+
|
20
|
+
- init
|
21
|
+
Initializes a new HDocBook project from a template, using runtime input variables
|
22
|
+
|
23
|
+
- serve
|
24
|
+
Starts a local web server on port 3000, serving the content. Supports a -port N to use a different port
|
25
|
+
|
26
|
+
- stats
|
27
|
+
Returns statistics regarding the book you are working on. Supports a -v switch for verbose output.
|
28
|
+
The book statistics do not include counts for any externally hosted content injected into the book content using the [[INCLUDE]] tags.
|
29
|
+
|
30
|
+
- validate
|
31
|
+
Validates the book content
|
32
|
+
|
33
|
+
- bump
|
34
|
+
Updates the semantic version number of the current book. If no options are specified, then the default of patch is applied:
|
35
|
+
- major - updates the major version of the book. i.e. - 1.4.5 would become 2.0.0
|
36
|
+
- minor - updates the minor version of the book. i.e. - 1.4.5 would become 1.5.0
|
37
|
+
- patch (default) - updates the patch version of the book. i.e. - 1.4.5 would become 1.4.6
|
38
|
+
|
39
|
+
- ver
|
40
|
+
Returns the version of the current book
|
41
|
+
|
42
|
+
Example
|
43
|
+
|
44
|
+
hdoc stats -v
|
45
|
+
`;
|
46
|
+
console.log(helpText);
|
47
|
+
};
|
48
|
+
})();
|