hdoc-tools 0.8.4 → 0.8.5
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-stats.js +11 -6
- package/package.json +1 -1
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
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
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
|