3.1 KiB
C Style Markup Language
The C Style Markup Language -CSML for short- is a markup language that can be 1 to 1 translated into traditional markup languages such as XML or HTML. It's syntax -as the name suggests- is engineered to be similar to the syntax of the C programming language (and thereby it is also similar to derived languages such as Javascript). It also happens to closely resemble Groovy's advanced templating language.
The rational behind it's creation is the realizations that:
- languages which have giant blocks (say thousands of lines) tend to be more readable if the block closing token explicitly states the block type being closed.
procedure exaple is
begin
;
end
- languges with implicit block closing contain less redundant text and as a result, are easier to edit
void exaple() {
;
}
So, CSML is indended to be a temporary representation of other markup languages for the duration of their directed editing. In practice, the developer would open a -say HTML- file, find the relevant section to modify, convert the document to CSML, perform the update, then convert it back -without loosing any data in the process of course. Or alternatively one could rapidly type out a webpage in CSML and seemlessly translate it in the end.
Syntax
Tags
<tag> [(<head>)] {<body>}
<tag>;
Example:
textarea (readonly) { lorem ipsum }
br;
The last identifier,
defined by this regular expression: [A-z][A-z0-9]*
,
before a (optional) head, body or semi-colon
is considered to be a tag.
CSML by itself does not enforce any (sub)set of words to be "valid"
(however, related tools might).
Each tag is pushed into a stack and later popped by the end of a body being found.
If the tag is followed by a semi-colon (';'), it's a self-closing tag.
The head holds attributes. A missing head signals that there are no attributes to be translated. Any text may be a valid attribute. Attributes can be given values by placing a colon (':') after them.
The value is parsed until the first non-escaped comma (',') or until the end of the head (closing ')').
The body is everything enclosed by curly braces ("{}"). It may contain more tags or comments. The body may be be enclosed in multiple curly braces, in which case inside the body, less curly braces than the body has, are not interpreted as part of a tag. They need not be escaped.
script {{
if (true) { /* this is fine */ }
}}
Escaping
Any special character may be escaped by prepending it with a backslash (''). This will prevent it from being parsed as a significant token to the syntax. List of escaped special characters: + ( + ) + { + } + , + : + ; + < + > Note, that they are not requred to be always escaped, but are highly advised.
Comments
CSML supports C99 comments, both single and multi line. That is:
//single line
/*multi-
line*/
Echoing
Anything not holding special meaning (tags, heads, comments) is considered regular text, which is significant. This includes whitespace too.