hdoc-tools 0.8.2 → 0.8.3
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 +21 -3
- package/hdoc-db.js +2 -2
- package/hdoc-module.js +6 -2
- package/package.json +1 -1
package/hdoc-build.js
CHANGED
|
@@ -205,6 +205,15 @@ const {
|
|
|
205
205
|
if (element.extension === 'md') {
|
|
206
206
|
md_files.push(element);
|
|
207
207
|
} else {
|
|
208
|
+
// File is html, see if there's a matching md file and if there is then ignore the html
|
|
209
|
+
let html_path = element.path.replace(path.extname(element.path), '.html');
|
|
210
|
+
if (fs.existsSync(html_path)) {
|
|
211
|
+
return;
|
|
212
|
+
}
|
|
213
|
+
html_path = element.path.replace(path.extname(element.path), '.htm');
|
|
214
|
+
if (fs.existsSync(html_path)) {
|
|
215
|
+
return;
|
|
216
|
+
}
|
|
208
217
|
static_html_files.push(element);
|
|
209
218
|
}
|
|
210
219
|
};
|
|
@@ -309,8 +318,9 @@ const {
|
|
|
309
318
|
if (table_created !== null) {
|
|
310
319
|
console.log(`Error creating table: ${table_created}`);
|
|
311
320
|
} else {
|
|
312
|
-
console.log(`Virtual table created: ${
|
|
321
|
+
console.log(`Virtual table created: ${table_name}`);
|
|
313
322
|
if (!hdocbook_config.tags) hdocbook_config.tags = [];
|
|
323
|
+
let index_success_count = 0;
|
|
314
324
|
for (let i = 0; i < index_records.length; i++) {
|
|
315
325
|
const index_vals = [
|
|
316
326
|
index_records[i].relative_path.replace('\\', '/').replace(`${hdocbook_config.docId}/`, ''),
|
|
@@ -320,9 +330,17 @@ const {
|
|
|
320
330
|
index_records[i].index_html.fm_props.title,
|
|
321
331
|
index_records[i].index_html.text
|
|
322
332
|
];
|
|
323
|
-
hdoc_index.insert_record(db, table_name, index_cols, index_vals, hdocbook_config.docId, index_records[i].index_html.fm_props.title);
|
|
333
|
+
let new_record_id = hdoc_index.insert_record(db, table_name, index_cols, index_vals, hdocbook_config.docId, index_records[i].index_html.fm_props.title);
|
|
334
|
+
if (!new_record_id) {
|
|
335
|
+
console.log(`Index record creation failed - ${hdocbook_config.docId}/${index_records[i].index_html.fm_props.title}: ${e}`);
|
|
336
|
+
continue;
|
|
337
|
+
}
|
|
338
|
+
index_success_count++;
|
|
339
|
+
if (verbose) {
|
|
340
|
+
console.log(`Inserted index record ${new_record_id}: ${hdocbook_config.docId} - ${index_records[i].index_html.fm_props.title}`);
|
|
341
|
+
}
|
|
324
342
|
}
|
|
325
|
-
console.log(`\nIndex Build Complete
|
|
343
|
+
console.log(`\nIndex Build Complete. ${index_success_count} records created.`);
|
|
326
344
|
}
|
|
327
345
|
|
|
328
346
|
try {
|
package/hdoc-db.js
CHANGED
|
@@ -43,9 +43,9 @@
|
|
|
43
43
|
try {
|
|
44
44
|
const stmt = db.prepare(queryProps.join('\n'));
|
|
45
45
|
const info = stmt.run(values);
|
|
46
|
-
|
|
46
|
+
return info.lastInsertRowid;
|
|
47
47
|
} catch (e) {
|
|
48
|
-
|
|
48
|
+
return false;
|
|
49
49
|
}
|
|
50
50
|
};
|
|
51
51
|
|
package/hdoc-module.js
CHANGED
|
@@ -172,9 +172,13 @@
|
|
|
172
172
|
// We have a Frontmatter header - return each property in an array
|
|
173
173
|
const fm_properties = child.data.split(/\r?\n/);
|
|
174
174
|
for (let i = 0; i < fm_properties.length; i++) {
|
|
175
|
-
const property_details = fm_properties[i].split(
|
|
175
|
+
const property_details = fm_properties[i].split(/:(.*)/s);
|
|
176
176
|
if (property_details.length > 1) {
|
|
177
|
-
|
|
177
|
+
let prop_val = property_details[i].trim();
|
|
178
|
+
if (/^".*"$/.test(prop_val)) {
|
|
179
|
+
prop_val = prop_val.substring(1, prop_val.length - 1);
|
|
180
|
+
}
|
|
181
|
+
response.fm_properties[property_details[0].trim().toLowerCase()] = prop_val;
|
|
178
182
|
}
|
|
179
183
|
}
|
|
180
184
|
|