hdoc-tools 0.9.21 → 0.9.23

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-db.js CHANGED
@@ -50,7 +50,7 @@
50
50
  error: null,
51
51
  db: null
52
52
  };
53
- console.log('Performing SQlite index creation...');
53
+ console.log('\nPerforming SQlite index creation...');
54
54
  let db_name = path.join(db_path, doc_id, 'index.db');
55
55
  response.db = new database(db_name);
56
56
  response.db.pragma('encoding="UTF-8"');
@@ -142,8 +142,7 @@
142
142
 
143
143
  }
144
144
  response.success = true;
145
- console.log(`\nIndex Build Complete:`);
146
- console.log(`${response.index_success_count} document index records created.`);
145
+ console.log(`\nIndex Build Complete: ${response.index_success_count} document index records created.`);
147
146
  return response;
148
147
  };
149
148
  })();
package/hdoc-build.js CHANGED
@@ -35,6 +35,7 @@
35
35
  conversion_failed = 0,
36
36
  doc_header_template = '',
37
37
  doc_header_template_non_git = '',
38
+ pdf_created = 0,
38
39
  pdf_enable = false,
39
40
  pdf_header_template = '',
40
41
  pdf_header_template_non_git = '',
@@ -242,6 +243,7 @@
242
243
  const pdf_file_path = file_path.path.replace(path.extname(file_path.path), '.pdf');
243
244
  pdf_size = await hdoc_build_pdf.generate_pdf(browser, pdf_template_path, pdf_template, hdocbook_config, pdf_txt, pdf_file_path, verbose);
244
245
  }
246
+ if (pdf_size > 0) pdf_created++;
245
247
 
246
248
  html_txt = `${fm_header_content}\n${doc_header}\n${html_txt}`;
247
249
 
@@ -452,7 +454,7 @@
452
454
  const pdf_file_path = file_path.path.replace(path.extname(file_path.path), '.pdf');
453
455
  pdf_size = await hdoc_build_pdf.generate_pdf(browser, pdf_template_path, pdf_template, hdocbook_config, pdf_txt, pdf_file_path, verbose);
454
456
  }
455
-
457
+ if (pdf_size > 0) pdf_created++;
456
458
  html_txt = `${fm_header}\n${doc_header}\n${html_txt}`;
457
459
 
458
460
  // Save HTML into HTML file
@@ -712,13 +714,16 @@
712
714
  }
713
715
 
714
716
  // Output to console
715
- console.log(` MD files found: ${conversion_attempted}`);
717
+ console.log(`\n MD files found: ${conversion_attempted}`);
716
718
  console.log(`Successfully converted to HTML: ${conversion_success}`);
717
719
  console.log(` Failed to convert: ${conversion_failed}\n`);
718
720
  console.log(` Includes Found: ${includes_found}`);
719
721
  console.log(` Includes Success: ${includes_success}`);
720
722
  console.log(` Includes Failed: ${includes_failed}\n`);
721
723
  console.log(` Static HTML Files Found: ${static_html_files.length}\n`);
724
+ if (!validate) {
725
+ console.log(` PDF Files Created: ${pdf_created}\n`);
726
+ }
722
727
 
723
728
  // Validate content
724
729
  const validation_success = await hdoc_validate.run(work_path, doc_id, verbose, hdocbook_config, hdocbook_project, bc);
package/hdoc-validate.js CHANGED
@@ -26,11 +26,11 @@
26
26
  let errors = {},
27
27
  messages = {},
28
28
  warnings = {},
29
- errorcount = 0,
30
29
  html_to_validate = [],
31
30
  md_to_validate = [],
32
31
  exclude_links = {},
33
- exclude_spellcheck = {};
32
+ exclude_spellcheck = {},
33
+ exclude_h1_count = {};
34
34
 
