Skip to content

Enables the seamless execution of code blocks in any language within Markdown files in VS Code.

License

Notifications You must be signed in to change notification settings

renathossain/vscode-markdown-runner

Repository files navigation

Markdown Code Block Runner for VS Code

This extension allows you to execute code blocks in any programming language directly from Markdown files in VS Code.

Run Code Block Run Code Snippet Run On Markdown

Features

  • Execute Code Blocks: CodeLens Buttons appear above each code block (```) for running or copying the code. Temporary files are created for execution and are cleaned up afterward.
  • Execute Code Snippets: Run code snippets (enclosed in `) with Ctrl + Click. Results are displayed in the terminal.
  • Save Execution Results: Execute code directly within Markdown files, with the output captured in the document.
  • Broad Language Support: Supports a wide range of languages, including C, Rust, C++, Java, TypeScript, PHP, Perl, R, Dart, Groovy, Go, Haskell, Julia, Lua, Ruby, JavaScript, Python, Bash. Add non-compiled languages via settings.

Requirements

Before running a code block:

  • Verify "Compiler Configuration" settings are correct.
  • Ensure your code is correct.
  • Install necessary languages and dependencies.
  • Add compilers to the PATH environment variable if necessary to enable global access to installed languages.

On Arch Linux, install all supported languages with:

sudo pacman --needed -S php perl r dart groovy go rustup ghc julia lua ruby nodejs npm python bash

For other systems, research language installation or use the Windows Subsystem for Linux.

Demo File

Download or copy DEMO.md and the demo_helpers folder into VS Code after installing this extension, and test all the features out!

Extension Settings

Compiler Configuration

  • Configure language compilers by specifying Item: Code Block Tag and associated Value: [Language Name, File Extension, Compiler Command/Path]. Only non-compiled languages can be added.
// Example
Item: python, Value: ["Python", "py", "python"]
  • Reset settings using the ↻ icons or remove the markdownRunner.compilerConfiguration entry from VSCode's settings.json to restore to default if any issues occur.

Python Path

Enable this to add the Markdown file's parent directory to Python's sys.path, allowing you to import modules from that directory.

Future Development

Planned features (no guarantee):

  • Support for multiple Run on Markdown output streams.

Your feedback and contributions are welcome in shaping the future of this extension!

License

GPL-3.0 license

About

Enables the seamless execution of code blocks in any language within Markdown files in VS Code.

Resources

License

Stars

Watchers

Forks

Packages

No packages published