kyrie
    Preparing search index...

    Function html_from_string

    • Converts a JSON or JavaScript string to HTML with inline CSS color styling Convenience function that parses the string and paints it as HTML

      Parameters

      • str: string

        The string to convert to HTML (JSON or JavaScript literal)

      • Optionaloptions: Options

        Optional configuration for highlighting

      Returns string

      HTML string with span tags and inline CSS styles

      const json = '{"name": "Alice", "age": 30}';
      const html = html_from_string(json);
      document.body.innerHTML = html;
      const arr = '[1, 2, 3, "hello", true]';
      const html = html_from_string(arr, { palette: palettes.bold.dark });
      console.log(html); // Outputs HTML with inline styles