3.5 KiB
?! specification
The ?! utility converts so called the "C Style Markup Language" to HTML/XML and back. The primary aim is to maximize both editability and readability by dynamizing the markup representation.
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 céltudatos^HU 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>}
Example:
div (?! find a stand alone attribute) { lorem ipsum }
The last identifier,
defined by this regular expression: [A-z][A-z0-9]*
,
before a (optional) head or body
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.
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 vessző^HU (',') or until the end of the head (closing ')').
The body is everything enclosed by curly braces ("{}"). It may contain more tags or comments.
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 (?!) style 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.
Translation
?! translates both ways in a single step, from top to bottom, perserving formatting.
Example:
?!
and
?!
are different sides of the same coin.
Cli
?! [options] <file>+
-c : the input is to be force interpeted as CSML
-? : the input is to be force interpeted as XML/HTML
-o <file> : specify output file name for the NEXT file
-q <char> : use <char> for quoting (default: "'")
-v : print version and quit
-h : print help and quit