Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

react-refractor

Package Overview
Dependencies
Maintainers
1
Versions
15
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

react-refractor - npm Package Compare versions

Comparing version 3.0.0 to 3.1.0

20

dist/index.d.ts

@@ -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 @@ }

5

dist/index.js

@@ -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 }));

2

package.json
{
"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

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc