A lot of template engine uses a mini language. cacography chooses a different approach, be zero logic, delegate expressing logic to the programming language itself.
Ideally text should be represented as AST or at least something similar, like lisp. Practically, template marks of cacography should be simple to parse.
When choosing template marks, cacography avoids collosion with popular markups.
For example:
[[WikiName]]
is used in a lot of wiki markup languagesSome templating engines uses ${}
,
where $
may be converted to local currency symbol in some input methods.
Also, some symbols are hard to type on moblie keyboards.
A programming language parses text for cacography template markup, replacing cacography marked text with processed result.
When processing cacography marked text,
a programming language converts it to a function call String? -> String
.
How to convert marked text to function call is left to the implementation to decide.
In the demostration implementation in Ceylon,
{{verbatim text}}
(we will talk about syntax later) is converted to
// cacographyCommands is entries of `String->String(String)`.
String(String) command = cacographyCommands["verbatim"];
String result = command(text);
To represent the idea of mapping marked text to function call,
choices are ()
, []
, and {}
.
()
is commonly used in natural languages.
(())
is less used, but accurate to represent complex strucutres.
[]
and [[]]
is commonly used in wiki markups, as metinoed before.
{}
is commonly used in programming languages. {{}}
is not
(unless a strange formatting style is applied).
Thus cacography chooses {{}}
.
Now cacography needs to distinguish function name with function parameter.
A lisp like syntax would be {{verbatim "some text"}}
.
The problem with this syntax is cacography needs to make a choice among:
Another choice is TeX style syntax @verbatim{{text}}
,
which is harder to parse.
cacography chooses disallowing nested function call. Nested function call are essentially lambda calculus, aginst the goal logic free.
@"c"
is c
itself in rendered output,
where c
is one of @
, {
and }
.
Only single character is supported.
This is borrowed from Scribble.