#data-model #markdown #convert-markdown #schema #markdown-parser #parse-markdown #template

bin+lib mdmodels

A tool to generate models, code and schemas from markdown files

2 releases

0.1.1 Jul 1, 2024
0.1.0 Jul 1, 2024

#2368 in Parser implementations


Used in mdmodels-macro

MIT license

215KB
4K SLoC

Rust 3K SLoC // 0.1% comments Jinja2 869 SLoC // 0.1% comments Shell 5 SLoC // 0.4% comments

Markdown Models

Build Status

This is a markdown parser and converter for Rust that can be used to parse markdown data model files and convert them to various formats, schemes and programming languages.

Installation

In order to install the command line tool, you can use the following command:

git clone https://github.com/JR-1991/md-models
cd md-models
cargo install --path .

Command line usage

The command line tool can be used to convert markdown files to various formats. The following command will convert a markdown file to Python code:

md-models -i model.md -o lib.py -l python-dataclass

This will read the input file model.md and write the output to lib.py using the Python dataclass template. Alternatively, you can also pass a URL as input to fetch the model remotely. For an overview of all available templates, you can use the following command:

md-models --help

Available templates

The following templates are available:

  • python-dataclass: Python dataclass implementation with JSON-LD support
  • python-sdrdm: Python PyDantic implementation with multiple output formats
  • xml-schema: XML schema definition
  • json-schema: JSON schema definition
  • shacl: SHACL shapes definition
  • shex: ShEx shapes definition

Development

This project uses GitHub Actions for continuous integration. The tests can be run using the following command:

cargo test
cargo clippy

Dependencies

~13–29MB
~395K SLoC