| OLD | NEW |
| (Empty) |
| 1 Sky Markup: Syntax | |
| 2 ================== | |
| 3 | |
| 4 A Sky file must consist of the following components: | |
| 5 | |
| 6 1. If the file is intended to be a top-level Sky application, the | |
| 7 string "``#!mojo mojo:sky``" followed by a U+0020, U+000A or | |
| 8 U+000D character. | |
| 9 | |
| 10 If the file is intended to be a module, then the string "SKY", a | |
| 11 U+0020 (space) character, the string "MODULE", and a U+0020, | |
| 12 U+000A or U+000D character. | |
| 13 | |
| 14 These signatures make it more difficult to e.g. embed some Sky | |
| 15 markup into a PNG and then cause someone to import that image as a | |
| 16 module. | |
| 17 | |
| 18 2. Zero or more of the following, in any order: | |
| 19 - comments | |
| 20 - text | |
| 21 - escapes | |
| 22 - elements | |
| 23 | |
| 24 Sky files must be encoded using UTF-8. | |
| 25 | |
| 26 A file that doesn't begin with the "``#!mojo mojo:sky``" signature | |
| 27 isn't a Sky application file. For example: | |
| 28 | |
| 29 #!mojo https://example.com/runtimes/sky.asmjs | |
| 30 Hello World | |
| 31 | |
| 32 ...is not a Sky file, even if ``https://example.com/runtimes/sky.asmjs`` | |
| 33 is an implementation of the Sky runtime: it's just a file intended | |
| 34 specifically for that runtime. | |
| 35 | |
| 36 The ``mojo:sky`` URL represents the generic Sky runtime provided by | |
| 37 your Mojo runtime vendor. | |
| 38 | |
| 39 | |
| 40 Comments | |
| 41 -------- | |
| 42 | |
| 43 Comments start with the sequence "``<!--``" and end with the | |
| 44 sequence "``-->``", where the start and end hyphens don't overlap. | |
| 45 In between these characters, any sequence of characters is allowed | |
| 46 except "``-->``", which terminates the comment. Comments cannot, | |
| 47 therefore, be nested. | |
| 48 | |
| 49 | |
| 50 Text | |
| 51 ---- | |
| 52 | |
| 53 Any sequence of Unicode characters other than ``<``, ``&``, and | |
| 54 U+0000. | |
| 55 | |
| 56 | |
| 57 Escapes | |
| 58 ------- | |
| 59 | |
| 60 There are three kinds of escapes: | |
| 61 | |
| 62 ### Hex | |
| 63 | |
| 64 They begin with the sequence ``&#x`` or ``&#X``, followed by a | |
| 65 sequence of hex characters (lowercase or uppercase), followed by a | |
| 66 semicolon. The number 0 is not allowed. | |
| 67 | |
| 68 ### Decimal | |
| 69 | |
| 70 They begin with the sequence ``&#`` or ``&#``, followed by a | |
| 71 sequence of decimal characters, followed by a semicolon. The number 0 | |
| 72 is not allowed. | |
| 73 | |
| 74 ### Named | |
| 75 | |
| 76 They begin with the sequence ``&``, followed by any characters, | |
| 77 followed by a semicolon. | |
| 78 | |
| 79 The following names work: | |
| 80 | |
| 81 | Name | Character | Unicode | | |
| 82 | ---- | --------- | ------- | | |
| 83 | `lt` | `<` | U+003C LESS-THAN SIGN character | | |
| 84 | `gt` | `>` | U+003E GREATER-THAN SIGN character | | |
| 85 | `amp` | `&` | U+0026 AMPERSAND character | | |
| 86 | `apos` | `'` | U+0027 APOSTROPHE character | | |
| 87 | `quot` | `"` | U+0022 QUOTATION MARK character | | |
| 88 | |
| 89 | |
| 90 Elements | |
| 91 -------- | |
| 92 | |
| 93 An element consists of the following: | |
| 94 | |
| 95 1. ``<`` | |
| 96 2. Tag name: A sequence of characters other than ``/``, ``>``, | |
| 97 U+0020, U+000A, U+000D (whitespace). | |
| 98 3. Zero or more of the following: | |
| 99 1. One or more U+0020, U+000A, U+000D (whitespace). | |
| 100 2. Attribute name: A sequence of characters other than ``/``, | |
| 101 ``=``, ``>``, U+0020, U+000A, U+000D (whitespace). | |
| 102 3. Optionally: | |
| 103 1. Zero or more U+0020, U+000A, U+000D (whitespace) characters. | |
| 104 2. ``=`` | |
| 105 3. Zero or more U+0020, U+000A, U+000D (whitespace) characters. | |
| 106 4. Attribute value: Either: | |
| 107 - ``'`` followed by attribute text other than ``'`` | |
| 108 followed by a terminating ``'``. | |
| 109 - ``"`` followed by attribute text other than ``'`` | |
| 110 followed by a terminating ``"``. | |
| 111 - attribute text other than ``/``, ``>``, | |
| 112 U+0020, U+000A, U+000D (whitespace). | |
| 113 "Attribute text" is escapes or any unicode characters other | |
| 114 than U+0000. | |
| 115 4. Either: | |
| 116 - For a void element: | |
| 117 1. ``/``, indicating an empty element. | |
| 118 2. ``>`` | |
| 119 - For a non-void element: | |
| 120 2. ``>`` | |
| 121 3. The element's contents: | |
| 122 - If the element's tag name is ``script``, then any sequence of | |
| 123 characters other than U+0000, but there must not be the | |
| 124 substring ``</script``. The sequence must be valid sky script. | |
| 125 - If the element's tag name is ``style``, then any sequence of | |
| 126 characters other than U+0000, but there must not be the | |
| 127 substring ``</style``. The sequence must be valid sky style. | |
| 128 - Otherwise, zero or more of the following, in any order: | |
| 129 - comments | |
| 130 - text | |
| 131 - escapes | |
| 132 - elements | |
| 133 4. Finally, the end tag, which may be omitted if the element's tag | |
| 134 name is not ``template``, consisting of: | |
| 135 1. ``<`` | |
| 136 2. ``/`` | |
| 137 3. Same sequence of characters as "tag name" above; this may | |
| 138 be omitted if no start tags have had their end tag omitted | |
| 139 since this element's start tag, unless this element's tag | |
| 140 name is ``script`` or ``style``. | |
| 141 4. ``>`` | |
| 142 | |
| 143 | |
| 144 Sky Markup: Elements | |
| 145 ==================== | |
| 146 | |
| 147 The Sky language consists of very few elements, since it is expected | |
| 148 that everything of note would be provided by frameworks. | |
| 149 | |
| 150 The following elements are implicitly registered by default, even if | |
| 151 you haven't imported anything. You can get to their constructors if | |
| 152 you import dart:sky (basically, dart:sky is always imported by defaul; | |
| 153 it's the runtime library). None of these elements have shadow trees. | |
| 154 | |
| 155 ``<import src="foo.sky">`` | |
| 156 - Downloads and imports foo.sky in the background. | |
| 157 | |
| 158 ``<import src="foo.sky" as="foo">`` | |
| 159 - Downloads and imports foo.sky in the background, using "foo" as its | |
| 160 local name (see ``<script>``). | |
| 161 | |
| 162 ``<template>`` | |
| 163 - The contents of the element aren't placed in the Element itself. | |
| 164 They are instead placed into a Fragment that you can obtain from | |
| 165 the element's "content" attribute. | |
| 166 | |
| 167 ``<script>`` | |
| 168 - Blocks until all previous imports have been loaded, then loads the | |
| 169 library given in the script block, as described in | |
| 170 [scripts.md](scripts.md). | |
| 171 | |
| 172 ``<style>`` | |
| 173 - Adds the contents to the module's styles. | |
| 174 | |
| 175 ``<content>`` | |
| 176 ``<content select="...">`` | |
| 177 - In a shadow tree, acts as an insertion point for distributed nodes. | |
| 178 The select="" attribute gives the selector to use to pick the nodes | |
| 179 to place in this insertion point; it defaults to everything. | |
| 180 | |
| 181 ``<img src="foo.bin">`` | |
| 182 - Sky fetches the bits for foo.bin, looks for a decoder for those | |
| 183 bits, and renders the bits that the decoder returns. | |
| 184 | |
| 185 ``<div>`` | |
| 186 - Element that does nothing. | |
| 187 | |
| 188 ``<span>`` | |
| 189 - Element that does nothing. | |
| 190 | |
| 191 ``<iframe src="foo.bin">`` | |
| 192 - Sky tells mojo to open an application for foo.bin, and hands that | |
| 193 application a view so that the application can render appropriately. | |
| 194 | |
| 195 ``<t>`` | |
| 196 - Within a ``<t>`` section, whitespace is not trimmed from the start and | |
| 197 end of text nodes by the parser. | |
| 198 TOOD(ianh): figure out if the authoring aesthetics of this are ok | |
| 199 | |
| 200 ``<a href="foo.bin">`` | |
| 201 - A widget that, when invoked, causes mojo to open a new application | |
| 202 for "foo.bin". | |
| 203 | |
| 204 ``<title>`` | |
| 205 - Sets the contents as the application's title (as provided by Sky to | |
| 206 the view manager). (Actually just ensures that any time the element | |
| 207 is mutated, module.application.title is set to the element's | |
| 208 contents.) | |
| 209 | |
| 210 | |
| 211 Sky Markup: Global Attributes | |
| 212 ============================= | |
| 213 | |
| 214 The following attributes are available on all elements: | |
| 215 | |
| 216 * ``id=""`` (any value) | |
| 217 * ``class=""`` (any value, space-separated) | |
| 218 * ``style=""`` (declaration part of a Sky style rule) | |
| 219 * ``lang=""`` (language code) | |
| 220 * ``dir=""`` (ltr or rtl only) | |
| 221 * ``contenteditable=""`` (subject to future developments) | |
| 222 * ``tabindex=""`` (subject to future developments) | |
| OLD | NEW |