hdoc-tools 0.9.41 → 0.9.43
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/hdoc-build.js +11 -12
- package/hdoc-module.js +34 -82
- package/package.json +2 -3
- package/templates/pdf/css/hdocs-pdf.css +5 -1
- package/templates/pdf/template.html +17 -4
package/hdoc-build.js
CHANGED
@@ -24,7 +24,6 @@
|
|
24
24
|
non_git_pdf_header_template_path = path.join(__dirname, 'templates', 'pdf-header-non-git.html'),
|
25
25
|
pdf_template_path = path.join(__dirname, 'templates', 'pdf'),
|
26
26
|
pdf_template_file_path = path.join(pdf_template_path, 'template.html'),
|
27
|
-
regex_set_version = /^[0-9]{1,3}[.][0-9]{1,3}[.][0-9]{0,6}$/,
|
28
27
|
regex_version = /^[0-9]{1,3}[.][0-9]{1,3}[.][0-9]{1,6}$/;
|
29
28
|
|
30
29
|
let bc = {}, // Breadcrumbs map
|
@@ -611,16 +610,16 @@
|
|
611
610
|
if (!validate && hdocbook_project.pdfGeneration !== undefined && hdocbook_project.pdfGeneration.enable !== undefined) {
|
612
611
|
pdf_enable = hdocbook_project.pdfGeneration.enable;
|
613
612
|
}
|
614
|
-
|
613
|
+
|
615
614
|
console.log(`Loading hdocbook config...`);
|
616
|
-
|
615
|
+
|
617
616
|
const book_path = path.join(source_path, doc_id),
|
618
617
|
hdocbook_path = path.join(book_path, 'hdocbook.json'),
|
619
618
|
work_path = path.join(source_path, '_work'),
|
620
619
|
work_hdocbook_path = path.join(work_path, doc_id, 'hdocbook.json');
|
621
620
|
|
622
621
|
hdocbook_config = require(hdocbook_path);
|
623
|
-
if (build_version !== '')
|
622
|
+
if (build_version !== '') {
|
624
623
|
if (build_version.match(regex_version)) {
|
625
624
|
hdocbook_config.version = build_version;
|
626
625
|
} else {
|
@@ -631,7 +630,7 @@
|
|
631
630
|
if (!hdocbook_config.version.match(regex_version)) {
|
632
631
|
console.log(`ERROR: Version number does not match required format - ${hdocbook_config.version}\n`);
|
633
632
|
process.exit(1);
|
634
|
-
}
|
633
|
+
}
|
635
634
|
|
636
635
|
if (hdocbook_config.publicSource.endsWith('.git')) hdocbook_config.publicSource = hdocbook_config.publicSource.substring(0, hdocbook_config.publicSource.length - 4);
|
637
636
|
|
@@ -660,7 +659,7 @@
|
|
660
659
|
}
|
661
660
|
}
|
662
661
|
}
|
663
|
-
|
662
|
+
|
664
663
|
console.log(`Building: ${doc_id} v${hdocbook_config.version}...\n`);
|
665
664
|
|
666
665
|
// Make _work folder to copy everything into
|
@@ -684,7 +683,7 @@
|
|
684
683
|
|
685
684
|
// Create MD5 hash of content before build
|
686
685
|
console.log(`Creating Hash...`);
|
687
|
-
|
686
|
+
|
688
687
|
dree.scan(work_path_content, md5DreeOptions, hash_callback);
|
689
688
|
let concat_hash = '|';
|
690
689
|
for (let i = 0; i < built_file_hashes.length; i++) {
|
@@ -736,7 +735,7 @@
|
|
736
735
|
|
737
736
|
if (pdf_enable) {
|
738
737
|
// Create a Chromium browser instance generate PDFs with
|
739
|
-
browser = await puppeteer.launch({headless: 'new'});
|
738
|
+
browser = await puppeteer.launch({ headless: 'new' });
|
740
739
|
}
|
741
740
|
|
742
741
|
// Work through MD files and convert to HTML
|
@@ -805,7 +804,7 @@
|
|
805
804
|
if (err) console.log(`Error deleting ${file}: ${e}`);
|
806
805
|
}));
|
807
806
|
}));
|
808
|
-
|
807
|
+
|
809
808
|
// Add book read timing to the hdocbook.json
|
810
809
|
hdocbook_config.readingTime = Math.ceil(book_read_time + ((book_read_time / 100) * 10));
|
811
810
|
hdocbook_config.navigation.items = hdoc.strip_drafts(hdocbook_config.navigation.items);
|
@@ -842,7 +841,7 @@
|
|
842
841
|
console.log(`\nZIP Creation Success: ${zip_path}\n`);
|
843
842
|
console.log(' Build Started:', build_start_dt);
|
844
843
|
console.log(`Build Completed: ${new Date().toLocaleString()}\n`);
|
845
|
-
|
844
|
+
|
846
845
|
} catch (e) {
|
847
846
|
console.log('\nError creating ZIP: ' + e);
|
848
847
|
}
|
@@ -853,8 +852,8 @@
|
|
853
852
|
console.log(`Time Taken: ${get_duration(start_time, end_time)}\n`);
|
854
853
|
};
|
855
854
|
|
856
|
-
const get_duration = function(start, end) {
|
857
|
-
const total_time = new Date(end - start).toISOString().slice(11,19);
|
855
|
+
const get_duration = function (start, end) {
|
856
|
+
const total_time = new Date(end - start).toISOString().slice(11, 19);
|
858
857
|
const duration_arr = total_time.split(':');
|
859
858
|
let duration = '';
|
860
859
|
if (parseInt(duration_arr[0], 10) > 0) {
|
package/hdoc-module.js
CHANGED
@@ -299,7 +299,8 @@
|
|
299
299
|
recurse_nav(return_nav);
|
300
300
|
return return_nav;
|
301
301
|
};
|
302
|
-
|
302
|
+
|
303
|
+
const recurse_nav = function (nav_items) {
|
303
304
|
for (const key in nav_items) {
|
304
305
|
if (nav_items[key].draft) {
|
305
306
|
nav_items.splice(key, 1);
|
@@ -311,91 +312,42 @@
|
|
311
312
|
};
|
312
313
|
|
313
314
|
exports.build_breadcrumbs = function (nav_items) {
|
314
|
-
|
315
|
-
|
316
|
-
|
317
|
-
|
318
|
-
|
319
|
-
if (
|
320
|
-
|
321
|
-
|
322
|
-
link
|
323
|
-
}
|
315
|
+
const bc = {};
|
316
|
+
const buildBreadcrumb = (items, parentLinks) => {
|
317
|
+
|
318
|
+
// Process parent links
|
319
|
+
let parentlink = true;
|
320
|
+
if (parentLinks.length > 0) {
|
321
|
+
if (parentLinks[0].link === undefined || parentLinks[0].link === '') parentlink = false;
|
322
|
+
if (parentLinks[1] && parentLinks[1].link === undefined && items.length > 0 && items[0].link) {
|
323
|
+
parentLinks[1].link = items[0].link;
|
324
|
+
}
|
325
|
+
if (parentLinks[2] && parentLinks[2].link === undefined && items.length > 0 && items[0].link) {
|
326
|
+
parentLinks[2].link = items[0].link;
|
327
|
+
}
|
324
328
|
}
|
325
|
-
if (nav_a.items) {
|
326
|
-
for (let b = 0; b < nav_a.items.length; b++) {
|
327
|
-
const nav_b = nav_a.items[b];
|
328
|
-
const parent_b = nav_b.text;
|
329
|
-
if (nav_b.link) {
|
330
|
-
if (bc[nav_a.link]) {
|
331
|
-
bc[nav_b.link] = bc[nav_a.link];
|
332
|
-
} else {
|
333
|
-
bc[nav_b.link] = [{
|
334
|
-
text: parent_a,
|
335
|
-
link: nav_a.items[0].link !== undefined ? nav_a.items[0].link : ''
|
336
|
-
}];
|
337
|
-
}
|
338
|
-
bc[nav_b.link].push({
|
339
|
-
text: nav_b.text,
|
340
|
-
link: nav_b.link
|
341
|
-
});
|
342
|
-
}
|
343
329
|
|
344
|
-
|
345
|
-
|
346
|
-
|
347
|
-
|
348
|
-
|
349
|
-
|
350
|
-
|
351
|
-
|
352
|
-
|
353
|
-
text: parent_a,
|
354
|
-
link: nav_a.items[0].link !== undefined ? nav_a.items[0].link : ''
|
355
|
-
}];
|
356
|
-
bc[nav_c.link].push({
|
357
|
-
text: parent_b,
|
358
|
-
link: nav_b.items[0].link
|
359
|
-
});
|
360
|
-
}
|
361
|
-
bc[nav_c.link].push({
|
362
|
-
text: nav_c.text,
|
363
|
-
link: nav_c.link
|
364
|
-
});
|
365
|
-
}
|
330
|
+
// Loop through items, build breadcrumb
|
331
|
+
for (let i = 0; i < items.length; i++) {
|
332
|
+
const item = items[i];
|
333
|
+
if (!parentlink && item.link) {
|
334
|
+
parentLinks[0].link = item.link;
|
335
|
+
parentlink = true;
|
336
|
+
}
|
337
|
+
const { text, link, items: subItems } = item;
|
338
|
+
const breadcrumb = [...parentLinks, { text, link }];
|
366
339
|
|
367
|
-
|
368
|
-
|
369
|
-
|
370
|
-
|
371
|
-
|
372
|
-
|
373
|
-
} else {
|
374
|
-
bc[nav_d.link] = [{
|
375
|
-
text: parent_a,
|
376
|
-
link: nav_a.items[0].link !== undefined ? nav_a.items[0].link : ''
|
377
|
-
}];
|
378
|
-
bc[nav_d.link].push({
|
379
|
-
text: parent_b,
|
380
|
-
link: nav_b.items[0].link
|
381
|
-
});
|
382
|
-
bc[nav_d.link].push({
|
383
|
-
text: parent_c,
|
384
|
-
link: nav_c.items[0].link
|
385
|
-
});
|
386
|
-
}
|
387
|
-
bc[nav_d.link].push({
|
388
|
-
text: nav_d.text,
|
389
|
-
link: nav_d.link
|
390
|
-
});
|
391
|
-
}
|
392
|
-
}
|
393
|
-
}
|
394
|
-
}
|
395
|
-
}
|
340
|
+
if (link) {
|
341
|
+
bc[link] = breadcrumb;
|
342
|
+
}
|
343
|
+
|
344
|
+
if (subItems) {
|
345
|
+
buildBreadcrumb(subItems, breadcrumb);
|
396
346
|
}
|
397
347
|
}
|
398
|
-
}
|
348
|
+
};
|
349
|
+
|
350
|
+
buildBreadcrumb(nav_items, []);
|
399
351
|
return bc;
|
400
352
|
};
|
401
353
|
|
@@ -406,7 +358,7 @@
|
|
406
358
|
prods_supported: [],
|
407
359
|
errors: ''
|
408
360
|
};
|
409
|
-
|
361
|
+
|
410
362
|
try {
|
411
363
|
const prods = await axios.get('https://docs.hornbill.com/_books/products.json', {
|
412
364
|
httpsAgent: agent
|
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "hdoc-tools",
|
3
|
-
"version": "0.9.
|
3
|
+
"version": "0.9.43",
|
4
4
|
"description": "Hornbill HDocBook Development Support Tool",
|
5
5
|
"main": "hdoc.js",
|
6
6
|
"bin": {
|
@@ -41,7 +41,6 @@
|
|
41
41
|
"dree": "^3.4.2",
|
42
42
|
"express": "^4.18.2",
|
43
43
|
"fs-extra": "^11.1.0",
|
44
|
-
"highlight.js": "^11.6.0",
|
45
44
|
"html-to-text": "^8.2.1",
|
46
45
|
"js-yaml": "^4.1.0",
|
47
46
|
"markdown-it": "^13.0.1",
|
@@ -56,4 +55,4 @@
|
|
56
55
|
"words-count": "^2.0.2",
|
57
56
|
"zip-a-folder": "^1.1.5"
|
58
57
|
}
|
59
|
-
}
|
58
|
+
}
|
@@ -128,7 +128,7 @@ audio,
|
|
128
128
|
iframe,
|
129
129
|
embed,
|
130
130
|
object {
|
131
|
-
display:none;
|
131
|
+
display: none;
|
132
132
|
}
|
133
133
|
|
134
134
|
figure {
|
@@ -240,4 +240,8 @@ video {
|
|
240
240
|
|
241
241
|
.hdoc-alert.alert-icon-warning code {
|
242
242
|
background-color: var(--htl-custom-block-warning-code-bg);
|
243
|
+
}
|
244
|
+
|
245
|
+
code {
|
246
|
+
font-size: 0.9em;
|
243
247
|
}
|
@@ -1,7 +1,20 @@
|
|
1
1
|
<!DOCTYPE html>
|
2
2
|
<html>
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
3
|
+
|
4
|
+
<head>
|
5
|
+
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/bootstrap-icons@1.9.1/font/bootstrap-icons.css" />
|
6
|
+
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/highlight.js/11.7.0/styles/vs2015.min.css">
|
7
|
+
<script src="https://cdnjs.cloudflare.com/ajax/libs/highlight.js/11.7.0/highlight.min.js"></script>
|
8
|
+
</head>
|
9
|
+
|
10
|
+
<body>
|
11
|
+
{{document_content}}
|
12
|
+
</body>
|
13
|
+
<script type="text/javascript">
|
14
|
+
|
15
|
+
// Using highlightAll method to
|
16
|
+
// highlight the code
|
17
|
+
hljs.highlightAll();
|
18
|
+
</script>
|
19
|
+
|
7
20
|
</html>
|