
Security News
AI Agent Lands PRs in Major OSS Projects, Targets Maintainers via Cold Outreach
An AI agent is merging PRs into major OSS projects and cold-emailing maintainers to drum up more work.
js-code-renderer
Advanced tools
美化JavaScript代码在浏览器的展示
npm install js-code-renderer
import { CodeRenderer } from 'js-code-renderer';
let renderBtn = document.querySelector('#render');
let codeArea = document.querySelector('#code');
let codeSnipet = document.querySelector('#code-snipet');
let ul = null;
renderBtn.addEventListener('click', function() {
if (ul) {
ul.parentNode.removeChild(ul);
ul = null;
}
doRender(codeArea.value)
})
//展示
function doRender(code) {
if (!code) return;
// renderResult 为一个二元数组
let renderResult = new CodeRenderer(code).render();
ul = document.createElement('ul');
renderResult.forEach(nodeRow => {
let li = document.createElement('li');
nodeRow.forEach(node => {
let span = document.createElement('span');
span.innerHTML = node.text.replace(/ /g, ' ');// 转换空格符
if (node.style) {
span.style.color = node.style.color;
}
li.appendChild(span)
});
ul.appendChild(li)
});
codeSnipet.appendChild(ul)
}
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Document</title>
<style>
ul {
list-style: none;
}
li {
height: 22px;
line-height: 22px;
}
#code-snipet {
background-color: #1e1e1e;
font-family: Consolas, 'Courier New', monospace;/*使用等宽字体*/
color: #d4d4d4;
}
</style>
</head>
<body>
<div class="js-code-renderer-demo">
<h1>把代码粘贴到该输入框</h1>
<textarea id="code"></textarea>
<button id="render">渲染</button>
<div id="code-snipet">
<ul></ul>
</div>
</div>
</body>
</html>
##demo代码地址 https://github.com/nicholasking900816/js-code-renderer-demo
FAQs
美化javascript代码在浏览器上的展示
The npm package js-code-renderer receives a total of 0 weekly downloads. As such, js-code-renderer popularity was classified as not popular.
We found that js-code-renderer 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
An AI agent is merging PRs into major OSS projects and cold-emailing maintainers to drum up more work.

Research
/Security News
Chrome extension CL Suite by @CLMasters neutralizes 2FA for Facebook and Meta Business accounts while exfiltrating Business Manager contact and analytics data.

Security News
After Matplotlib rejected an AI-written PR, the agent fired back with a blog post, igniting debate over AI contributions and maintainer burden.