hdoc-tools 0.8.31 → 0.8.33

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
@@ -21,7 +21,8 @@
21
21
  'book_id',
22
22
  'contributor_count INTEGER UNINDEXED',
23
23
  'edit_url UNINDEXED',
24
- 'last_commit UNINDEXED'
24
+ 'last_commit UNINDEXED',
25
+ 'pdf_size INTEGER UNINDEXED'
25
26
  ],
26
27
  hdoc_contributors: [
27
28
  'resource_url',
@@ -102,7 +103,8 @@
102
103
  doc_id,
103
104
  index_records[i].metadata.contributor_count,
104
105
  index_records[i].metadata.edit_url,
105
- index_records[i].metadata.last_commit
106
+ index_records[i].metadata.last_commit,
107
+ index_records[i].pdf_size
106
108
  ];
107
109
  const meta_response = hdoc_index.insert_record(db, 'hdoc_meta', db_schema.hdoc_meta, meta_vals);
108
110
  if (!meta_response.success) {
package/hdoc-build-pdf.js CHANGED
@@ -17,7 +17,6 @@
17
17
 
18
18
  let css_files = [],
19
19
  hb_logo = '',
20
- header = '',
21
20
  footer = '';
22
21
 
23
22
  const file_callback = function (element) {
@@ -98,7 +97,7 @@
98
97
 
99
98
  exports.generate_pdf = async function (pdf_template_path, pdf_template_content, book_config, html_source, target_file, verbose = false) {
100
99
  if (verbose) console.log(`Generating PDF: ${target_file}`);
101
-
100
+ let pdf_size = 0;
102
101
  // Cache footer
103
102
  if (footer === '') footer = get_footer(pdf_template_path);
104
103
 
@@ -111,7 +110,7 @@
111
110
  hb_logo = `data:image/svg+xml;base64,${hb_logo}`;
112
111
  } catch (err) {
113
112
  console.log('Error reading logo from template:', err);
114
- return;
113
+ return pdf_size;
115
114
  }
116
115
  }
117
116
 
@@ -143,7 +142,7 @@
143
142
  }
144
143
 
145
144
  try {
146
- await page.pdf({
145
+ const pdf_gen = await page.pdf({
147
146
  path: target_file,
148
147
  margin: {
149
148
  top: '30px',
@@ -159,11 +158,13 @@
159
158
  });
160
159
  if (verbose) console.log('PDF generation success.');
161
160
 
161
+ pdf_size = pdf_gen.byteLength;
162
162
  } catch (err) {
163
163
  console.log(`Error generating PDF ${target_file} - ${err}`);
164
164
  }
165
165
 
166
166
  // Close the browser instance
167
167
  await browser.close();
168
+ return pdf_size;
168
169
  };
169
170
  })();
package/hdoc-build.js CHANGED
@@ -227,13 +227,14 @@
227
227
  if (pdf_enable && !pdf_path_excluded(file_path.relativePath)) pdf_header = process_doc_header(fm_headers, file_path.relativePath, pdf_header_template_non_git);
228
228
  }
229
229
 
230
+ let pdf_size = 0;
230
231
  if (pdf_enable && !pdf_path_excluded(file_path.relativePath)) {
231
232
  let pdf_txt = await hdoc_build_pdf.process_images(file_path, html_txt);
232
233
  pdf_txt = `${pdf_header}\n${pdf_txt}`;
233
234
 
234
235
  // Generate PDF file from HTML
235
236
  const pdf_file_path = file_path.path.replace(path.extname(file_path.path), '.pdf');
236
- await hdoc_build_pdf.generate_pdf(pdf_template_path, pdf_template, hdocbook_config, pdf_txt, pdf_file_path, verbose);
237
+ pdf_size = await hdoc_build_pdf.generate_pdf(pdf_template_path, pdf_template, hdocbook_config, pdf_txt, pdf_file_path, verbose);
237
238
  }
238
239
 
239
240
  html_txt = `${fm_header_content}\n${doc_header}\n${html_txt}`;
@@ -242,7 +243,8 @@
242
243
  relative_path: file_path.relativePath,
243
244
  index_html: hdoc_index.transform_html_for_index(html_txt),
244
245
  metadata: metadata,
245
- contributors: contribs
246
+ contributors: contribs,
247
+ pdf_size: pdf_size
246
248
  });
247
249
  // Save HTML into HTML file
248
250
  try {
@@ -425,14 +427,15 @@
425
427
  doc_header = process_doc_header(fm_headers, file_path.relativePath, doc_header_template_non_git);
426
428
  if (pdf_enable && !pdf_path_excluded(file_path.relativePath)) pdf_header = process_doc_header(fm_headers, file_path.relativePath, pdf_header_template_non_git);
427
429
  }
428
-
430
+
431
+ let pdf_size = 0;
429
432
  if (pdf_enable && !pdf_path_excluded(file_path.relativePath)) {
430
433
  let pdf_txt = await hdoc_build_pdf.process_images(file_path, html_txt);
431
434
  pdf_txt = `${pdf_header}\n${pdf_txt}`;
432
435
 
433
436
  // Generate PDF file from HTML
434
437
  const pdf_file_path = file_path.path.replace(path.extname(file_path.path), '.pdf');
435
- await hdoc_build_pdf.generate_pdf(pdf_template_path, pdf_template, hdocbook_config, pdf_txt, pdf_file_path, verbose);
438
+ pdf_size = await hdoc_build_pdf.generate_pdf(pdf_template_path, pdf_template, hdocbook_config, pdf_txt, pdf_file_path, verbose);
436
439
  }
437
440
 
438
441
  html_txt = `${fm_header}\n${doc_header}\n${html_txt}`;
@@ -452,7 +455,8 @@
452
455
  relative_path: relative_path,
453
456
  index_html: index_details,
454
457
  metadata: metadata,
455
- contributors: contribs
458
+ contributors: contribs,
459
+ pdf_size: pdf_size
456
460
  });
457
461
 
458
462
  // Delete MD file from _work path
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "hdoc-tools",
3
- "version": "0.8.31",
3
+ "version": "0.8.33",
4
4
  "description": "Hornbill HDocBook Development Support Tool",
5
5
  "main": "hdoc.js",
6
6
  "bin": {
@@ -74,6 +74,7 @@ table {
74
74
  border-collapse: collapse;
75
75
  margin: 20px 0;
76
76
  font-size: var(--htl-default-font-size);
77
+ break-inside: avoid;
77
78
  /* sets font-size for table and table rows/td/th etc*/
78
79
  }
79
80
 
@@ -112,6 +113,9 @@ hr {
112
113
  img,
113
114
  svg {
114
115
  display: inline-block;
116
+ max-height: 750px;
117
+ height: auto;
118
+ break-inside: avoid;
115
119
  }
116
120
 
117
121
  video,
@@ -130,7 +134,9 @@ figure {
130
134
  img,
131
135
  video {
132
136
  max-width: 100%;
137
+ max-height: 750px;
133
138
  height: auto;
139
+ break-inside: avoid;
134
140
  }
135
141
 
136
142
  .header {
@@ -166,6 +172,7 @@ video {
166
172
  font-size: var(--htl-small-font-size);
167
173
  }
168
174
 
175
+
169
176
  .hdoc-alert {
170
177
  border: 1px solid transparent;
171
178
  border-radius: 8px;
@@ -174,6 +181,7 @@ video {
174
181
  font-size: var(--htl-default-font-size);
175
182
  color: var(--htl-c-text-2);
176
183
  margin: 10px 0;
184
+ break-inside: avoid;
177
185
  }
178
186
 
179
187
  .hdoc-alert p {