https://github.com/javier/md_code_extractor
extracts code blocks from markdown files
https://github.com/javier/md_code_extractor
Last synced: 8 months ago
JSON representation
extracts code blocks from markdown files
- Host: GitHub
- URL: https://github.com/javier/md_code_extractor
- Owner: javier
- License: apache-2.0
- Created: 2024-05-16T10:59:34.000Z (about 2 years ago)
- Default Branch: main
- Last Pushed: 2024-05-16T11:29:02.000Z (about 2 years ago)
- Last Synced: 2025-07-29T02:21:46.560Z (11 months ago)
- Language: Python
- Size: 7.81 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Extract Code Blocks from Markdown/Docusaurus Project
This Python script extracts all code blocks from a Markdown or Docusaurus project and outputs them to a specified markdown file. The code blocks are sorted by file paths in alphabetical order for easier navigation.
## Features
- Extracts fenced code blocks (`` ``` ``).
- Outputs extracted code blocks to a specified markdown file.
- Sorts files and folders alphabetically for easy navigation.
## Requirements
- Python 3.6 or higher
## Usage
1. Clone the repository to your local machine.
```sh
git clone https://github.com/javier/md_code_extractor.git
cd md_code_extractor
```
2. Run the script, providing the path to the Docusaurus repository and the desired output markdown file name as arguments:
```sh
python md_code_extractor.py
```
Replace `` with the path to the project and `` with the desired name of the output markdown file.
## Example
```sh
python md_code_extractor.py /path/to/your/docs extracted_code_blocks.md
```
This command will create a `extracted_code_blocks.md` file containing all code blocks from the specified project.
## License
This project is licensed under the Apache 2.0 License. See the [LICENSE](LICENSE) file for details.