How to use the html-to-react/lib/is-valid-node-definitions.alwaysValid function in html-to-react

To help you get started, we’ve selected a few html-to-react 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 neinteractiveliterature / intercode / app / javascript / parsePageContent.jsx View on Github external
export default function parsePageContent(content, componentMap = DEFAULT_COMPONENT_MAP) {
  const parser = new DOMParser();
  const doc = parser.parseFromString(content, 'text/html');
  const processingInstructions = buildProcessingInstructions(componentMap);
  const bodyComponents = traverseWithInstructions(
    doc.body.childNodes,
    IsValidNodeDefinitions.alwaysValid,
    processingInstructions,
  );
  const headComponents = traverseWithInstructions(
    doc.head.childNodes,
    IsValidNodeDefinitions.alwaysValid,
    processingInstructions,
  );
  return { bodyComponents, headComponents };
}
github neinteractiveliterature / intercode / app / javascript / parsePageContent.jsx View on Github external
export default function parsePageContent(content, componentMap = DEFAULT_COMPONENT_MAP) {
  const parser = new DOMParser();
  const doc = parser.parseFromString(content, 'text/html');
  const processingInstructions = buildProcessingInstructions(componentMap);
  const bodyComponents = traverseWithInstructions(
    doc.body.childNodes,
    IsValidNodeDefinitions.alwaysValid,
    processingInstructions,
  );
  const headComponents = traverseWithInstructions(
    doc.head.childNodes,
    IsValidNodeDefinitions.alwaysValid,
    processingInstructions,
  );
  return { bodyComponents, headComponents };
}

html-to-react

A lightweight library that converts raw HTML to a React DOM structure.

MIT
Latest version published 8 months ago

Package Health Score

79 / 100
Full package analysis