Research
Security News
Quasar RAT Disguised as an npm Package for Detecting Vulnerabilities in Ethereum Smart Contracts
Socket researchers uncover a malicious npm package posing as a tool for detecting vulnerabilities in Etherium smart contracts.
msc-code-viewer
Advanced tools
As a web developer, show some demo code is a very common stuff. There are so many syntax highlighting libraries for the Web. highlight.js is one of the popular library. It is easy to use and there are so many themes for it. To make it more suitable for me
As a web developer, show some demo code is a very common stuff. There are so many syntax highlighting libraries for the Web. highlight.js is one of the popular library. It is easy to use and there are so many themes for it. To make it more suitable for me, I wrap highlight.js and GitHub light / dark themes as a web component and named it <msc-code-viewer />. With <msc-code-viewer /> syntax highlighting is a piece of cake. It will switch light / dark mode as user preference. Of course「COPY」feature has already built-in.
<msc-code-viewer /> is a web component. All we need to do is put the required script into your HTML document. Then follow <msc-code-viewer />'s html structure and everything will be all set.
<script
type="module"
src="https://your-domain/wc-msc-code-viewer.js">
</script>
Put the content inside <msc-code-viewer /> as its child. It will have highlighting content.
<msc-code-viewer>
<!-- Syntax highlighting content -->
<style>
body, .usertext {
color: #F0F0F0; background: #600;
font-family: Chunkfive, sans;
--heading-1: 30px/32px Helvetica, sans-serif;
}
</style>
</msc-code-viewer>
<msc-code-viewer /> could also use JavaScript to create DOM element. Here comes some examples.
<script type="module">
import { MscCodeViewer } from 'https://your-domain/wc-msc-code-viewer.js';
// use DOM api
const nodeA = document.createElement('msc-code-viewer');
document.body.appendChild(nodeA);
nodeA.textContent = `
Show me the money
`;
// new instance with Class
const nodeB = new MscCodeViewer();
document.body.appendChild(nodeB);
nodeB.textContent = `
Show me the money
`;
</script>
<msc-code-viewer /> uses CSS variables to style its interface. That means developer could easy change them into the lookup you like.
<style>
msc-code-viewer {
--msc-code-viewer-border-radius: 16px;
}
</style>
Property Name | Type | Description |
---|---|---|
value | String | Getter / Setter for value. Developers could use this property to setup syntax highlighting. |
Event Signature | Description |
---|---|
msc-code-viewer-mutate | Fired when mutated. |
FAQs
As a web developer, show some demo code is a very common stuff. There are so many syntax highlighting libraries for the Web. highlight.js is one of the popular library. It is easy to use and there are so many themes for it. To make it more suitable for me
The npm package msc-code-viewer receives a total of 15 weekly downloads. As such, msc-code-viewer popularity was classified as not popular.
We found that msc-code-viewer 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.
Research
Security News
Socket researchers uncover a malicious npm package posing as a tool for detecting vulnerabilities in Etherium smart contracts.
Security News
Research
A supply chain attack on Rspack's npm packages injected cryptomining malware, potentially impacting thousands of developers.
Research
Security News
Socket researchers discovered a malware campaign on npm delivering the Skuld infostealer via typosquatted packages, exposing sensitive data.