
Security News
vlt Launches "reproduce": A New Tool Challenging the Limits of Package Provenance
vlt's new "reproduce" tool verifies npm packages against their source code, outperforming traditional provenance adoption in the JavaScript ecosystem.
Extract and process code blocks from Markdown files. Now you can keep code examples automatically:
--help
(if uv is available)
Try codeblocks
without installing:
uvx codeblocks --help
Install to PATH
:
uv tool install codeblocks
codeblocks --help
With pip
:
pip install codeblocks
With uv
:
uv add codeblocks
With poetry
:
poetry add codeblocks
Usage: codeblocks [OPTIONS] LANGUAGE FILE [COMMAND]...
Extract or process LANGUAGE code blocks in Markdown FILE.
Extract Python code blocks:
codeblocks python README.md
Reformat Python code blocks with `black`, in place:
codeblocks python README.md -- black -
Options:
--wrap Wrap each code block in a function.
--check Do not modify the file, just return the status. Return code 0
means block matches COMMAND output. Return code 1 means block
would be modified.
--version Show the version and exit.
--help Show this message and exit.
Extract Python code blocks:
codeblocks python README.md
Check formatting of Python code blocks with black:
codeblocks --check python README.md -- black -
Reformat Python code blocks with black, in place:
codeblocks python README.md -- black -
Type check Python code blocks with mypy (--wrap
puts each code block into its own function):
mypy somemodule anothermodule <(codeblocks python --wrap README.md)
Insert the output of codeblock --help
into usage
block in this README.md:
codeblocks usage README.md -- codeblocks --help
Check that usage
block in this README.md is up-to-date with --help
output:
codeblocks --check usage README.md -- codeblocks --help
def plus(x: int, y: int) -> int:
return x + y
plus(1, '2')
$ mypy --pretty <(codeblocks python README.md)
/dev/fd/63:5: error: Argument 2 to "plus" has incompatible type "str"; expected "int" [arg-type]
plus(1, '2')
^~~
Found 1 error in 1 file (checked 1 source file)
There are alternative tools, but none of them supported all of the cases above.
black --check
is not supported. No lint or unit test support. In addition, codeblocks
implementation is much simpler and is not coupled with black.FAQs
Extract and process code blocks from Markdown files.
We found that codeblocks demonstrated a healthy version release cadence and project activity because the last version was released less than 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
vlt's new "reproduce" tool verifies npm packages against their source code, outperforming traditional provenance adoption in the JavaScript ecosystem.
Research
Security News
Socket researchers uncovered a malicious PyPI package exploiting Deezer’s API to enable coordinated music piracy through API abuse and C2 server control.
Research
The Socket Research Team discovered a malicious npm package, '@ton-wallet/create', stealing cryptocurrency wallet keys from developers and users in the TON ecosystem.