Metadata-Version: 2.4
Name: jmd-format
Version: 0.4.3
Summary: JMD (JSON Markdown) — structured data format for LLM-driven infrastructure
Author-email: Andreas Ostermeyer <andreas@ostermeyer.de>
License: MIT License
        
        Copyright (c) 2026 Andreas Ostermeyer <andreas@ostermeyer.de>
        
        Permission is hereby granted, free of charge, to any person obtaining a copy
        of this software and associated documentation files (the "Software"), to deal
        in the Software without restriction, including without limitation the rights
        to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
        copies of the Software, and to permit persons to whom the Software is
        furnished to do so, subject to the following conditions:
        
        The above copyright notice and this permission notice shall be included in all
        copies or substantial portions of the Software.
        
        THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
        IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
        FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
        AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
        LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
        OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
        SOFTWARE.
        
        ---
        
        This license applies to the benchmark code only (the `benchmark/` and
        `benchmark_results/` directories). It does not grant any rights to the JMD
        format specification, which is licensed separately under CC BY-NC-SA 4.0.
        See LICENSE for details.
        
Project-URL: Homepage, https://github.com/ostermeyer/jmd-spec
Project-URL: Repository, https://github.com/ostermeyer/jmd-impl
Keywords: jmd,llm,structured-data,json,markdown,mcp
Classifier: Development Status :: 4 - Beta
Classifier: Intended Audience :: Developers
Classifier: License :: Other/Proprietary License
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.10
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3.12
Classifier: Programming Language :: Python :: 3.13
Classifier: Topic :: Software Development :: Libraries :: Python Modules
Classifier: Topic :: Text Processing :: Markup
Requires-Python: >=3.10
Description-Content-Type: text/markdown
License-File: LICENSE
Requires-Dist: lxml>=5.0
Dynamic: license-file

# jmd-format — Python Reference Implementation

Python reference implementation of the [JMD specification](https://github.com/ostermeyer/jmd-spec) (v0.4). Includes a C-accelerated parser and serializer, plus lossless XML↔JMD conversion.

## Installation

Install the latest version directly from GitHub:

```bash
pip install git+https://github.com/ostermeyer/jmd-impl.git
```

Or pin a specific release:

```bash
pip install git+https://github.com/ostermeyer/jmd-impl.git@v0.4
```

Pre-built wheels for Linux, macOS, and Windows are attached to each
[GitHub Release](https://github.com/ostermeyer/jmd-impl/releases) and can be
installed directly:

```bash
pip install https://github.com/ostermeyer/jmd-impl/releases/download/v0.4/jmd_format-0.3-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
```

The C extensions are built automatically during installation if a C compiler is available. If not, the pure-Python fallback is used transparently.

## Quick Start

```python
from jmd import parse, serialize

data = parse("""
# Order
id: 42
status: pending

## customer
name: Anna Müller
email: anna@example.com
""")

print(data)
# {'id': 42, 'status': 'pending', 'customer': {'name': 'Anna Müller', 'email': 'anna@example.com'}}

print(serialize(data, label="Order"))
```

## Document Modes

```python
from jmd import jmd_mode, JMDQueryParser, JMDSchemaParser, JMDDeleteParser, parse_error

# Detect mode without full parse
mode = jmd_mode(source)   # 'data' | 'query' | 'schema' | 'delete'

# Query by Example (#?)
query = JMDQueryParser().parse("#? Order\nstatus: pending")

# Schema (#!)
schema = JMDSchemaParser().parse("#! Order\nid: integer readonly\nstatus: string")

# Delete (#-)
delete = JMDDeleteParser().parse("#- Order\nid: 42")

# Error (# Error)
error = parse_error("# Error\nstatus: 404\ncode: not_found\nmessage: Not found")
```

## Streaming

```python
from jmd import jmd_stream

for event in jmd_stream(source):
    print(event)
```

## XML Mapping

Lossless conversion between data XML and JMD (requires `lxml`):

```python
from jmd.xml import xml_to_jmd, jmd_to_xml

jmd_source = xml_to_jmd(xml_bytes_or_str)  # XML → JMD string
xml_output  = jmd_to_xml(jmd_source)        # JMD → XML bytes
```

Targets data XML — OOXML (WordprocessingML, DrawingML, SpreadsheetML),
SOAP, XBRL, XRechnung, and similar formats. Mixed-content XML (ODF, XHTML)
is out of scope.

See the [JMD over XML companion specification](https://github.com/ostermeyer/jmd-spec/blob/main/jmd-over-xml.md) for the full mapping rules.

## C Extensions

Build manually if needed:

```bash
python build_ext.py build_ext --inplace
```

## Specification

See [jmd-spec](https://github.com/ostermeyer/jmd-spec) for the full format specification, benchmark results, and design documentation.

## License

Licensed under the MIT License. See [LICENSE](LICENSE).

The JMD format specification is licensed separately under CC BY-NC-SA 4.0.
