Skip to main content

Mark Json

The Mark Json library is a markdown to JSON converter that transforms Markdown documents into a structured JSON format, ideal for working with long documents like books.

Installation

Install the library using pip:

pip install mark-json

Basic Usage

Basic conversion example:

from mark_json import from_mark

with open('file.md', 'r', encoding='utf-8') as f:
  markdown_content = f.read()

json = from_mark(markdown_content)

print(json)

Conversion Rules

Frontmatter

The Markdown document MUST start with a frontmatter block that includes:

  • Title: The title of the document.

  • Author: The author of the document.

  • Language: The language of the document.

  • Translator: The translator of the document (if applicable).

  • Date: The publication or creation date of the document.

Sections and content

In the conversion process, each markdown heading represents a section within the document. The depth of each section is determined by the level of the heading.

Content that appears immediately below each heading is considered part of that section. This content is preserved as string in Markdown format in the content field of the section object.

Example Conversion

Markdown

---
title: The Pathway of Life
author: Leo Tolstoy
language: en
translator: Archibald J. Wolfe
date: 1919-01-01
---

# The Pathway of Life

## Force

One of the main causes of human misery is the erroneous idea that some men may by force order or improve the life of others.

### The Inefficiency of Force

The fact that it is possible to make men amenable to justice by the use of force, does not yet prove that it is just to subject people to force.

_Pascal_

JSON

{
  "title": "The Pathway of Life",
  "author": "Leo Tolstoy",
  "language": "en",
  "translator": "Archibald J. Wolfe",
  "date": "1919-01-01",
  "sections": [
    {
      "depth": 1,
      "title": "The Pathway of Life",
      "content": null,
      "position": 1
    },
    {
      "depth": 2,
      "title": "Force",
      "content": "One of the main causes of human misery is the erroneous idea that some men may by force order or improve the life of others.",
      "position": 2
    },
    {
      "depth": 3,
      "title": "The Inefficiency of Force",
      "content": "The fact that it is possible to make men amenable to justice by the use of force, does not yet prove that it is just to subject people to force. _Pascal_",
      "position": 3
    }
  ]
}

Contributions

Open an issue or submit a pull request for suggestions or improvements.

License

This project is licensed under the MIT License.

Metadata

Release files for mark-json 0.1.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for mark-json 0.1.1
File Size Uploaded Provenance
mark_json-0.1.1.tar.gz 3.7 kB Without provenance Details

Built distribution (wheel)

Table of built distributions (wheels) for mark-json 0.1.1
File Interpreter ABI Platform
mark_json-0.1.1-py3-none-any.whl Python 3 none any Details

Total release size: 7.6 kB

Release files / mark_json-0.1.1.tar.gz

Download URL mark_json-0.1.1.tar.gz
Size 3.7 kB
Tags Source
SHA-256 checksum
How to use checksums
d0d6e59af65bc1e9a3331b9aec33bbe4b2a81bd6cb62fae722db06d2245bafac
BLAKE2b-256 checksum
How to use checksums
9779e13cd7d7128598c7b431890e7aca394f09e3698f452ea34868e59ae822e1
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/5.1.1 CPython/3.12.5

Release files / mark_json-0.1.1-py3-none-any.whl

Download URL mark_json-0.1.1-py3-none-any.whl
Size 3.9 kB
Tags Python 3
SHA-256 checksum
How to use checksums
b8ac9cc8759c9f197818a2220ac6ffa9b309f781767915f649f05b2dee8e21c0
BLAKE2b-256 checksum
How to use checksums
dfc0a52df9539f7461a19f94833ab2d25ff81d451cbf471328ffd0bb92eebda3
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/5.1.1 CPython/3.12.5

Security for mark-json 0.1.1

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release

0.1.1 This release

2 release files No provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page