@hypothesis/frontend-shared
Version:
Shared components, styles and utilities for Hypothesis projects
31 lines (30 loc) • 1.19 kB
TypeScript
import type { ComponentChildren } from 'preact';
/**
* Render a JSX expression as a code string.
*
* A trailing underscore in component names will be omitted, allowing wrapper
* components to be represented as the component they wrap. Props with a
* leading underscore will be ignored.
*
* @example
* jsxToString(<Widget_ count={0} error={false} open={true} label="Thing" onClick={() => go()} _hello={"hello"} />)
* // returns '<Widget count={0}error={false} open label="Thing" onClick={onClick} />'
*/
export declare function jsxToString(vnode: ComponentChildren): string;
/**
* Render a code snippet as syntax-highlighted HTML markup.
*
* For the syntax highlighting to be visible, a Highlight.js CSS stylesheet must be
* loaded on the page.
*
* The content returned by this function is sanitized and safe to use as
* `dangerouslySetInnerHTML` prop.
*/
export declare function highlightCode(code: string): string;
/**
* Render a JSX expression as syntax-highlighted HTML markup.
*
* The content returned by this function is sanitized and safe to use as
* `dangerouslySetInnerHTML` prop.
*/
export declare function jsxToHTML(vnode: ComponentChildren): string;