
Security News
Django Joins curl in Pushing Back on AI Slop Security Reports
Django has updated its security policies to reject AI-generated vulnerability reports that include fabricated or unverifiable content.
bs-react-syntax-highlighter
Advanced tools
ReasonML bindings for react-syntax-highlighter library.
npm i --save bs-react-syntax-highlighter react-syntax-highlighter
Then add bs-react-syntax-highlighter
as a dependency to bsconfig.json
.
Unlike in the JavaScript counterpart, there is no default highlighter - you have to choose Hljs or Prism explicitly.
[@react.component]
let make = () => {
<ReactSyntaxHighlighter.Prism style={ReactSyntaxHighlighter.Prism.Style.darcula}>
{"A code to highlight"}
</ReactSyntaxHighlighter.Prism>;
};
[@react.component]
let make = () => {
<ReactSyntaxHighlighter.Hljs language={`JavaScript}>
{"const foo = () => {};"}
</ReactSyntaxHighlighter.Hljs>;
};
In JavaScript, there is a possibility to put any property you like on the root element rendered by the component,
by simply putting it on a component. It's called "props spread". react-syntax-highlighter
supports that pattern as well.
ReasonML simply can't do it.
Quite nice escape hatch is wrapping the component you wish to spread props on in another component (HOC or High-Order Component), which will inject all passed properties to its child in a not type-safe, but quite an efficient way. source. There is a runtime cost for this operation, though, so I've decided to not include such code in this library. Pay the cost only when you need to.
module Spread = {
[@react.component]
let make = (~props, ~children) =>
ReasonReact.cloneElement(children, ~props, [||]);
};
<Spread props={"id": "foobar"}>
<ReactSyntaxHighlighter.Hljs language={`JavaScript}>
{"const foo = () => {};"}
</ReactSyntaxHighlighter.Hljs>;
</Spread>
For convenience I've included just one such a generic property in component bindings: className
.
The package provides fallback for projects using older version of JSX syntax.
[@react.component]
let make = () => {
<ReactSyntaxHighlighter.Hljs.Jsx2 language={`JavaScript}>
...{"const foo = () => {};"}
</ReactSyntaxHighlighter.Hljs.Jsx2>;
};
An async build and a light build are not currently supported. PRs are welcome!
FAQs
ReasonML bindings for react-syntax-highlighter library
The npm package bs-react-syntax-highlighter receives a total of 18 weekly downloads. As such, bs-react-syntax-highlighter popularity was classified as not popular.
We found that bs-react-syntax-highlighter demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Django has updated its security policies to reject AI-generated vulnerability reports that include fabricated or unverifiable content.
Security News
ECMAScript 2025 introduces Iterator Helpers, Set methods, JSON modules, and more in its latest spec update approved by Ecma in June 2025.
Security News
A new Node.js homepage button linking to paid support for EOL versions has sparked a heated discussion among contributors and the wider community.