How to use the htmlparser2.DomUtils.getInnerHTML function in htmlparser2

To help you get started, we’ve selected a few htmlparser2 examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github Smithsonian / dpo-cook / source / server / tasks / MigratePlayTask.ts View on Github external
}, contentDiv.children, true);

        // fetch all images
        const urls = Object.keys(imageUrls);
        const promises: Promise[] = urls.map(url => {
            console.log(`fetchArticle - fetching image from ${url}`);
            return fetch.buffer(url, "GET").then(image => {
                const imageFileName = imageUrls[url];
                const imageFilePath = this.getFilePath(imageFileName);
                console.log(`fetchArticle - writing image to ${imageFilePath}`);
                return fs.writeFile(imageFilePath, Buffer.from(image))
            });
        });

        // write article HTML content
        const contentHtml = DomUtils.getInnerHTML(contentDiv);
        const articleFileName = `${this.articlesDir}/article-${articleIndex}.html`;
        this.result.files[`scene_${articleFileName}`] = articleFileName;
        const articleFilePath = this.getFilePath(articleFileName);
        promises.push(fs.writeFile(articleFilePath, contentHtml));

        return Promise.all(promises);
    }
github Smithsonian / dpo-cook / source / server / migration / playArticleTools.ts View on Github external
}, contentDiv.children, true);

    // fetch all images
    const urls = Object.keys(imageUrls);
    const promises: Promise[] = urls.map(url => {
        console.log(`fetchArticle - fetching image from ${url}`);
        return fetch.buffer(url, "GET").then(image => {
            const imageFileName = imageUrls[url];
            const imageFilePath = path.resolve(context.job.jobDir, imageFileName);
            console.log(`fetchArticle - writing image to ${imageFilePath}`);
            return fs.writeFile(imageFilePath, Buffer.from(image))
        });
    });

    // write article HTML content
    const contentHtml = DomUtils.getInnerHTML(contentDiv);
    const articleFileName = `${context.articleDir}/article-${articleIndex}.html`;
    context.files[articleFileName] = articleFileName;
    const articleFilePath = path.resolve(context.job.jobDir, articleFileName);
    promises.push(fs.writeFile(articleFilePath, contentHtml));

    return Promise.all(promises);
}
github realywithoutname / mini-program-webpack-loader / src / helpers / wxml.js View on Github external
let attrKeys = Object.keys(attribs)

      /**
       * 抽象组件处理
       * 如果作死有这个鬼那就ooo了
       */
      if (/generic:/.test(attrKeys.join(';'))) {
        attrKeys.forEach(key => {
          /generic:/.test(key) && tags.push(attribs[key])
        })
      }

      handle && handle(componnets, el, componnets.has(name), this.request)
    })

    content = DomUtils.getInnerHTML({ children: dom })

    tags.length && this.writeToComponent(tags)

    return new ConcatSource(content)
  }
}
github realywithoutname / mini-program-webpack-loader / src / ali / transxml.js View on Github external
if (dom.length > 1) {
        dom = [{
          type: 'tag',
          name: 'view',
          attribs: {
            class: '{{ rootClass }}',
            id: '{{ id }}',
            onTap: '$_tap',
            'data-parent': '{{ parentData }}'
          },
          children: dom
        }]
      }
    }

    content = DomUtils.getInnerHTML({
      children: dom
    })

    assets[distPath] = new ConcatSource(content)
  }

  for (const file of tree.jsons) {
    let fileMeta = tree.getFile(file)

    if (fileMeta.generics.size) {
      let wxmlPath = file.replace('.json', '.wxml')
      let distJsonPath = toTargetPath(utils.getDistPath(file))
      let distWxmlPath = toTargetPath(utils.getDistPath(wxmlPath))
      let jsonFileContent = JSON.parse(getAssetContent(file, compilation))
      let wxmlFileContent = assets[distWxmlPath].source().toString()
github realywithoutname / mini-program-webpack-loader / src / ali / transxml.js View on Github external
<${propName} />
        `, (el) => {
          if (el.name === propName) {
            el.attribs = { ...attribs }
            el.children = children
          }
        })

        parent.children.splice(index, 0, genericDom[0])
      })

      attribs['a:else'] = 'true'
    }
  })

  DomUtils.getInnerHTML({ children: dom })
  return new ConcatSource(DomUtils.getInnerHTML({ children: dom }))
}
github realywithoutname / mini-program-webpack-loader / src / ali / transxml.js View on Github external
`, (el) => {
          if (el.name === propName) {
            el.attribs = { ...attribs }
            el.children = children
          }
        })

        parent.children.splice(index, 0, genericDom[0])
      })

      attribs['a:else'] = 'true'
    }
  })

  DomUtils.getInnerHTML({ children: dom })
  return new ConcatSource(DomUtils.getInnerHTML({ children: dom }))
}