A Go program that extracts code blocks from Markdown files.
go run main.go [options] <markdown_file>-l, --language: Specify the language to extract (default: "shell")- Use "all" to extract all code blocks regardless of language
- Flags can be placed before or after the filename
-
Extract all shell code blocks:
go run main.go example.md
-
Extract Python code blocks (flags can be placed before or after the filename):
go run main.go -l python example.md go run main.go example.md -l python
-
Extract all code blocks regardless of language:
go run main.go -l all example.md go run main.go example.md -l all
You can use language-specific comments in your code blocks to provide context or instructions. For example:
# Run this command on the server
sudo systemctl status minio# Run this command on the client
mc ls labThe program will preserve all comments in the extracted code blocks.
-
Clone the repository
-
Install dependencies:
go mod download
To build the program:
go build -o code_extractor