hdoc-tools 0.8.24 → 0.8.26

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.
Files changed (3) hide show
  1. package/hdoc-build.js +35 -23
  2. package/hdoc.js +8 -7
  3. package/package.json +1 -1
package/hdoc-build.js CHANGED
@@ -1,7 +1,3 @@
1
- const {
2
- verbose
3
- } = require('sqlite3');
4
-
5
1
  (function () {
6
2
  'use strict';
7
3
 
@@ -49,7 +45,7 @@ const {
49
45
  static_html_files = [],
50
46
  work_path_content = '';
51
47
 
52
- const transform_static_html = async function (file_path) {
48
+ const transform_static_html = async function (file_path, verbose, no_pdf) {
53
49
  if (fs.existsSync(file_path.path)) {
54
50
  // Load HTML file
55
51
  let html_txt = fs.readFileSync(file_path.path, 'utf8');
@@ -199,11 +195,23 @@ const {
199
195
  }
200
196
 
201
197
  let doc_header = '';
198
+ let pdf_header = '';
202
199
  if (hdocbook_config.publicSource.includes('github.com/Hornbill-Docs')) {
203
200
  // Build doc header from template and frontmatter tags
204
201
  doc_header = process_doc_header(fm_headers, file_path.relativePath, doc_header_template);
202
+ if (!no_pdf) pdf_header = process_doc_header(fm_headers, file_path.relativePath, pdf_header_template);
205
203
  } else {
206
204
  doc_header = process_doc_header(fm_headers, file_path.relativePath, doc_header_template_non_git);
205
+ if (!no_pdf) pdf_header = process_doc_header(fm_headers, file_path.relativePath, pdf_header_template_non_git);
206
+ }
207
+
208
+ if (!no_pdf) {
209
+ let pdf_txt = await hdoc_build_pdf.process_images(file_path, html_txt);
210
+ pdf_txt = `${pdf_header}\n${pdf_txt}`;
211
+
212
+ // Generate PDF file from HTML
213
+ const pdf_file_path = file_path.path.replace(path.extname(file_path.path), '.pdf');
214
+ await hdoc_build_pdf.generate_pdf(pdf_template_path, pdf_template, hdocbook_config, pdf_txt, pdf_file_path, verbose);
207
215
  }
208
216
 
209
217
  html_txt = `${fm_header_content}\n${doc_header}\n${html_txt}`;
@@ -223,7 +231,7 @@ const {
223
231
  }
224
232
  };
225
233
 
226
- const transform_markdown_and_save_html = async function (file_path, verbose) {
234
+ const transform_markdown_and_save_html = async function (file_path, verbose, no_pdf) {
227
235
  conversion_attempted++;
228
236
  if (fs.existsSync(file_path.path)) {
229
237
  // Load markdown file
@@ -388,19 +396,21 @@ const {
388
396
  if (hdocbook_config.publicSource.includes('github.com/Hornbill-Docs')) {
389
397
  // Build doc header from template and frontmatter tags
390
398
  doc_header = process_doc_header(fm_headers, file_path.relativePath, doc_header_template);
391
- pdf_header = process_doc_header(fm_headers, file_path.relativePath, pdf_header_template);
399
+ if (!no_pdf) pdf_header = process_doc_header(fm_headers, file_path.relativePath, pdf_header_template);
392
400
  } else {
393
401
  // Build doc header from template and frontmatter tags
394
402
  doc_header = process_doc_header(fm_headers, file_path.relativePath, doc_header_template_non_git);
395
- pdf_header = process_doc_header(fm_headers, file_path.relativePath, pdf_header_template_non_git);
403
+ if (!no_pdf) pdf_header = process_doc_header(fm_headers, file_path.relativePath, pdf_header_template_non_git);
396
404
  }
397
405
 
398
- let pdf_txt = await hdoc_build_pdf.process_images(file_path, html_txt);
399
- pdf_txt = `${pdf_header}\n${pdf_txt}`;
400
-
401
- // Generate PDF file from HTML
402
- const pdf_file_path = file_path.path.replace(path.extname(file_path.path), '.pdf');
403
- await hdoc_build_pdf.generate_pdf(pdf_template_path, pdf_template, hdocbook_config, pdf_txt, pdf_file_path, verbose);
406
+ if (!no_pdf) {
407
+ let pdf_txt = await hdoc_build_pdf.process_images(file_path, html_txt);
408
+ pdf_txt = `${pdf_header}\n${pdf_txt}`;
409
+
410
+ // Generate PDF file from HTML
411
+ const pdf_file_path = file_path.path.replace(path.extname(file_path.path), '.pdf');
412
+ await hdoc_build_pdf.generate_pdf(pdf_template_path, pdf_template, hdocbook_config, pdf_txt, pdf_file_path, verbose);
413
+ }
404
414
 
405
415
  html_txt = `${fm_header}\n${doc_header}\n${html_txt}`;
406
416
 
@@ -622,7 +632,7 @@ const {
622
632
  //console.log(JSON.stringify(bc, null, 2));
623
633
  };
624
634
 
625
- exports.run = async function (source_path, verbose, github_api_token) {
635
+ exports.run = async function (source_path, verbose, github_api_token, no_pdf) {
626
636
  if (github_api_token !== '') {
627
637
  git_token = github_api_token;
628
638
  }
@@ -684,12 +694,14 @@ const {
684
694
  process.exit(1);
685
695
  }
686
696
 
687
- // Load PDF templates
688
- try {
689
- pdf_template = fs.readFileSync(pdf_template_file_path, 'utf8');
690
- } catch (err) {
691
- console.log(`Error reading PDF template: ${err}`);
692
- process.exit(1);
697
+ if (!no_pdf) {
698
+ // Load PDF templates
699
+ try {
700
+ pdf_template = fs.readFileSync(pdf_template_file_path, 'utf8');
701
+ } catch (err) {
702
+ console.log(`Error reading PDF template: ${err}`);
703
+ process.exit(1);
704
+ }
693
705
  }
694
706
 
695
707
  build_breadcrumbs(hdocbook_config.navigation.items);
@@ -700,12 +712,12 @@ const {
700
712
 
701
713
  // Work through MD files and convert to HTML
702
714
  for (let i = 0; i < md_files.length; i++) {
703
- await transform_markdown_and_save_html(md_files[i], verbose);
715
+ await transform_markdown_and_save_html(md_files[i], verbose, no_pdf);
704
716
  }
705
717
 
706
718
  // Work through Static HTML files and add Frontmatter tags
707
719
  for (let i = 0; i < static_html_files.length; i++) {
708
- await transform_static_html(static_html_files[i]);
720
+ await transform_static_html(static_html_files[i], verbose, no_pdf);
709
721
  }
710
722
 
711
723
  // Output to console
package/hdoc.js CHANGED
@@ -27,7 +27,8 @@
27
27
  let ui_path = path.join(__dirname, 'ui');
28
28
  let git_token = '';
29
29
  let command = '', // Our command to run
30
- verbose = false;
30
+ verbose = false,
31
+ no_pdf = false;
31
32
 
32
33
  // Get options from command args
33
34
  for (let x = 0; x < process.argv.length; x++) {
@@ -40,7 +41,11 @@
40
41
  continue;
41
42
  }
42
43
 
43
- if (process.argv[x] == '-path') {
44
+ if (process.argv[x] === '-v') {
45
+ verbose = true;
46
+ } else if (process.argv[x] === '-no-pdf') {
47
+ no_pdf = true;
48
+ } else if (process.argv[x] == '-path') {
44
49
  x++;
45
50
  if (x < process.argv.length) {
46
51
  source_path = process.argv[x];
@@ -56,10 +61,6 @@
56
61
  git_token = process.argv[x];
57
62
  }
58
63
  }
59
-
60
- if (process.argv[x] === '-v') {
61
- verbose = true;
62
- }
63
64
  }
64
65
 
65
66
  console.log('Hornbill HDocBook Tools v' + getHdocPackageVersion(packageFile), '\r\n');
@@ -71,7 +72,7 @@
71
72
  server.run(ui_path, source_path);
72
73
  } else if (command == 'build') {
73
74
  const builder = require(path.join(__dirname, 'hdoc-build.js'));
74
- await builder.run(source_path, verbose, git_token);
75
+ await builder.run(source_path, verbose, git_token, no_pdf);
75
76
  } else if (command == 'stats') {
76
77
  const stats = require(path.join(__dirname, 'hdoc-stats.js'));
77
78
  stats.run(ui_path, source_path, verbose);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "hdoc-tools",
3
- "version": "0.8.24",
3
+ "version": "0.8.26",
4
4
  "description": "Hornbill HDocBook Development Support Tool",
5
5
  "main": "hdoc.js",
6
6
  "bin": {