Code Monkey home page Code Monkey logo

geml's Introduction

GeML: Generic Markup Language

Install

To install the library:

yarn add @hediet/geml

Example Geml Documents

A contact book

{ContactBook {-- "ContactBook" is the type of the object --}
    contacts: [
        {-- The next object does not have a type --}
        { firstName: <Max> lastName: <Mustermann> }
    ]
}

Text with markup

<
    Hello {Bold <World>}!
    You can {Bold <even {Italic <nest>} markup!>}
>

As I18n Formatting Language

You have {count} unread {plural {count} one:<E-Mail> other:<E-Mails>}!
Click {link <here>} to read them!

Demonstration of all language features

{!geml 0.9}
{Obj
    <Hello World {bold <Blub {nested}>}>
    param: value
    foo: {
        bla: 1
        flag: true
        baz: "2"
        "te\"st": blub
        <key>: <baz>
    }

    arr: [
        item1
        "item2"
    ]

    {-test-
    Comment
    -test-}

    blaa: <test<
        \test\:{test}
    >test>
    foo: <
        baz {blub}
    >
    {
        1
        2
        3
    }
}

Grammar

Identifier          ::= IdentifierStartChar IdentifierContChar*
IdentifierStartChar ::= '_' | unicode:ID_Start
IdentifierContChar  ::= '_' | '.' | '-' | unicode:ID_Continue

SingleLineWSChar ::= #x09 | #x20
LineBreak        ::= #x0D #x0A | #x0D | #x0A
WS               ::= SingleLineWSChar | LineBreak

Comment   ::= '{-' Delimiter '-' AnyText '-' Delimiter '-}'
Delimiter ::= unicode:ID_Continue*
AnyText   ::= .*

Trivias  ::= (WS | Comment)+

RecognizedAsGemlDocument ::= '{!geml' AnyText
Document ::= Header? (Trivias? Value)* Trivias?

Header ::= '{!geml 0.1' (Trivias HeaderAttr)* Trivias? '}'

HeaderAttr ::= HeaderAttrPropertyName ':' Trivias? HeaderAttrPropertyValue
HeaderAttrPropertyName  ::= Identifier
HeaderAttrPropertyValue ::= Value

Value ::= Primitive | String | Structured
Structured ::= Object | Array

Primitive      ::= PrimitiveChar+
PrimitiveChar  ::= IdentifierContChar | [+*=|~!?,;/\"'()^&@%$#]

String ::= SinglelineString | MultilineString | HeredocString

SinglelineString     ::= '"' (SinglelineStringChar | EscapeSequence)* '"'
SinglelineStringChar ::= . \ ('\' | '"' | LineBreak)

MultilineString     ::= '<' (MultilineStringChar | EscapeSequence | Object)* '>'
MultilineStringChar ::= . \ ('\' | '<' | '>' | '{' | '}' | LineBreak)

EscapeSequence     ::=  '\' (EscapedCR | EscapedLF | EscapedTab | EscapedSpecialChar | CodePointRef | IgnoredWS)
EscapedCR          ::= 'r'
EscapedLF          ::= 'n'
EscapedTab         ::= 't'
EscapedSpecialChar ::= [\<>{}"] | '[' | ']'
CodePointRef       ::= 'u' Hex Hex Hex Hex
Hex                ::= [0-9A-F]
IgnoredWS          ::= LineBreak SingleLineWSChar*

HeredocString ::= '<' Delimiter '<' (AnyText | '\' Delimiter EscapeSequence | '\' Delimiter '\:' Object)* '>' Delimiter '>'


Object  ::= '{' ObjectKind? (Trivias Property)* Trivias? '}'
ObjectKind ::= Identifier

Property           ::= PositionalProperty | NamedProperty
PositionalProperty ::= PropertyValue
PropertyValue      ::= Value

NamedProperty      ::= PropertyName ':' Trivias? PropertyValue
PropertyName       ::= Identifier | String

Array ::= '[' (Trivias Value)* Trivias ']'

Planned Tooling

  • TypeScript based parser lib. Will produce rich AST with printing/formatting/... capabilities.
  • VS Code Syntax Highlighting + Syntax Validation
  • Online Editor support
  • Eventually, JSON Schema / @hediet/semantic-json support

Target

  • Alternative to ICU message format
  • Alternative to xml
  • Alternative to json/json5/yaml/toml

geml's People

Contributors

hediet avatar

Stargazers

 avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.