web-documentation 1.0.24 → 1.0.26
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/package.json +2 -2
- package/source/dummyReadme.md +2 -3
- package/source/index.ts +16 -8
- package/source/renderMarkdown.mjs +23 -23
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "web-documentation",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.26",
|
|
4
4
|
"description": "Declarative multilanguage documentation website generator",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"documentation",
|
|
@@ -68,7 +68,7 @@
|
|
|
68
68
|
"@webcomponents/webcomponentsjs": "^2.8.0",
|
|
69
69
|
"archiver": "^8.0.0",
|
|
70
70
|
"bootstrap-icons": "^1.13.1",
|
|
71
|
-
"clientnode": "^4.0.
|
|
71
|
+
"clientnode": "^4.0.1414",
|
|
72
72
|
"css-loader": "^7.1.4",
|
|
73
73
|
"cssnano": "^8.0.1",
|
|
74
74
|
"default-gateway": "^7.2.2",
|
package/source/dummyReadme.md
CHANGED
|
@@ -60,11 +60,10 @@ You need utilities for:<!--deDE:Sie benötigen Hilfsfunktionen für:-->
|
|
|
60
60
|
- URLs
|
|
61
61
|
|
|
62
62
|
<!--Place for automatic generated table of contents.-->
|
|
63
|
-
|
|
64
|
-
<!--Clientside generated version indicator:-->
|
|
65
|
-
<div class="doc-toc" style="display: none">
|
|
63
|
+
<div class="wd-table-of-contents" style="display: none">
|
|
66
64
|
<!--|deDE:Inhalt-->
|
|
67
65
|
<h2 id="content">Content</h2>
|
|
66
|
+
<!--wd-table-of-contents-->
|
|
68
67
|
</div>
|
|
69
68
|
|
|
70
69
|
<!--|deDE:Installation-->
|
package/source/index.ts
CHANGED
|
@@ -76,7 +76,9 @@ export class WebDocumentation<
|
|
|
76
76
|
}}"
|
|
77
77
|
>
|
|
78
78
|
<web-internationalization
|
|
79
|
-
options="{selectors: {
|
|
79
|
+
options="{selectors: {
|
|
80
|
+
knownTranslation: '.wd-table-of-contents'
|
|
81
|
+
}}"
|
|
80
82
|
>
|
|
81
83
|
<slot>Please provide a template to transclude.</slot>
|
|
82
84
|
</web-internationalization>
|
|
@@ -97,8 +99,8 @@ export class WebDocumentation<
|
|
|
97
99
|
'.section__home h1, .section__home h2, ' +
|
|
98
100
|
'.section__home h3, .section__home h4, ' +
|
|
99
101
|
'.section__home h5, .section__home h6',
|
|
100
|
-
tableOfContent: '.
|
|
101
|
-
tableOfContentLinks: '.
|
|
102
|
+
tableOfContent: '.wd-table-of-contents',
|
|
103
|
+
tableOfContentLinks: '.wd-table-of-contents ul li a[href^="#"]'
|
|
102
104
|
},
|
|
103
105
|
|
|
104
106
|
showExample: {
|
|
@@ -170,7 +172,7 @@ export class WebDocumentation<
|
|
|
170
172
|
* @param reason - Why an update has been triggered.
|
|
171
173
|
* @param resolveRendering - Indicates whether rendering should be resolved
|
|
172
174
|
* finally. Should be set to "false" via super calls in inherited render
|
|
173
|
-
* methods which do further dom manipulations
|
|
175
|
+
* methods which do further dom manipulations afterward and resolve the
|
|
174
176
|
* rendering process by their own.
|
|
175
177
|
* @returns A promise resolving when rendering has finished. A promise may
|
|
176
178
|
* be needed for classes inheriting from this class.
|
|
@@ -253,8 +255,6 @@ export class WebDocumentation<
|
|
|
253
255
|
if (first)
|
|
254
256
|
firstLevel = newLevel
|
|
255
257
|
|
|
256
|
-
console.log('A', newLevel)
|
|
257
|
-
|
|
258
258
|
if (newLevel > level)
|
|
259
259
|
listItemsHTML += '<ul>'
|
|
260
260
|
else if (newLevel < level)
|
|
@@ -277,7 +277,14 @@ export class WebDocumentation<
|
|
|
277
277
|
level += 1
|
|
278
278
|
}
|
|
279
279
|
|
|
280
|
-
this.tableOfContentDomNode.
|
|
280
|
+
for (const domNode of this.tableOfContentDomNode.childNodes)
|
|
281
|
+
if (
|
|
282
|
+
domNode.nodeType === Node.COMMENT_NODE &&
|
|
283
|
+
domNode.nodeValue === 'wd-table-of-contents'
|
|
284
|
+
) {
|
|
285
|
+
domNode.after(createDomNodes(listItemsHTML))
|
|
286
|
+
domNode.remove()
|
|
287
|
+
}
|
|
281
288
|
|
|
282
289
|
this.tableOfContentLinkDomNodes =
|
|
283
290
|
this.tableOfContentDomNode.querySelectorAll<HTMLAnchorElement>(
|
|
@@ -302,7 +309,8 @@ export class WebDocumentation<
|
|
|
302
309
|
}
|
|
303
310
|
)
|
|
304
311
|
|
|
305
|
-
this.tableOfContentDomNode.style.display
|
|
312
|
+
if (this.tableOfContentDomNode.style.display === 'none')
|
|
313
|
+
this.tableOfContentDomNode.style.display = 'initial'
|
|
306
314
|
}
|
|
307
315
|
/**
|
|
308
316
|
* This method makes dotes after code lines which are too long. This
|
|
@@ -1,11 +1,13 @@
|
|
|
1
1
|
import {Marked} from 'marked'
|
|
2
|
-
import {gfmHeadingId} from 'marked-gfm-heading-id'
|
|
2
|
+
import {gfmHeadingId, getHeadingList} from 'marked-gfm-heading-id'
|
|
3
3
|
import {markedHighlight} from 'marked-highlight'
|
|
4
4
|
import highlightJSModule from 'highlight.js'
|
|
5
5
|
import {markedXhtml} from 'marked-xhtml'
|
|
6
6
|
|
|
7
7
|
const {getLanguage, highlight} = highlightJSModule
|
|
8
8
|
|
|
9
|
+
const TOC_INDICATOR_HTML = '<!--wd-table-of-contents-->'
|
|
10
|
+
|
|
9
11
|
const marked = new Marked(
|
|
10
12
|
markedHighlight({
|
|
11
13
|
/*
|
|
@@ -22,32 +24,30 @@ const marked = new Marked(
|
|
|
22
24
|
|
|
23
25
|
export default (options) => {
|
|
24
26
|
marked.setOptions(options)
|
|
25
|
-
// Include an id attribute when emitting headings (h1, h2, h3, ...).
|
|
26
|
-
marked.use(gfmHeadingId(
|
|
27
|
-
{prefix: 'doc-'}/* TODO,
|
|
28
|
-
|
|
29
|
-
{
|
|
30
|
-
hooks: {
|
|
31
|
-
postprocess(html) {
|
|
32
|
-
const headings = getHeadingList()
|
|
33
27
|
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
28
|
+
// Include an id attribute when emitting headings (h1, h2, h3, ...).
|
|
29
|
+
marked.use(
|
|
30
|
+
gfmHeadingId({prefix: 'wd-heading-'}),
|
|
31
|
+
{
|
|
32
|
+
hooks: {
|
|
33
|
+
// Adds an autogenerated table of contents list.
|
|
34
|
+
postprocess: (html) => {
|
|
35
|
+
const headings = getHeadingList()
|
|
36
|
+
const tableOfContents = `
|
|
37
|
+
<ul>${
|
|
38
|
+
headings
|
|
39
|
+
.map(({id, raw, level}) =>
|
|
40
|
+
`<li><a href="#${id}">${raw}</a></li>`
|
|
41
|
+
)
|
|
42
|
+
.join('\n')
|
|
43
|
+
}</ul>
|
|
46
44
|
`
|
|
45
|
+
|
|
46
|
+
return html.replace(TOC_INDICATOR_HTML, tableOfContents)
|
|
47
47
|
}
|
|
48
48
|
}
|
|
49
|
-
}
|
|
50
|
-
)
|
|
49
|
+
}
|
|
50
|
+
)
|
|
51
51
|
// Favors self-closing xhtml tags.
|
|
52
52
|
marked.use(markedXhtml())
|
|
53
53
|
|