Skip to content

feat(docs): add YAML input to Playground with tests#303

Merged
johannschopplich merged 3 commits into
toon-format:mainfrom
swetasanghi2004-prog:feat/playground-yaml-input
May 17, 2026
Merged

feat(docs): add YAML input to Playground with tests#303
johannschopplich merged 3 commits into
toon-format:mainfrom
swetasanghi2004-prog:feat/playground-yaml-input

Conversation

@swetasanghi2004-prog
Copy link
Copy Markdown
Contributor

@swetasanghi2004-prog swetasanghi2004-prog commented May 14, 2026

  • Add input format selector and YAML parsing (YAML 1.2, merge keys off)
  • Extract parse/stringify helpers for testability and SPEC-aligned encoding
  • Add Vitest for docs package and playground parse tests
  • Update Playground copy in package README and ecosystem docs

Linked Issue

Closes #299

Description

This PR adds YAML input support to the playground along with parsing utilities, test coverage, and documentation updates for improved TOON playground interoperability.

Type of Change

  • Bug fix (non-breaking change that fixes an issue)
  • New feature (non-breaking change that adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • Documentation update
  • Refactoring (no functional changes)
  • Performance improvement
  • Test coverage improvement

Changes Made

Added an input format selector to the playground
Added YAML 1.2 parsing support with merge keys disabled
Extracted parse/stringify helpers into reusable utilities for improved testability
Updated encoding behavior to align with TOON SPEC requirements
Added Vitest configuration and coverage for:
playground parsing utilities
docs package behavior
YAML parsing edge cases
Updated Playground documentation in the README
Updated ecosystem docs to document YAML support and formatting behavior

SPEC Compliance

  • This PR implements/fixes spec compliance
  • Spec section(s) affected:
  • Spec version:

Testing

  • All existing tests pass
  • Added new tests for changes
  • Tests cover edge cases and spec compliance

JSON ↔ YAML format switching
YAML 1.2 parsing behavior
Disabled merge key handling
Invalid YAML error handling
Parse/stringify helper behavior
SPEC-aligned encoding output

Pre-submission Checklist

  • My code follows the project's coding standards
  • I have run code formatting/linting tools
  • I have added tests that prove my fix/feature works
  • New and existing tests pass locally
  • I have updated documentation if needed
  • I have reviewed the TOON specification for relevant sections

Breaking Changes

  • No breaking changes
  • Breaking changes (describe migration path below)

Additional Context

This change improves the playground developer experience by supporting both JSON and YAML workflows while keeping parsing behavior deterministic and SPEC-compliant.

- Add input format selector and YAML parsing (YAML 1.2, merge keys off)
- Extract parse/stringify helpers for testability and SPEC-aligned encoding
- Add Vitest for docs package and playground parse tests
- Update Playground copy in package README and ecosystem docs
@swetasanghi2004-prog swetasanghi2004-prog force-pushed the feat/playground-yaml-input branch from 3b327ac to fc17284 Compare May 14, 2026 11:52
- Inline parse/stringify helpers into the component, drop the separate
  parse-input module and its tests
- Rename input state from `jsonInput`/`formattedJson`/`jsonTokens` to
  `inputText`/`formattedInput`/`inputTokens` so names no longer lie when
  YAML is selected
- Hide the JSON Baseline selector in YAML mode and make the token-count
  tooltip conditional on input format
- Store input under `state.input` with a fallback read of legacy
  `state.json` so existing share URLs keep working
- Drop redundant YAML parse options (merge/version match library
  defaults); use lineWidth: 0 for editor display so long scalars do not
  fold mid-sentence
- Remove the duplicated vitest devDep, docs vitest.config.ts, and `test`
  script – the playground is verified through the dev server
- "in real-time" → "in real time" (real-time only hyphenates as a
  compound modifier before a noun)
- Header copy now matches the ecosystem page: "Convert JSON or YAML to
  TOON in real time"
- Token-count tooltip unified across input formats; the JSON baseline
  selector is right next to it and already communicates the format
- Drop `?? ''` fallback on state.input — decodeState already gates on
  successful JSON parse; the chain falls through to the legacy
  state.json field
@johannschopplich johannschopplich merged commit 90a04bd into toon-format:main May 17, 2026
@johannschopplich
Copy link
Copy Markdown
Collaborator

Thank you!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

YAML support into Playground

2 participants