Skip to content

ajithraghavan/qmd

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Quick Markdown (QMD) Reference Documentation

QMD Logo

Version 1.0
A storage-efficient, backward-compatible evolution of Markdown especially for LLM consumption


Table of Contents

  1. Introduction
  2. Design Principles
  3. Syntax Reference
  4. Parsing Rules
  5. Implementation Guide
  6. Migration Tools
  7. Examples
  8. FAQ

Introduction

Quick Markdown (QMD) is a lightweight markup language that maintains Markdown's readability while significantly reducing storage requirements and token consumption.

Primarily, many Large Language Models (LLMs) consume Markdown files, and the traditional Markdown format consumes more tokens due to its multi-character syntax. To consume fewer tokens than Markdown, we introduce Quick Markdown (QMD), which achieves efficiency through single-character markers, intelligent whitespace handling, and context-aware parsing.

Key Benefits

  • Token Efficient: Reduces LLM token consumption
  • Storage Efficient: Smaller file sizes (comparably)
  • Backward Compatible: Accepts traditional Markdown syntax
  • Fast Parsing: Simpler tokens enable faster processing
  • Clean Syntax: More visually distinctive markers
  • Universal Accessibility: All characters typeable on standard keyboards

Design Principles

  1. Single-Character Markers: Replace multi-character sequences with single characters to reduce token count
  2. Context-Aware Parsing: Derive meaning from position and indentation
  3. Progressive Enhancement: Support traditional syntax while generating optimized output
  4. Minimal Ambiguity: Each marker has one clear purpose
  5. LLM Optimization: Minimize token usage for AI model consumption

Syntax Reference

Headings

Level Traditional QMD Example
1 # ! !Title
2 ## > >Chapter
3 ### - -Section
4 #### . .Subsection
5 ##### : :Minor
6 ###### ; ;Micro

Note: Space after marker is optional in QMD

Text Formatting

