web-documentation 1.0.24 → 1.0.25

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 CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "web-documentation",
3
- "version": "1.0.24",
3
+ "version": "1.0.25",
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.1413",
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",
@@ -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
- <!--Backend generated one indicator: "# heading"-->
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: {knownTranslation: '.doc-toc'}}"
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: '.doc-toc',
101
- tableOfContentLinks: '.doc-toc ul li a[href^="#"]'
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 afterwards and resolve the
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.append(createDomNodes(listItemsHTML))
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 = 'initial'
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
@@ -6,6 +6,8 @@ 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
  /*
@@ -24,29 +26,26 @@ export default (options) => {
24
26
  marked.setOptions(options)
25
27
  // Include an id attribute when emitting headings (h1, h2, h3, ...).
26
28
  marked.use(gfmHeadingId(
27
- {prefix: 'doc-'}/* TODO,
28
-
29
- {
30
- hooks: {
31
- postprocess(html) {
32
- const headings = getHeadingList()
33
-
34
-
35
- NOTE: We do not wrap with an initial UL tag since H1
36
- should be ignored. It is only existing once for SEO
37
- purposes.
38
- * /
39
- return `
40
- ${headings.map(({
41
- id,
42
- raw,
43
- level
44
- }) => `<li><a href="#${id}">${raw}</a></li>`)}
45
- ${html}
29
+ {prefix: 'wd-heading-'},
30
+ {
31
+ hooks: {
32
+ // Adds an autogenerated table of contents list.
33
+ postprocess: (html) => {
34
+ const headings = getHeadingList()
35
+ const tableOfContents = `
36
+ <ul>${
37
+ headings
38
+ .map(({id, raw, level}) =>
39
+ `<li><a href="#${id}">${raw}</a></li>`
40
+ )
41
+ .join('\n')
42
+ }</ul>
46
43
  `
44
+
45
+ return html.replace(TOC_INDICATOR_HTML, tableOfContents)
47
46
  }
48
47
  }
49
- }*/
48
+ }
50
49
  ))
51
50
  // Favors self-closing xhtml tags.
52
51
  marked.use(markedXhtml())