hdoc-tools 0.7.5 → 0.7.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-stats.js +25 -21
- package/package.json +1 -3
- package/ui/index.html +3 -3
- package/ui/js/doc.hornbill.js +7 -2
package/hdoc-stats.js
CHANGED
|
@@ -8,7 +8,6 @@
|
|
|
8
8
|
const path = require('path');
|
|
9
9
|
const dree = require('dree');
|
|
10
10
|
const html2text = require('html-to-text');
|
|
11
|
-
const { markdownToTxt } = require('markdown-to-txt');
|
|
12
11
|
const wordsCount = require('words-count').default;
|
|
13
12
|
|
|
14
13
|
// Regex to remove Hornbill-specific tags
|
|
@@ -21,32 +20,19 @@
|
|
|
21
20
|
mdFiles: {},
|
|
22
21
|
staticHTMLFiles: {}
|
|
23
22
|
};
|
|
24
|
-
|
|
23
|
+
|
|
24
|
+
let markdownFiles = [];
|
|
25
|
+
|
|
26
|
+
// File callback for scan
|
|
25
27
|
const fileCallback = function(element) {
|
|
26
28
|
if (element.extension === 'md' ) {
|
|
27
|
-
|
|
28
|
-
// Read markdown file as string
|
|
29
|
-
const md = fs.readFileSync(element.path, 'utf8');
|
|
30
|
-
|
|
31
|
-
// Strip out standard MD tags
|
|
32
|
-
let text = markdownToTxt(md);
|
|
33
|
-
|
|
34
|
-
// Strip out any Hornbill Docs specific markdown tags
|
|
35
|
-
text = text.replaceAll(hbMDTagRegex, '');
|
|
36
|
-
|
|
37
|
-
// Do the wordcount and add to status
|
|
38
|
-
const wordCount = wordsCount(text);
|
|
39
|
-
stats.totalWordCount += wordCount;
|
|
40
|
-
stats.mdFiles[element.relativePath] = {
|
|
41
|
-
wordCount: wordCount,
|
|
42
|
-
sizeInBytes: element.sizeInBytes
|
|
43
|
-
};
|
|
29
|
+
markdownFiles.push(element);
|
|
44
30
|
stats.totalMDFiles++;
|
|
45
31
|
} else {
|
|
46
32
|
// file must be html
|
|
47
33
|
const mdFilePath = element.path.slice(0, element.path.lastIndexOf('.')) + '.md';
|
|
34
|
+
//Do we have a matching MD file - if not, then word count the HTML
|
|
48
35
|
if (!fs.existsSync(mdFilePath)) {
|
|
49
|
-
//Do we have a matching MD file - if not, then word count the HTML
|
|
50
36
|
stats.totalStaticHTMLFiles++;
|
|
51
37
|
const html = fs.readFileSync(element.path, 'utf8');
|
|
52
38
|
const text = html2text.convert(html, {
|
|
@@ -120,7 +106,25 @@
|
|
|
120
106
|
|
|
121
107
|
// Scan content path directory, send file info to callback for processing
|
|
122
108
|
dree.scan(bookPath, dreeOptions, fileCallback);
|
|
123
|
-
|
|
109
|
+
markdownFiles.forEach(function(element){
|
|
110
|
+
// Load markdown file
|
|
111
|
+
let md_txt = fs.readFileSync(element.path, 'utf8');
|
|
112
|
+
|
|
113
|
+
// Render markdown into HTML
|
|
114
|
+
var html_txt = md.render(md_txt.toString());
|
|
115
|
+
const text = html2text.convert(html_txt, {
|
|
116
|
+
wordwrap: null
|
|
117
|
+
});
|
|
118
|
+
|
|
119
|
+
// Do the wordcount and add to status
|
|
120
|
+
const wordCount = wordsCount(text);
|
|
121
|
+
stats.totalWordCount += wordCount;
|
|
122
|
+
stats.mdFiles[element.relativePath] = {
|
|
123
|
+
wordCount: wordCount,
|
|
124
|
+
sizeInBytes: element.sizeInBytes
|
|
125
|
+
};
|
|
126
|
+
});
|
|
127
|
+
|
|
124
128
|
if (verbose) {
|
|
125
129
|
// Output verbose stats
|
|
126
130
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "hdoc-tools",
|
|
3
|
-
"version": "0.7.
|
|
3
|
+
"version": "0.7.7",
|
|
4
4
|
"description": "Hornbill HDocBook Development Support Tool",
|
|
5
5
|
"main": "hdoc.js",
|
|
6
6
|
"bin": {
|
|
@@ -33,11 +33,9 @@
|
|
|
33
33
|
"highlight.js": "^11.6.0",
|
|
34
34
|
"html-to-text": "^8.2.1",
|
|
35
35
|
"js-yaml": "^4.1.0",
|
|
36
|
-
"lodash": "^4.17.21",
|
|
37
36
|
"markdown-it": "^13.0.1",
|
|
38
37
|
"markdown-it-container": "^3.0.0",
|
|
39
38
|
"markdown-it-front-matter": "^0.2.3",
|
|
40
|
-
"markdown-to-txt": "^2.0.1",
|
|
41
39
|
"multer": "^1.4.5-lts.1",
|
|
42
40
|
"prompt": "^1.3.0",
|
|
43
41
|
"stream": "0.0.2",
|
package/ui/index.html
CHANGED
|
@@ -21,7 +21,7 @@
|
|
|
21
21
|
<style>
|
|
22
22
|
.hb-hidden
|
|
23
23
|
{
|
|
24
|
-
visibility:hidden;
|
|
24
|
+
visibility:hidden !important;
|
|
25
25
|
}
|
|
26
26
|
|
|
27
27
|
</style>
|
|
@@ -155,10 +155,10 @@
|
|
|
155
155
|
</div>
|
|
156
156
|
|
|
157
157
|
<!-- 100% horizontal col below toolbar and auto adjust vertical to take rest of avail height -->
|
|
158
|
-
<div class="main-layout hb-container-horizontal hb-container-expand">
|
|
158
|
+
<div class="main-layout hb-container-horizontal hb-container-expand hb-hidden">
|
|
159
159
|
|
|
160
160
|
<!-- the left hand nav col -->
|
|
161
|
-
<aside class="DocSidebar hb-container-vertical">
|
|
161
|
+
<aside class="DocSidebar hb-container-vertical hb-hidden">
|
|
162
162
|
|
|
163
163
|
<nav class="nav hb-container-expand" id="DocSidebarNav" aria-labelledby="sidebar-aria-label" tabindex="-1">
|
|
164
164
|
<div v-for="(navSection,index) in docApp.navSections" v-bind:class="{'group':navSection.items, 'nogrouplink':!navSection.items}">
|
package/ui/js/doc.hornbill.js
CHANGED
|
@@ -491,24 +491,29 @@ async function intialiseApp() {
|
|
|
491
491
|
//-- now render out the nav menu
|
|
492
492
|
view.renderNavigation();
|
|
493
493
|
|
|
494
|
-
$("#vDocDevApp").removeClass("hb-hidden");
|
|
495
494
|
|
|
496
495
|
setTimeout(function()
|
|
497
|
-
{
|
|
496
|
+
{
|
|
498
497
|
listenForHrefClicks();
|
|
499
498
|
|
|
500
499
|
//-- check if url is not root - in which case we need to load content for url
|
|
501
500
|
var initialLoadContentHref = window.location.href.replace(window.location.origin+"/","");
|
|
502
501
|
initialLoadContentHref = findFirstClickableBookLink(initialLoadContentHref);
|
|
502
|
+
|
|
503
503
|
if(initialLoadContentHref)
|
|
504
504
|
{
|
|
505
505
|
//-- find the link we are going to show and make sure parent/s are set to .expand=true
|
|
506
506
|
loadContentUrl(initialLoadContentHref,true,false);
|
|
507
|
+
|
|
508
|
+
|
|
507
509
|
}
|
|
508
510
|
else
|
|
509
511
|
{
|
|
510
512
|
console.log("initial first view link to laod is not present");
|
|
511
513
|
}
|
|
514
|
+
|
|
515
|
+
$(".hb-hidden").removeClass("hb-hidden");
|
|
516
|
+
|
|
512
517
|
},200);
|
|
513
518
|
});
|
|
514
519
|
});
|