Canon provides canonicalization, pretty-printing, and semantic comparison for XML, HTML, JSON, and YAML formats.

1. Welcome

Canon helps you:

  • Format documents into canonical or human-readable forms

  • Compare documents semantically, not just textually

  • Test with RSpec matchers that understand structure

  • Debug with clear, color-coded diff output

2. Quick Navigation

2.1. By Your Role

Developer

Start with Ruby API to integrate Canon into your applications.

QA Engineer

Start with RSpec Matchers for testing XML/JSON/YAML generation.

DevOps

Start with CLI for command-line formatting and comparison.

Architect

Start with Architecture to understand Canon’s design.

2.3. By Format

XML

W3C Canonical XML 1.1, namespace handling, attribute ordering

HTML

HTML4/5 detection, rendered whitespace handling

JSON

Sorted keys, semantic comparison

YAML

Sorted keys, alias handling

3. Learning Path

3.1. Level 1: Get Started (5 minutes)

3.2. Level 2: Learn Interfaces (15 minutes)

Choose your interface:

  • Ruby API - Integrate into applications

  • CLI - Command-line usage

  • RSpec - Testing integration

3.3. Level 3: Understand Canon (30 minutes)

3.4. Level 4: Master Features (1 hour)

3.5. Level 5: Advanced Topics (As needed)

5. Getting Help

Found a bug?

Report an issue on GitHub

Have a question?

Check Glossary or search this documentation

Want to contribute?

See Contributing to Documentation

6. What’s New

6.1. Version 0.x (Current)

  • Semantic tree diff algorithm (experimental)

  • Size limits for large files

  • Enhanced character visualization

  • Environment variable configuration

  • Configuration profiles with element-level whitespace classification

  • Three-way whitespace sensitivity: strict, normalize, insensitive