TODO: Transformation to MarkWare VCMake Structure
masscode2md
is a lightweight tool designed to convert code snippets stored in JSON format into organized Markdown files. The tool reads a JSON file containing code snippets and automatically arranges them into directories based on the provided structure in the JSON file.
- C++ compiler supporting C++17 or later
- nlohmann/json library for JSON parsing
- CMake (optional, recommended for streamlined build process)
-
Clone the repository:
git clone [email protected]:tomasmark79/masscode2md.git cd masscode2md
-
Install the required dependencies (nlohmann/json):
-
Using
vcpkg
:vcpkg install nlohmann-json
-
Alternatively, you can directly include the library in your project by downloading
json.hpp
from GitHub.
-
If you prefer using CMake, follow these steps:
-
Create a build directory:
mkdir build cd build
-
Generate the build system and compile the project:
cmake .. cmake --build .
Alternatively, if you are not using CMake, you can compile the project directly using a C++ compiler:
g++ -o masscode2md main.cpp -std=c++17 -lstdc++fs
The program accepts two command-line arguments: the path to the input JSON file and the output directory where the Markdown files will be saved.
./masscode2md <input_json_path> <output_directory>
./masscode2md snippets.json output
Below is an example of the input JSON file:
{
"folders": [
{
"name": "Example Folder",
"id": "folder_1"
}
],
"snippets": [
{
"folderId": "folder_1",
"name": "example_snippet",
"isDeleted": false,
"content": [
{
"label": "example",
"value": "#include <iostream>\nint main() { std::cout << \"Hello, World!\"; return 0; }",
"language": "cpp"
}
]
}
]
}
The core functionality of masscode2md
is as follows:
- The program accepts two input arguments: the path to the JSON file and the desired output directory.
- If the
ERASE_OUTPUT_DIR_AT_STARTUP
macro is defined astrue
, the output directory's contents will be cleared upon program startup. - The program parses the JSON file and reads the structure of folders and snippets.
- Folders specified in the JSON are created in the output directory.
- For each snippet that is not marked as deleted (
isDeleted: false
), a Markdown file is generated containing the snippet’s code.
This project is licensed under the MIT License. For more information, please refer to the LICENSE
file.
Developed and maintained by Tomáš Mark.