LML
Light Meta Language - an HTML alternative
Concept
- Indentation-based hierarchy - obvious hierarchy
- Enforced one-statement-per-line with reasonable multiline attributes option
- No
<
,>
character, and no closing tag - Simple directives for text (
;
), comment (#
), cdata ($
) - No templating trickery - as static as HTML
- Maintained attribute string compatibility with HTML
- It works well with stuff like Angular event handler attributes (e.g.
(click)="x = 'nah'"
) unlike Pug/Jade
- It works well with stuff like Angular event handler attributes (e.g.
Example
!DOCTYPE htmlhtml head title ; My Title script type="text/javascript" src="ext.js" script type="text/javascript" alert('Hello'); style body { color: #333; } body # A comment div id="wrapper" ; My Site!
Translates to
My Title <!-- A comment --> My Site!
Programmatical use
Install for your project
npm install lml --save
Parsers produce AST and convert
JavaScript example
// convert LML to HTMLconst parseLML = parseLML; ;
Parsers
Parser functions are exposed with the same signiture, and the returned object has the same interface:
parseAST(source: string | ASTModel[], parseConfig?: ParseConfig) => ParserInterface
parseJSON(source: string | JSONModel[], parseConfig?: ParseConfig) => ParserInterface
parseLML(source: string, parseConfig?: ParseConfig) => ParserInterface
Parsing HTML
- install html-lml:
npm install html-lml --save
- use the the indentical parser from that package:
parseHTML(source: string, parseConfig?: ParseConfig) => ParserInterface
Parser interface:
Configurations
AST Model
AST model is used by a variety of DOM parsers, like https://astexplorer.net/
JSON Model
The native structure used by these libraries
CLI
There is a dedicated command line tool: lml-cli