mdparse

command module
v0.1.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 18, 2025 License: MIT Imports: 10 Imported by: 0

README

mdparse

Bidirectional converter between Markdown (with YAML frontmatter) and JSON.

Features

  • Auto-detection: Automatically detects input format (Markdown or JSON)
  • Bidirectional: Convert Markdown → JSON and JSON → Markdown
  • YAML Frontmatter: Preserves frontmatter as JSON properties
  • Flexible Input: Accepts stdin, file paths, or literal content
  • Customizable: Configure body property name and JSON formatting

Installation

go install github.com/hay-kot/mdparse@latest

Usage

# Markdown to JSON from stdin
echo "# Hello" | mdparse

# Markdown file to JSON with pretty printing
mdparse document.md --pretty

# JSON to markdown (round-trip)
mdparse document.md | mdparse

# Custom body property name
mdparse --body-key content document.md

# Literal markdown to JSON
mdparse "# Title"
Options
  • --body-key, -b: JSON property name for markdown body content (default: "$body")
  • --pretty, -p: Pretty-print JSON output with indentation
  • --log-level: Set log level (debug, info, warn, error, fatal, panic)
  • --log-file: Path to log file (optional)

Examples

Markdown to JSON

Input (document.md):

---
title: My Document
author: John Doe
---

# Introduction

This is the content.

Output:

mdparse document.md --pretty
{
  "title": "My Document",
  "author": "John Doe",
  "$body": "# Introduction\n\nThis is the content."
}
JSON to Markdown

Input:

{
  "title": "My Document",
  "author": "John Doe",
  "$body": "# Introduction\n\nThis is the content."
}

Output:

echo '{"title":"My Document","author":"John Doe","$body":"# Introduction"}' | mdparse
---
author: John Doe
title: My Document
---

# Introduction

License

MIT

Documentation

The Go Gopher

There is no documentation for this package.

Directories

Path Synopsis
internal

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL