Integration Guide

For IDE vendors and plugin developers. Learn how to integrate MOTH into your tools.

Integration Levels

MOTH can be integrated at different levels depending on your needs:

Level 1: Basic Recognition

Recognize .moth files and apply syntax highlighting. Minimal effort, maximum compatibility.

Level 2: Syntax Highlighting

Full syntax highlighting for MOTH syntax elements: sections, keys, values, types.

Level 3: Validation & Linting

Validate MOTH syntax, check for common errors, provide linting feedback.

Level 4: Full IDE Support

Code completion, hover documentation, refactoring, and advanced features.

Syntax Highlighting

MOTH uses a simple, regex-friendly syntax that's easy to highlight:

# Comments - Lines starting with #
[SECTIONS] - Text in square brackets
key: - Identifiers before colons
value - Text after colons
; - Semicolon separators
{k=v} - Configuration objects

Validation Rules

Implement these validation rules for MOTH files:

✓ File must start with header metadata

intent:...; audience:...; style:...

✓ At least one [SECTION]

Sections must be in ALL_CAPS

✓ Valid key:value syntax

Keys must be snake_case, values until newline or semicolon

✓ Proper quote escaping

Use quotes for values with colons or semicolons

File Format

Extensions:

  • .moth - Primary extension
  • .str - Alternative (STRAND)
  • .spex - Specification variant

MIME Types:

  • text/x-moth
  • text/x-moth+plain

Encoding:

UTF-8 required

Resources for Developers