35
35
  const load_product_families = async function () {
36
36
  try {
@@ -224,15 +224,18 @@
224
224
  };
225
225
 
226
226
  const checkTags = async function (htmlFile) {
227
+ // Check if file is excluded from tag check
228
+ const file_no_ext = htmlFile.relativePath.replace(path.extname(htmlFile.relativePath), '');
229
+ if (exclude_h1_count[file_no_ext]) return;
230
+
231
+ // Check tags
227
232
  const htmlBody = fs.readFileSync(htmlFile.path, 'utf8');
228
233
  const $ = cheerio.load(htmlBody);
229
234
 
230
235
  const h1_tags = $('h1').map(function () {
231
236
  return $(this);
232
237
  }).get();
233
-
234
238
  if (h1_tags.length && h1_tags.length > 1) {
235
- //console.log("PATH: ", htmlFile.path); //hdoc-guide/hdocbook/markdown.html
236
239
  let error_msg = `${h1_tags.length} <h1> tags found in content: `;
237
240
  for (let i = 0; i < h1_tags.length; i++) {
238
241
  error_msg += h1_tags[i].text();
@@ -374,10 +377,10 @@
374
377
  console.log('\r\n-----------------------');
375
378
  console.log(' Validation Output ');
376
379
  console.log('-----------------------');
377
- console.log(`\r\n${meta_errors.length} Validation Errors Found\r\n`);
378
380
  for (let i = 0; i < meta_errors.length; i++) {
379
381
  console.log(`- ${meta_errors[i]}`);
380
382
  }
383
+ console.log(`\r\n${meta_errors.length} Validation Errors Found`);
381
384
  return false;
382
385
  }
383
386
 
@@ -392,6 +395,11 @@
392
395
  exclude_spellcheck[excl_sc.document_path] = excl_sc.words;
393
396
  });
394
397
  }
398
+ if (hdocbook_project.validation.exclude_h1_count && hdocbook_project.validation.exclude_h1_count instanceof Array) {
399
+ hdocbook_project.validation.exclude_h1_count.forEach(function (excl_h1) {
400
+ exclude_h1_count[excl_h1] = true;
401
+ });
402
+ }
395
403
  }
396
404
 
397
405
  // Do spellchecking on markdown files
@@ -434,7 +442,7 @@
434
442
 
435
443
  // Check for multiple H1 tags
436
444
  await checkTags(html_to_validate[i]);
437
-
445
+
438
446
  // Build list content for Google
439
447
  listContent += `/${html_to_validate[i].relativePath.replace(path.extname(html_to_validate[i].relativePath), '')}`;
440
448
  if (i < html_to_validate.length - 1) {
@@ -467,21 +475,24 @@
467
475
  console.log('\r\n-----------------------');
468
476
  console.log(' Validation Output ');
469
477
  console.log('-----------------------');
470
- if (errorcount > 0) {
471
- console.log(`\r\n${errorcount} Validation Errors Found\r\n`);
478
+ if (Object.keys(errors).length > 0) {
479
+ let error_count = 0;
472
480
  for (const key in errors) {
473
481
  if (errors.hasOwnProperty(key) && errors[key].length > 0) {
474
482
  console.log(`\r\n${errors[key].length} error(s) in ${key}`);
475
483
  for (let i = 0; i < errors[key].length; i++) {
476
484
  console.log(` - ${errors[key][i]}`);
477
- errorcount++;
485
+ error_count++
478
486
  }
479
487
  }
480
488
  }
481
- return false;
489
+ if (error_count > 0) {
490
+ console.log(`\r\n${error_count} Validation Errors Found`);
491
+ return false;
492
+ }
482
493
  }
483
494
 
484
- console.log(`\r\nNo Validation Errors Found!\r\n`);
495
+ console.log(`\r\nNo Validation Errors Found!`);
485
496
  return true;
486
497
  };
487
498
  })();
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "hdoc-tools",
3
- "version": "0.9.21",
3
+ "version": "0.9.23",
4
4
  "description": "Hornbill HDocBook Development Support Tool",
5
5
  "main": "hdoc.js",
6
6
  "bin": {
package/ui/index.html CHANGED
@@ -99,14 +99,14 @@
99
99
  <i v-bind:class="{'bi bi-chevron-right': !asection.expand,'bi bi-chevron-down': asection.expand}" class="bi"></i>
100
100
  </div>
101
101
  </div>
102
- <a class="title-text">{{asection.text}}</a>
102
+ <a class="title-text"><i v-if="asection.draft" class="bi bi-exclamation-triangle-fill text-danger" title="This section is set to draft."></i> {{asection.text}}</a>
103
103
  </div>
104
104
  <div v-show="asection.expand && asection.items" v-for="(navSectionItem, index) in asection.items" class="items">
105
105
 
106
106
  <!-- if navSectionItem has no items show clickable link -->
107
107
  <div v-if="!navSectionItem.items">
108
108
  <a class="DocLink link noitems" v-bind:href="navSectionItem.link" v-bind:target="navSectionItem.target || ''" style="padding-left: 0px;">
109
- <span class="link-text">{{navSectionItem.text}} <i v-if="navSectionItem.target" class="bi bi-box-arrow-up-right"></i> </span>
109
+ <span class="link-text"><i v-if="navSectionItem.draft" class="bi bi-exclamation-triangle-fill text-danger" title="This page is set to draft."></i> {{navSectionItem.text}} <i v-if="navSectionItem.target" class="bi bi-box-arrow-up-right"></i> </span>
110
110
  </a>
111
111
  </div>
112
112