Skip to content

squeakywings/jsonml

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

11 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

JSONML

HTML Represented using JSON.

Example Input

{
    "html": [
        { "head": [] },
        {
            "body": [
                "Plain Text...",
                { "p": "Hello, World!" },
                "<img src='https://www.w3.org/Icons/w3c_home'/>"
            ],
            "style": "color:red;"
        }
    ]
}

Example Output

<!DOCTYPE html><html><head></head><body style='color:red;'>Plain Text...<p>Hello, World!</p><img src='https://www.w3.org/Icons/w3c_home'/></body></html>

Spec

The first key in a JSON object is interpreted as the element name. e.g. div or p or body. Any other keys are interpreted as element attributes.

The value of the first key is either a string (for textContent) or an array of other elements or strings (interpreted as inline html). Single tags can be used by using the string as an element e.g.

{
    "div": [
        "<img src='hi.png'/>"
    ]
}

About

HTML Represented in JSON

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published