
Security News
Feross on the 10 Minutes or Less Podcast: Nobody Reads the Code
Socket CEO Feross Aboukhadijeh joins 10 Minutes or Less, a podcast by Ali Rohde, to discuss the recent surge in open source supply chain attacks.
@loopmode/codeblock
Advanced tools
A react component for code highlighting - based on prismjs
This is a simple wrapper around prismjs. Some of its main goals:
prismjs, but without bloating the final bundle with unused onesyarn add @loopmode/codeblock
# or
npm install --save @loopmode/codeblock
import() syntax - we only load what's needed from prismjs, dynamicallyIf you want to use the URL-based loader via src prop in older browsers, you should either provide a window.fetch polyfill or your own loadExternal function that doesn't require window.fetch.
Note: In case your project is based on a recent version of create-react-app, you're good to go!
import React from 'react';
import Codeblock from '@loopmode/codeblock'
export default function CodeblockExamples() {
return (
<Codeblock>{`
class Foo {
constructor(value) {
this.value = value;
}
}
const a = new Foo('a');
const b = new Foo('b');
`}</Codeblock>
);
}
import React from 'react';
import Codeblock, { Code } from '@loopmode/codeblock'
export const Examples = () => (
<>
{/* load external content via src prop */}
<Codeblock src="http://my-website.com/my-file.js" />
{/* specify language and/or theme props */}
<Codeblock language="python" theme="twilight">
{'import base64, sys; base64.decode(open(sys.argv[1], "rb"), open(sys.argv[2], "wb"))'}
</Codeblock>
{/* inline styling */}
<p>We can use inline code: <Codeblock inline>const foo = 'foo'</Codeblock><p>
<p>Alternatively, use the Code component: <Code>const foo = 'foo'</Code><p>
</>
)
FAQs
React component to highlight code using prismjs
The npm package @loopmode/codeblock receives a total of 5 weekly downloads. As such, @loopmode/codeblock popularity was classified as not popular.
We found that @loopmode/codeblock 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
Socket CEO Feross Aboukhadijeh joins 10 Minutes or Less, a podcast by Ali Rohde, to discuss the recent surge in open source supply chain attacks.

Research
/Security News
Campaign of 108 extensions harvests identities, steals sessions, and adds backdoors to browsers, all tied to the same C2 infrastructure.

Security News
OpenAI rotated macOS signing certificates after a malicious Axios package reached its CI pipeline in a broader software supply chain attack.