hdoc-tools 0.8.4 → 0.8.7

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 CHANGED
@@ -312,6 +312,7 @@ const {
312
312
  console.log('Performing SQlite index creation...');
313
313
  let db_name = path.join(work_path, docId, 'index.db');
314
314
  const db = new Database(db_name);
315
+ db.pragma('encoding="UTF-8"');
315
316
  console.log(`\nDatabase created: ${db_name}`);
316
317
 
317
318
  // Now add the table
package/hdoc-db.js CHANGED
@@ -1,8 +1,7 @@
1
1
  (function () {
2
2
  'use strict';
3
3
 
4
- const ellipsize = require('ellipsize'),
5
- html2text = require('html-to-text'),
4
+ const html2text = require('html-to-text'),
6
5
  path = require('path'),
7
6
  hdoc = require(path.join(__dirname, 'hdoc-module.js'));
8
7
 
@@ -84,7 +83,7 @@
84
83
  uppercaseHeadings: false,
85
84
  wordwrap: null
86
85
  });
87
- response.preview = ellipsize(response.preview, 200).replace(/(?:\r\n|\r|\n)/g, ' ');
86
+ response.preview = hdoc.truncate_string(response.preview, 200, true).replace(/(?:\r\n|\r|\n)/g, ' ');
88
87
  return response;
89
88
  };
90
89
 
package/hdoc-module.js CHANGED
@@ -191,4 +191,10 @@
191
191
  }
192
192
  return response;
193
193
  };
194
+
195
+ exports.truncate_string = function( str, n, useWordBoundary ){
196
+ if (str.length <= n) { return str; }
197
+ const subString = str.slice(0, n-1);
198
+ return (useWordBoundary ? subString.slice(0, subString.lastIndexOf(" ")) : subString) + '…';
199
+ };
194
200
  })();
package/hdoc-stats.js CHANGED
@@ -4,11 +4,11 @@
4
4
 
5
5
  // Required modules
6
6
  // /const { STATUS_CODES } = require('http');
7
- const fs = require('fs');
8
- const path = require('path');
9
- const dree = require('dree');
10
- const html2text = require('html-to-text');
11
- const wordsCount = require('words-count').default;
7
+ const fs = require('fs'),
8
+ path = require('path'),
9
+ dree = require('dree'),
10
+ html2text = require('html-to-text'),
11
+ wordsCount = require('words-count').default;
12
12
 
13
13
  // Regex to remove Hornbill-specific tags
14
14
  const hbMDTagRegex = /(:{3}[ ]note)|(:{3}[ ]tip)|(:{3}[ ]important)|(:{3}[ ]caution)|(:{3}[ ]warning)|(:{3})/g;
@@ -103,6 +103,12 @@
103
103
  console.error('Could not load book configuration:\r\n', e);
104
104
  return;
105
105
  }
106
+ // Load markdown-it module
107
+ const md = require('markdown-it')({
108
+ html: true,
109
+ linkify: true,
110
+ typographer: true
111
+ });
106
112
 
107
113
  // Scan content path directory, send file info to callback for processing
108
114
  dree.scan(bookPath, dreeOptions, fileCallback);
@@ -110,7 +116,6 @@
110
116
  // Load markdown file
111
117
  let md_txt = fs.readFileSync(element.path, 'utf8');
112
118
 
113
- // Render markdown into HTML
114
119
  var html_txt = md.render(md_txt.toString());
115
120
  const text = html2text.convert(html_txt, {
116
121
  wordwrap: null
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "hdoc-tools",
3
- "version": "0.8.4",
3
+ "version": "0.8.7",
4
4
  "description": "Hornbill HDocBook Development Support Tool",
5
5
  "main": "hdoc.js",
6
6
  "bin": {
@@ -33,7 +33,6 @@
33
33
  "cheerio": "^1.0.0-rc.12",
34
34
  "cookie-parser": "^1.4.6",
35
35
  "dree": "^3.4.2",
36
- "ellipsize": "^0.5.1",
37
36
  "express": "^4.18.2",
38
37
  "fs-extra": "^11.1.0",
39
38
  "highlight.js": "^11.6.0",