web-documentation 1.0.29 → 1.0.31

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.29",
3
+ "version": "1.0.31",
4
4
  "description": "Declarative multilanguage documentation website generator",
5
5
  "keywords": [
6
6
  "documentation",
package/source/deploy.ts CHANGED
@@ -451,8 +451,7 @@ const isFileIgnored = async (filePath: string): Promise<boolean> => (
451
451
  */
452
452
  const copyRepositoryFile = async (
453
453
  sourcePath: string, targetPath: string, file: File
454
- ): Promise<false | undefined> =>
455
- {
454
+ ): Promise<false | undefined> => {
456
455
  if (await isFileIgnored(file.path) || basename(file.name) === 'readme.md')
457
456
  return false
458
457
 
package/source/index.ts CHANGED
@@ -438,9 +438,10 @@ export class WebDocumentation<
438
438
  .createElement('style')
439
439
  domNode.setAttribute('type', 'text/css')
440
440
  domNode.innerText = code
441
- } else if (match[2].toLowerCase() === 'hidden')
442
- domNode = code
443
- else {
441
+ } else if (match[2].toLowerCase() === 'hidden') {
442
+ domNode = createDomNodes(code)
443
+ reInjectScripts = true
444
+ } else {
444
445
  domNode = createDomNodes(format(
445
446
  this.options.showExample.htmlWrapper, code
446
447
  ))
@@ -455,24 +456,37 @@ export class WebDocumentation<
455
456
 
456
457
  codeDomNode.after(domNode)
457
458
 
458
- if (reInjectScripts) {
459
+ if (reInjectScripts)
459
460
  /*
460
461
  Injected script tags are not executed by
461
462
  default. So we need to reinject those.
462
463
  */
463
- for (const scriptDomNode of domNode.querySelectorAll('script')) {
464
- // const newScriptDomNode = scriptDomNode.cloneNode(true)
465
- const newScriptDomNode = document.createElement('script')
466
- for (const name of scriptDomNode.getAttributeNames())
467
- newScriptDomNode.setAttribute(name, scriptDomNode.getAttribute(name))
468
- newScriptDomNode.textContent = scriptDomNode.textContent
464
+ for (const scriptDomNode of
465
+ domNode.querySelectorAll('script')
466
+ ) {
467
+ const newScriptDomNode =
468
+ document.createElement('script')
469
+ for (const name of
470
+ scriptDomNode.getAttributeNames()
471
+ )
472
+ newScriptDomNode.setAttribute(
473
+ name,
474
+ scriptDomNode.getAttribute(name) as
475
+ string
476
+ )
477
+ newScriptDomNode.textContent =
478
+ scriptDomNode.textContent
469
479
  const promise = new Promise((resolve) => {
470
- newScriptDomNode.addEventListener('load', resolve)
480
+ newScriptDomNode.addEventListener(
481
+ 'load', resolve
482
+ )
471
483
  })
472
- scriptDomNode.parentNode.replaceChild(newScriptDomNode, scriptDomNode)
484
+ if (scriptDomNode.parentNode)
485
+ scriptDomNode.parentNode.replaceChild(
486
+ newScriptDomNode, scriptDomNode
487
+ )
473
488
  await promise
474
489
  }
475
- }
476
490
  } catch (error) {
477
491
  log.critical(
478
492
  `Error while integrating code "${code}":`,