Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/cshaa/nml
HTML6-like Markup Language
https://github.com/cshaa/nml
Last synced: about 5 hours ago
JSON representation
HTML6-like Markup Language
- Host: GitHub
- URL: https://github.com/cshaa/nml
- Owner: cshaa
- Created: 2013-05-11T20:54:44.000Z (over 11 years ago)
- Default Branch: master
- Last Pushed: 2015-03-02T10:20:00.000Z (almost 10 years ago)
- Last Synced: 2025-01-17T21:12:55.778Z (8 days ago)
- Size: 160 KB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# nml
Namespace Markup Language## Work in progress!
This spec is not finished yet! For more info about nml, you can check out my [parser](https://github.com/m93a/nml-parser/).## Intro
### What's nml?
The Namespace Markup Language (`nml`) is a try to create more powerful and user-friendly version of The Extensible Markup Language, aka. `xml`. Its name is a creation of [Phil Andy](https://github.com/philandy), originally thought to be a name of a community-maintaned version of `html` (see [this thread](https://github.com/OscarGodson/HTML6/issues/17#issuecomment-21987975) for more info).### What's wrong with xml?
Are you a big fan of `xml`? Me too. "But - wait!" you say, "Then why are you trying to get rid of it?". I am not. `nml` will probably never replace `xml`. And it's not its goal. `nml` can be easily converted to `xml` at any time.
The problem with `xml` is that it's easy-to-read for parsers but hard-to-write for programmers. Why nobody uses `xhtml`? Because they would lose those comfortable features like boolean attributes, unquoted values and UPPERCASE TAG NAMES (yes, some people still use them). The goal of `nml` is to be as comfortable as possible without losing `xml`'s readability.### What language is nml's default for defining namespaces?
Huh, that's a good point. Actually - I don't know. Personally I'd like to use something based on `css` syntax but there are many, many possibilities and it's better to let the community decide.### Who is this spec for?
This spec is intended to be suitable for everybody, either a beginner or an expert writing his own nml-based browser-or-something. You will find four types of content here - normative sections for parser-makers, advanced sections for users that know `xml` and `html` and beginner sections for - wait for it... - beginners! The fourth type is an example section for better understanding. Note that the advanced sections may be omitted on places without any difference from `xml` and `html`.## Syntax
### Document
**Beginner section**
Basically, any file written in `nml` is a _document_. Document is a set of everything in your file. The building units of a document are _tags_ and _text_.**Example**
```htmlThe Little Prince
The Universe Versus Alex Woods
The Hitchhikers Guide to The Galaxy```
**Normative section**
Every `nml` document is represented by a DOM [`Document` object](#document-object).
Every document consists of a _root element_ – either empty or containing child elements and/or text, optionally preceded by a [_doctype declaration_](#doctype).Every _element_ may be either empty – represented by a [single tag](#single-tag) – or may contain one or more _nodes_ enclosed in [begin tag](#begin-tag) and [end tag](#end-tag), both must have the same tag name and namespace and must be children of the same element (or in case of root, must not be children of an element).
_Node_ is either an element or a text string containing any character but [`U+003C`](#ref-unicode) (LESS-THAN SIGN) and [`U+0000`](#ref-unicode) (NULL).
### Doctype
**Beginner section**
Doctypes are used to determine the default _namespace_ of a document. Most of the time, you will probably use `` – namespace of the `html api`.**Example**
``
``**Normative section**
Form ([regex](#ref-regex)): `//i`
The group number one of the regular expersion is the name of a [globally recognized API](#globaly-recognized-apis) or a URL encapsulated in double or single quotes. If a URL is provided, it has to be a valid link to a markdown declaration file (eg. DTD or XML Schema). If a API name is provided, parser's own markdown declaration rules will be loaded. Those define the _default namespace_ that will be used if none is specified.In the case that URL was provided and the markdown declaration file does not provide any namespace name:
* find the last forward slash [`U+002F`](#ref-unicode) (SOLIDUS)
* get the subtring after the slash
* apply `/^[A-\u02AF\-]+/` ([regex](#ref-regex)) to the substring
* if the result is at least one character long
* use it as the default namespace name
* else use empty string### Tag
**Beginner section**
Tags are used to structure the document. Tags is the things between `<` and `>` characters.
There are three types of tags:
* Single tag
* Begin tag
* End tagBegin tag looks like this: ``. They mark the beginning of the `name` _element_.
End tag is similar to begin tag but it has a slash at the beginning: ``. It marks the end of the `name` _element_.
Single tag is a combination of begin and end tags. It looks like this: `` and means the same as this: ``, it creates an _empty element_.What does _element_ mean? Elements are virtual parts of the document that have a special meaning defined by their _namespace_. Elements may have child elements but they don't have to. As an example of what they can do: in `html api` there's an `a` element used to mark that certain piece of text is an anchor/link.
_Namespaces_ are sets of rules that define the behaviour of elements. The most common namespace is `html` which defines tags such as `title` (page title) and `a` (anchors). There are many other namespaces, each serves a different purpose. To specify which namespace the element uses you can type `` – that creates `a` element in the `html` namespace. If you don't specify the namespace, [default one](#doctype) will be used.
Single and begin tags may have _attributes_ to keep some information. They're based on a simple `foo=bar` format, written
right after the element name (and a space). In this examle, `foo` is called _attribute name_ or _key_ and `bar` is an
_attribute value_. If you want to use whitespace characters in value, you have to quote it this way: `foo="some bars"`.There are also _single attributes_ (also called _boolean_), created by omitting the value and equal sign. Eg. attribute `bool` means `bool=""` (value is empty).
**Example**
`` - Begin tag of an `abc` element.
`` - End tag of a `bar` element from `foo` namespace.
`` - Single tag of a `name` element with three attributes.
`Hi there!` - A text between two tags, making one `a` element together.
`` - The `foo` element is a child of the `x` element.
`` - Element `hello` with a single attribute `world`.
`` - **Begin tag** (!) - that's because the slash is a part of the attribute value.
`` - Single tag; the attribute value and the slash are divided by a space.**Advanced section**
Single tags are interpreted in the same way as in xml.
Attributes are interpreted the same way in html5 (unquoted and boolean attributes are allowed).
To specify which namespace the element uses, type ``. If you don't, the [default namespace](#doctype) will be used.
Note that nml is **case insensitive**!All characters in the following range are allowed in tag, namespace and attribute names: [`U+0041`](#ref-unicode) (LATIN CAPITAL LETTER A) to [`U+02AF`](#ref-unicode) (LATIN SMALL LETTER TURNED H WITH FISHHOOK AND TAIL) plus the [`U+002D`](#ref-unicode) (HYPHEN-MINUS) character.
**Normative section**
Identifier ([regex](#ref-regex)): `/[A-\u02AF\-]+/`
Attribute ([regex](#ref-regex)): `/` Identifier `(\s*=\s*([^"'\s]+|("[^"]*")|('[^']*')))?/`
Begin tag ([regex](#ref-regex)): `/<` Identifier `(:` Identifier `)?(\s+` Attribute `)*\s*>/`
Single tag ([regex](#ref-regex)): `/<` Identifier `(:` Identifier `)?(\s+` Attribute `)*\s*\/>/`
End tag ([regex](#ref-regex)): `/<\/` Identifier `\s*\/>/`Namespace, tag and attribute names are case insensitive and are converted to lowercase.
### //TODO
## DOM
If not stated otherwise, nml conforms the [Whatwg DOM Standard](#ref-dom). The following [Web IDL](#ref-webidl) code snippets may extend/implement classes and types that are not defined in this specifation – such classes are defined in the [Whatwg standard](#ref-dom).### Document object
//TODO### //TODO
## References
### Globaly recognized APIs
* Hypertext Markup Language API
* World Wide Web Form API
* Simple Vector Graphics API### External specifications
* [ecma-262 — Regular Expressions.](http://www.ecma-international.org/ecma-262/5.1/#sec-15.10)
* [The Unicode Consortium – The Unicode Standard.](http://www.unicode.org/versions/latest/)
* [W3C – Web IDL.](http://www.w3.org/TR/WebIDL/)
* [Whatwg – DOM Standard.](http://dom.spec.whatwg.org/)## Outro
### Credits
[m93a](http://m93a.g6.cz) (Michal Grňo) - wrote this spec
[Oscar Godson](http://oscargodson.com) - invented the way to blend html & xml syntax
[Phil Andy](https://github.com/philandy) - created the name
W3C - Thanks for standardizing the Web and sorry for breaking your standards :)### License
Copyright (c) 2015 Michal GrňoPermission is hereby granted, free of charge, to any person
obtaining a copy of this software and associated documentation
files (the "Software"), to deal in the Software without
restriction, including without limitation the rights to use,
copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the
Software is furnished to do so, subject to the following
conditions:The above copyright notice and this permission notice shall be
included in all copies or substantial portions of the Software.THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
OTHER DEALINGS IN THE SOFTWARE.