react-refractor
Advanced tools
Comparing version 3.0.0 to 3.1.0
@@ -38,6 +38,26 @@ import {ComponentType} from 'react' | ||
export declare interface RefractorProps { | ||
/** | ||
* The code value to highlight | ||
*/ | ||
value: string | ||
/** | ||
* The language code/name to use for highlighting, eg `php`, `css`, `html` etc | ||
*/ | ||
language: string | ||
/** | ||
* Class name for the outer `<pre>` element, defaults to `refractor` | ||
* Note: this is not used when `inline` is `true`. | ||
*/ | ||
className?: string | ||
/** | ||
* If `true`, the code will not be highlighted - instead it will be rendered as plain text. | ||
*/ | ||
plainText?: boolean | ||
/** | ||
* If `true`, the code will be rendered inline, eg not wrapped in a `<pre>` element. | ||
*/ | ||
inline?: boolean | ||
/** | ||
* An array of markers to highlight in the code. | ||
*/ | ||
markers?: (Marker | number)[] | ||
@@ -44,0 +64,0 @@ } |
@@ -184,3 +184,6 @@ import { jsx } from "react/jsx-runtime"; | ||
const className = props.className || DEFAULT_CLASSNAME, langClassName = `language-${props.language}`, codeProps = { className: langClassName }, preClass = [className, langClassName].filter(Boolean).join(" "); | ||
props.inline && (codeProps.style = { display: "inline" }, codeProps.className = className); | ||
if (props.inline && (codeProps.style = { display: "inline" }, codeProps.className = className), props.plainText) { | ||
const code2 = /* @__PURE__ */ jsx("code", __spreadProps(__spreadValues({}, codeProps), { children: props.value })); | ||
return props.inline ? code2 : /* @__PURE__ */ jsx("pre", { className: preClass, children: code2 }); | ||
} | ||
let ast = refractor.highlight(props.value, props.language); | ||
@@ -187,0 +190,0 @@ props.markers && props.markers.length > 0 && (ast = addMarkers(ast, { markers: props.markers })); |
{ | ||
"name": "react-refractor", | ||
"version": "3.0.0", | ||
"version": "3.1.0", | ||
"description": "Super-thin React wrapper for refractor (Syntax highlighting using VDOM)", | ||
@@ -5,0 +5,0 @@ "type": "module", |
@@ -63,2 +63,3 @@ # react-refractor | ||
| `markers` | Array of lines to mark. See section on markers below | | ||
| `plainText` | Set to `true` to skip highlighting and render the passed value as-is | | ||
@@ -65,0 +66,0 @@ ## Differences to Prism |
@@ -7,6 +7,31 @@ import {type ComponentType, type ReactNode} from 'react' | ||
export interface RefractorProps { | ||
/** | ||
* The code value to highlight | ||
*/ | ||
value: string | ||
/** | ||
* The language code/name to use for highlighting, eg `php`, `css`, `html` etc | ||
*/ | ||
language: string | ||
/** | ||
* Class name for the outer `<pre>` element, defaults to `refractor` | ||
* Note: this is not used when `inline` is `true`. | ||
*/ | ||
className?: string | ||
/** | ||
* If `true`, the code will not be highlighted - instead it will be rendered as plain text. | ||
*/ | ||
plainText?: boolean | ||
/** | ||
* If `true`, the code will be rendered inline, eg not wrapped in a `<pre>` element. | ||
*/ | ||
inline?: boolean | ||
/** | ||
* An array of markers to highlight in the code. | ||
*/ | ||
markers?: (Marker | number)[] | ||
@@ -13,0 +38,0 @@ } |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
48539
640
119
0