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

remark-clang-format

Package Overview
Dependencies
Maintainers
4
Versions
34
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

remark-clang-format - npm Package Compare versions

Comparing version 2.3.2 to 2.3.3

code/format-code.js

36

index.js
'use strict';
import { visit } from 'unist-util-visit';
import { spawnSync as spawnSync } from 'child_process';
import formatCode from './code/format-code.js';
import formatMath from './math/format-math.js';
function visitor(node) {
if (node.type == 'code' || node.type == 'inlineCode') {
// if (node.type == 'inlineCode') {
if (
node.lang &&
(node.lang.toLowerCase() == 'c++' ||
node.lang.toLowerCase() == 'cpp' ||
node.lang.toLowerCase() == 'c') &&
(!node.meta || !node.meta.includes('nolint')) &&
(node.value && (!node.value.includes('--8<--')))
) {
const child = spawnSync('clang-format', { input: node.value });
if (child.stderr) {
console.warn("[remark-clang-format] stderr: ", child.stderr);
}
if (!child.stdout) {
console.warn("[remark-clang-format] empty stdout");
console.warn("[remark-clang-format] original code: ", node.value);
console.warn("[remark-clang-format] child info", child);
// node value left untouched
} else {
node.value = child.stdout;
}
}
}
}
export default function attacher() {
export default function remarkCodeFormat() {
return function transformer(tree) {
visit(tree, visitor);
formatCode(tree);
formatMath(tree);
};
}
{
"name": "remark-clang-format",
"version": "2.3.2",
"version": "2.3.3",
"description": "run clang-format for code in markdown",

@@ -25,3 +25,7 @@ "main": "index.js",

"dependencies": {
"@babel/parser": "^7.18.13",
"@unified-latex/unified-latex-prettier": "^1.0.12",
"@unified-latex/unified-latex-util-parse": "^1.0.12",
"clang-format": "^1.2.4",
"prettier": "^2.3.2",
"unist-util-visit": "^3.1.0"

@@ -37,5 +41,10 @@ },

"fs-extra": "^10.0.0",
"prettier": "^2.3.2",
"remark": "^13.0.0",
"remark-parse": "^9.0.0",
"rehype-format": "^4.0.1",
"rehype-mathjax": "^4.0.2",
"rehype-stringify": "^9.0.3",
"remark": "^14.0.2",
"remark-math": "^5.1.1",
"remark-parse": "^10.0.1",
"remark-rehype": "^10.1.0",
"unified": "^10.1.2",
"zx": "^2.0.0"

@@ -42,0 +51,0 @@ },

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