A brand new markup language
It works like Typescript, which is transpiled into Javascript. ytml files can be transpiled into html
html
<html lang="pt-br">
<body>
<p color="blue" class="paragraph" id="first">Hello there</p>
</body>
</html>
Is equivalent to
html(lang = "pt-br"){
body {
p.paragraph#first(color = "blue") {
Hello there
}
}
}
Also, with the multiply operator(*), you can avoid repetition, so
html
<html>
<body>
<p>Hello!</p>
<p>Hello!</p>
<p>Hello!</p>
<p>Hello!</p>
</body>
</html>
Can be wrote this way
html {
body {
p*4 {
Hello!
}
}
}
Create a tag:
```rust use ytml::ast::Tag; use ytml::html::asttagto_html;
fn main() { let tag = Tag { name: String::from("html"), attributes: HashMap::new(), inner: Vec::new(), }; let indent = 2; // The indentation let indentstart = 0; // The initial indentation let htmloutput = asttagtohtml(&tag, indentstart, indent); println!("{}", html_output); // } ```
Read ytml code into tag:
```rust use ytml::filehandling::fileinput::readfileinto_ast;
fn main() { let filepath = "./index.ytml"; let tags = readfileintoast(file_path); for tag in tags { println!("{}", tag); } } ```
Write html code:
```rust use std::collections::HashMap; use ytml::{filehandling::fileoutput::writehtmlto_file, ast::Tag};
fn main() { let document = vec![ Tag{ attributes: HashMap::new(), inner: Vec::new(), name: String::from("html"), } ]; let filepath = "./out.html"; writehtmltofile(file_path, document, 2); } ```
Define tag with a inner content:
```rust use std::collections::HashMap;
use ytml::ast::{Tag, TagInnerElement};
fn main() { let p = Tag{ attributes: HashMap::new(), name: String::from("p"), inner: vec![TagInnerElement::Text { content: String::from("This is a paragraph") }] }; println!("{}", p);
let div = Tag{
attributes: HashMap::new(),
name: String::from("div"),
inner: vec![TagInnerElement::Tag { tag: p }]
};
println!("{}", div);
} ```
Using file paths only:
```rust use ytml::filehandling::compileytml_file;
fn main() { let ytmlfilepath = String::from("./index.ytml"); let htmlfilepath = String::from("./out.html"); let indent = 2; compileytmlfile(ytmlfilepath, Some(htmlfilepath), indent); } ```