remark-clang-format
Advanced tools
Comparing version 2.3.2 to 2.3.3
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 @@ }, |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
Filesystem access
Supply chain riskAccesses the file system, and could potentially read sensitive data.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
12394
25
206
6
16
3
3
+ Added@babel/parser@^7.18.13
+ Addedprettier@^2.3.2
+ Added@babel/helper-string-parser@7.25.9(transitive)
+ Added@babel/helper-validator-identifier@7.25.9(transitive)
+ Added@babel/parser@7.26.3(transitive)
+ Added@babel/types@7.26.3(transitive)
+ Added@unified-latex/unified-latex-builder@1.8.0(transitive)
+ Added@unified-latex/unified-latex-ctan@1.8.1(transitive)
+ Added@unified-latex/unified-latex-prettier@1.8.1(transitive)
+ Added@unified-latex/unified-latex-types@1.8.0(transitive)
+ Added@unified-latex/unified-latex-util-align@1.8.1(transitive)
+ Added@unified-latex/unified-latex-util-argspec@1.8.1(transitive)
+ Added@unified-latex/unified-latex-util-arguments@1.8.1(transitive)
+ Added@unified-latex/unified-latex-util-catcode@1.8.0(transitive)
+ Added@unified-latex/unified-latex-util-comments@1.8.0(transitive)
+ Added@unified-latex/unified-latex-util-environments@1.8.1(transitive)
+ Added@unified-latex/unified-latex-util-match@1.8.0(transitive)
+ Added@unified-latex/unified-latex-util-parse@1.8.1(transitive)
+ Added@unified-latex/unified-latex-util-pegjs@1.8.1(transitive)
+ Added@unified-latex/unified-latex-util-pgfkeys@1.8.1(transitive)
+ Added@unified-latex/unified-latex-util-print-raw@1.8.0(transitive)
+ Added@unified-latex/unified-latex-util-render-info@1.8.0(transitive)
+ Added@unified-latex/unified-latex-util-replace@1.8.0(transitive)
+ Added@unified-latex/unified-latex-util-scan@1.8.0(transitive)
+ Added@unified-latex/unified-latex-util-split@1.8.0(transitive)
+ Added@unified-latex/unified-latex-util-trim@1.8.0(transitive)
+ Added@unified-latex/unified-latex-util-visit@1.8.0(transitive)
+ Addedbail@2.0.2(transitive)
+ Addedcolor@4.2.3(transitive)
+ Addedcolor-convert@2.0.1(transitive)
+ Addedcolor-name@1.1.4(transitive)
+ Addedcolor-string@1.9.1(transitive)
+ Addedextend@3.0.2(transitive)
+ Addedis-arrayish@0.3.2(transitive)
+ Addedis-buffer@2.0.5(transitive)
+ Addedis-plain-obj@4.1.0(transitive)
+ Addedprettier@2.8.83.4.2(transitive)
+ Addedsimple-swizzle@0.2.2(transitive)
+ Addedtrie-prefix-tree@1.5.1(transitive)
+ Addedtrough@2.2.0(transitive)
+ Addedunified@10.1.2(transitive)
+ Addedunist-util-stringify-position@3.0.3(transitive)
+ Addedvfile@5.3.7(transitive)
+ Addedvfile-message@3.1.4(transitive)