Style Traditional QMD Example
Bold **text** *text* *important*
Italic *text* /text/ /emphasis/
Bold+Italic ***text*** */text/* */critical/*
Strikethrough ~~text~~ ~text~ ~deleted~
Code `code` `code` `var x = 1`

Lists

Unordered Lists

- First item
- Second item
  Continuation of second
- Third item
  - Nested item
  - Another nested
    Even deeper

Ordered Lists

1. First item
2. Second item
   Continuation
3. Third item
   a. Nested
   b. Items

Task Lists

+ Completed task
x Failed task
* In progress
. Pending task

Links and Images

Automatic Detection

https://example.com         → auto-linked
user@example.com           → auto-linked

Explicit Links

[text](url)                → standard syntax maintained
[text][ref]                → reference style

[ref]: https://long-url.com

Images

![alt](image.jpg)          → standard syntax maintained

Code Blocks

Fenced Code

`language
code here
more code
`

Indented Code (4 spaces)

    function example() {
        return true;
    }

Tables

Compact Format

Col1 | Col2 | Col3
-----+------+-----
A    | B    | C
D    | E    | F

Alignment

Left | Center | Right
:----|:------:|-----:
A    |   B    |    C

Blockquotes

" Simple quote
" Continues here

" Nested quotes:
  " Inner quote
    " Deeper level

Horizontal Rules

Any of these on a line by itself:

---
***
___

Mathematical Expressions

Inline math: $\alpha + \beta = \gamma$
Display math: $$\int_{0}^{\infty} e^{-x^2} dx = \frac{\sqrt{\pi}}{2}$$

Special Blocks

@note{ This is a note }
@warning{ Important warning }
@tip{ Helpful tip }

Parsing Rules

Line-Based Parsing

  1. First Character Rule: The first non-whitespace character determines line type

    • !>-.:; → Heading
    • +x*. → List item (bullet, completed, failed, in progress, pending)
    • " → Blockquote
    • ` → Code block start/end
    • @ → Special block
  2. Indentation Significance

    • Preserves hierarchy in lists
    • 4 spaces = code block
    • 2 spaces = list continuation
  3. Context Preservation

    • URLs are auto-detected and linked
    • Email addresses are auto-linked
    • Smart quote conversion

Precedence Rules

  1. Explicit markers override auto-detection
  2. Traditional Markdown syntax is always valid
  3. QMD syntax is preferred for generation

Context-Aware Disambiguation

Text Formatting vs. List Markers:

  • * at line start = task list item (in progress)
  • * inline = bold formatting
  • Parser uses position context to determine meaning

Example:

* Working on this task
This is *bold text* in a paragraph

Examples

Complete Document Example

!Quick Markdown Guide

>Introduction

This document demonstrates /all/ QMD features with *efficient* syntax.

-Key Features

• Single-character headings
• Smart text formatting
  Continuation without markers
• Automatic URL detection: https://example.com
• Optimized task lists with ASCII characters

.Task Management Example

+ Review documentation
x Fix broken tests (failed due to timeout)
* Implement new parser
. Schedule team meeting

:Implementation Details

`python
def parse_qmd(text):
    lines = text.split('\n')
    for line in lines:
        process_line(line)
`

;Mathematical Support

The quadratic formula: $x = \frac{-b \pm \sqrt{b^2 - 4ac}}{2a}$

" As stated in the specification:
  " QMD reduces storage while maintaining readability

@note{ Remember: traditional Markdown syntax still works! }

Comparison: Traditional vs QMD

Traditional Markdown (231 bytes):

## Shopping List

**Important** items to buy:

- Milk
- Bread
  - Whole wheat
  - Sourdough
- ~~Eggs~~ Already have

### Tasks
- [x] Buy groceries
- [ ] Call store
- [~] Check prices

### Notes

Check https://store.com for *deals*.

QMD Version (217 bytes,approximately 6.1 % reduction):

>Shopping List

*Important* items to buy:

• Milk
• Bread
  • Whole wheat
  • Sourdough
• ~Eggs~ Already have

-Tasks
+ Buy groceries
. Call store
* Check prices

-Notes

Check https://store.com for /deals/.

For larger files, the compression ratio between QMD and MD should be significantly better

Task List Workflow Example

!Project Alpha Development

-Current Sprint Tasks

+ Implement user authentication
+ Set up database schema
* Working on API endpoints
* Debugging payment integration
x Failed deployment (config issues)
. Code review scheduled
. Write documentation
. Deploy to staging

-Next Sprint

. Plan feature roadmap
. Conduct user testing
. Performance optimization

FAQ

Q: Is QMD compatible with existing Markdown parsers?
A: QMD parsers accept traditional Markdown. However, traditional parsers won't understand QMD-specific syntax.

Q: Can I mix traditional and QMD syntax?
A: Yes! QMD parsers handle both formats seamlessly.

Q: How does the parser distinguish between * for bold and * for task lists?
A: Context-aware parsing: * at line start = task item, * inline = bold formatting.

Q: What about Markdown extensions (tables, footnotes, etc.)?
A: QMD supports common extensions with optimized syntax where beneficial.

Q: How do I handle conflicts (e.g., / in URLs)?
A: QMD uses context-aware parsing. / only triggers italic formatting when surrounded by spaces or at word boundaries.

Q: Is there a standard file extension?
A: Use .qmd for pure QMD files, .md for mixed content.

Q: Why ASCII characters for task lists instead of Unicode symbols?
A: ASCII ensures universal keyboard accessibility, reduces storage by 75%, and eliminates encoding issues across different systems.

Q: How much token reduction can I expect when using QMD with LLMs?
A: Typically 20-30% reduction in token count compared to traditional Markdown, leading to lower API costs and faster processing.


Appendix: Character Reference

Headings

Character Unicode Purpose Bytes (UTF-8)
! U+0021 Heading 1 1
> U+003E Heading 2 1
- U+002D Heading 3 1
. U+002E Heading 4 1
: U+003A Heading 5 1
; U+003B Heading 6 1

Text Formatting

Character Unicode Purpose Bytes (UTF-8)
* U+002A Bold 1
/ U+002F Italic 1
~ U+007E Strikethrough 1

Task Lists (Optimized)

Character Unicode Purpose Bytes (UTF-8) Accessibility
+ U+002B Completed 1 Universal
x U+0078 Failed 1 Universal
* U+002A In progress 1 Universal
. U+002E Pending 1 Universal

Other Elements

Character Unicode Purpose Bytes (UTF-8)
U+2022 Bullet 3
" U+0022 Blockquote 1

Version History

v1.0

  • Initial QMD specification
  • Unicode task list characters
  • Basic syntax definitions

QMD Specification v1.0 - Quick, Quality, Quantum-leap

About

Quick Markdown

Resources

License

Apache-2.0 and 2 other licenses found

Licenses found

Apache-2.0
LICENSE
Unknown
LICENSE-CODE.md
Unknown
LICENSE-SPEC.md

Contributing

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Languages