hdoc-tools 0.15.0 → 0.15.2
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 +31 -17
- package/package.json +1 -1
- package/templates/pdf/css/hdocs-pdf.css +63 -0
package/hdoc-build.js
CHANGED
@@ -24,7 +24,8 @@
|
|
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_version = /^[0-9]{1,3}[.][0-9]{1,3}[.][0-9]{1,6}
|
27
|
+
regex_version = /^[0-9]{1,3}[.][0-9]{1,3}[.][0-9]{1,6}$/,
|
28
|
+
h1_pattern = /(<h1.*?>)\s*.*\s*(.*<\/h1>)/;
|
28
29
|
|
29
30
|
let bc = {}, // Breadcrumbs map
|
30
31
|
built_file_hashes = [],
|
@@ -126,7 +127,7 @@
|
|
126
127
|
}
|
127
128
|
}
|
128
129
|
|
129
|
-
if (!fm_title_found) {
|
130
|
+
if (!fm_title_found && file_path.name !== 'description_ext.md' && file_path.name !== 'article_ext.md') {
|
130
131
|
// No frontmatter title found in properties
|
131
132
|
// Go get title from h tags in html
|
132
133
|
const html_heading = hdoc.getFirstHTMLHeading(html_txt, h_tags_to_search);
|
@@ -153,7 +154,7 @@
|
|
153
154
|
id: 'title',
|
154
155
|
value: html_heading[0].children[0].data
|
155
156
|
});
|
156
|
-
} else {
|
157
|
+
} else if (file_path.name !== 'description_ext.md' && file_path.name !== 'article_ext.md') {
|
157
158
|
// No header tag, no frontmatter title, output a warning
|
158
159
|
console.log(`[WARNING] No frontmatter title property, or ${h_tags_to_search.join(', ')} tags detected in ${file_path.path}`);
|
159
160
|
}
|
@@ -176,7 +177,11 @@
|
|
176
177
|
let metadata = {};
|
177
178
|
|
178
179
|
// Remove the first <h1>title</h1> from the HTML as we'll add that in the document header
|
179
|
-
|
180
|
+
let html_h1 = h1_pattern.exec(html_txt);
|
181
|
+
if (html_h1 && html_h1[0])
|
182
|
+
html_h1 = html_h1[0].replace(/(<h1.*?>)/, '').replace(/(<\/h1>)/, '');
|
183
|
+
|
184
|
+
html_txt = html_txt.replace(h1_pattern, '');
|
180
185
|
|
181
186
|
// Get contributor data from Github, if exists
|
182
187
|
let contribs = [];
|
@@ -240,16 +245,16 @@
|
|
240
245
|
if (hdocbook_config.publicSource && hdocbook_config.publicSource.includes('github.com/Hornbill-Docs')) {
|
241
246
|
// Build doc header from template and frontmatter tags
|
242
247
|
if (!inline_content)
|
243
|
-
doc_header = process_doc_header(fm_headers, file_path.relativePath, doc_header_template);
|
248
|
+
doc_header = process_doc_header(fm_headers, file_path.relativePath, doc_header_template, html_h1);
|
244
249
|
|
245
250
|
if (pdf_enable && !pdf_path_excluded(file_path.relativePath))
|
246
|
-
pdf_header = process_doc_header(fm_headers, file_path.relativePath, pdf_header_template);
|
251
|
+
pdf_header = process_doc_header(fm_headers, file_path.relativePath, pdf_header_template, html_h1);
|
247
252
|
} else {
|
248
253
|
if (!inline_content)
|
249
|
-
doc_header = process_doc_header(fm_headers, file_path.relativePath, doc_header_template_non_git);
|
254
|
+
doc_header = process_doc_header(fm_headers, file_path.relativePath, doc_header_template_non_git, html_h1);
|
250
255
|
|
251
256
|
if (pdf_enable && !pdf_path_excluded(file_path.relativePath))
|
252
|
-
pdf_header = process_doc_header(fm_headers, file_path.relativePath, pdf_header_template_non_git);
|
257
|
+
pdf_header = process_doc_header(fm_headers, file_path.relativePath, pdf_header_template_non_git, html_h1);
|
253
258
|
}
|
254
259
|
|
255
260
|
let pdf_size = 0;
|
@@ -388,7 +393,7 @@
|
|
388
393
|
value: html_heading[0].children[0].data.trim()
|
389
394
|
});
|
390
395
|
doc_title = html_heading[0].children[0].data.trim();
|
391
|
-
} else {
|
396
|
+
} else if (file_path.name !== 'description_ext.md' && file_path.name !== 'article_ext.md') {
|
392
397
|
// No header tag, no frontmatter title, output a warning
|
393
398
|
console.log(`[WARNING] No frontmatter title property, or h1, h2 or h3 header tags detected in ${file_path.path}`);
|
394
399
|
}
|
@@ -406,7 +411,11 @@
|
|
406
411
|
let metadata = {};
|
407
412
|
|
408
413
|
// Remove the first <h1>title</h1> from the HTML as we'll add that in the document header
|
409
|
-
|
414
|
+
let html_h1 = h1_pattern.exec(html_txt);
|
415
|
+
if (html_h1 && html_h1[0])
|
416
|
+
html_h1 = html_h1[0].replace(/(<h1.*?>)/, '').replace(/(<\/h1>)/, '');
|
417
|
+
|
418
|
+
html_txt = html_txt.replace(h1_pattern, '');
|
410
419
|
|
411
420
|
// Get contributor data from Github, if exists
|
412
421
|
let contribs = [];
|
@@ -472,17 +481,17 @@
|
|
472
481
|
if (hdocbook_config.publicSource && hdocbook_config.publicSource.includes('github.com/Hornbill-Docs')) {
|
473
482
|
// Build doc header from template and frontmatter tags
|
474
483
|
if (!inline_content)
|
475
|
-
doc_header = process_doc_header(fm_headers, file_path.relativePath, doc_header_template);
|
484
|
+
doc_header = process_doc_header(fm_headers, file_path.relativePath, doc_header_template, html_h1);
|
476
485
|
|
477
486
|
if (pdf_enable && !pdf_path_excluded(file_path.relativePath))
|
478
|
-
pdf_header = process_doc_header(fm_headers, file_path.relativePath, pdf_header_template);
|
487
|
+
pdf_header = process_doc_header(fm_headers, file_path.relativePath, pdf_header_template, html_h1);
|
479
488
|
} else {
|
480
489
|
// Build doc header from template and frontmatter tags
|
481
490
|
if (!inline_content)
|
482
|
-
doc_header = process_doc_header(fm_headers, file_path.relativePath, doc_header_template_non_git);
|
491
|
+
doc_header = process_doc_header(fm_headers, file_path.relativePath, doc_header_template_non_git, html_h1);
|
483
492
|
|
484
493
|
if (pdf_enable && !pdf_path_excluded(file_path.relativePath))
|
485
|
-
pdf_header = process_doc_header(fm_headers, file_path.relativePath, pdf_header_template_non_git);
|
494
|
+
pdf_header = process_doc_header(fm_headers, file_path.relativePath, pdf_header_template_non_git, html_h1);
|
486
495
|
}
|
487
496
|
|
488
497
|
let pdf_size = 0;
|
@@ -532,14 +541,19 @@
|
|
532
541
|
return false;
|
533
542
|
};
|
534
543
|
|
535
|
-
const process_doc_header = function (fm_headers, doc_path, template) {
|
544
|
+
const process_doc_header = function (fm_headers, doc_path, template, h1) {
|
536
545
|
let wip_doc_header = template;
|
537
|
-
|
546
|
+
let used_h1 = false;
|
547
|
+
if (h1 && h1 !== '') {
|
548
|
+
wip_doc_header = wip_doc_header.replaceAll('{{title}}', h1);
|
549
|
+
used_h1 = true;
|
550
|
+
}
|
538
551
|
// Process fm_headers properties first
|
539
552
|
for (let i = 0; i < fm_headers.length; i++) {
|
540
553
|
switch (fm_headers[i].id) {
|
541
554
|
case 'title':
|
542
|
-
|
555
|
+
if (!used_h1)
|
556
|
+
wip_doc_header = wip_doc_header.replaceAll('{{title}}', fm_headers[i].value);
|
543
557
|
break;
|
544
558
|
case 'reading-time':
|
545
559
|
wip_doc_header = wip_doc_header.replaceAll('{{reading-time}}', fm_headers[i].value);
|
package/package.json
CHANGED
@@ -386,6 +386,69 @@ video {
|
|
386
386
|
background-color: #224187;
|
387
387
|
}
|
388
388
|
|
389
|
+
.badge.badge-http-delete:after {
|
390
|
+
content: "DELETE";
|
391
|
+
white-space: nowrap;
|
392
|
+
border: solid 1px #C7004F;
|
393
|
+
background-color: #C7004F;
|
394
|
+
}
|
395
|
+
|
396
|
+
.badge.badge-http-get:after {
|
397
|
+
content: "GET";
|
398
|
+
white-space: nowrap;
|
399
|
+
border: solid 1px rgb(12, 139, 63);
|
400
|
+
background-color: rgb(12, 139, 63);
|
401
|
+
}
|
402
|
+
|
403
|
+
.badge.badge-http-head:after {
|
404
|
+
content: "HEAD";
|
405
|
+
white-space: nowrap;
|
406
|
+
border: solid 1px #51C17D;
|
407
|
+
background-color: #51C17D;
|
408
|
+
}
|
409
|
+
|
410
|
+
.badge.badge-http-options:after {
|
411
|
+
content: "OPTIONS";
|
412
|
+
white-space: nowrap;
|
413
|
+
border: solid 1px rgb(158, 28, 167);
|
414
|
+
background-color: rgb(158, 28, 167);
|
415
|
+
}
|
416
|
+
|
417
|
+
.badge.badge-http-patch:after {
|
418
|
+
content: "PATCH";
|
419
|
+
white-space: nowrap;
|
420
|
+
border: solid 1px #58178c;
|
421
|
+
background-color: #58178c;
|
422
|
+
}
|
423
|
+
|
424
|
+
.badge.badge-http-post:after {
|
425
|
+
content: "POST";
|
426
|
+
white-space: nowrap;
|
427
|
+
border: solid 1px #F18229;
|
428
|
+
background-color: #F18229;
|
429
|
+
}
|
430
|
+
|
431
|
+
.badge.badge-http-put:after {
|
432
|
+
content: "PUT";
|
433
|
+
white-space: nowrap;
|
434
|
+
border: solid 1px #1194DE;
|
435
|
+
background-color: #1194DE;
|
436
|
+
}
|
437
|
+
|
438
|
+
.badge.badge-rest:after {
|
439
|
+
content: "REST";
|
440
|
+
white-space: nowrap;
|
441
|
+
border: solid 1px #00B0E9;
|
442
|
+
background-color: #00B0E9;
|
443
|
+
}
|
444
|
+
|
445
|
+
.badge.badge-rpc:after {
|
446
|
+
content: "RPC";
|
447
|
+
white-space: nowrap;
|
448
|
+
border: solid 1px #4A536B;
|
449
|
+
background-color: #4A536B;
|
450
|
+
}
|
451
|
+
|
389
452
|
code {
|
390
453
|
font-size: 0.9em;
|
391
454
|
}
|