Skip to content

Convert Lona files between JSON AST and Swift source code

Notifications You must be signed in to change notification settings

Lona/serialization

Repository files navigation

Lona Serialization

Build and Test

Convert Lona files between JSON, and source code (Swift + MDX).

Overview

Lona token files are typically stored as MDX (Markdown with embedded React components).

Token files support a special kind of code block, marked with the language "tokens", that contains Lona token definitions. These definitions can be stored as JSON, or (a small subset of) Swift. This utility converts between the different formats.

API

convertDocument: (String, Format) -> String

Supported formats: 'json', 'source'

Example: Convert a .md document to JSON

import { convertDocument } from '@lona/serialization'

const lonaDocument = '...' // source code of a Lona document

const lonaJson = convertDocument(lonaDocument, 'json')

convertLogic: (String, Format) -> String

Supported formats: 'json', 'source'

Example: Convert a .tokens file to JSON

import { convertLogic } from '@lona/serialization'

const lonaTokens = '...' // source code of a Lona tokens file

const lonaJson = serialization.convertLogic(lonaTokens, 'json')

About

Convert Lona files between JSON AST and Swift source code

Resources

Stars

Watchers

Forks

Packages

No packages published

Contributors 3

  •  
  •  
  •