Skip to content

Commit ca1cabc

Browse files
committed
v0.1.0
0 parents  commit ca1cabc

File tree

11 files changed

+288
-0
lines changed

11 files changed

+288
-0
lines changed

.gitignore

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
# Build files
2+
/target
3+
/Cargo.lock
4+
5+
# Dist files
6+
releases

Cargo.toml

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
[package]
2+
name = "stupidsimple-html"
3+
version = "0.1.0"
4+
edition = "2024"
5+
6+
[dependencies]
7+
clap = { version = "4.5.42", features = ["derive"] }
8+
serde = { version = "1.0.219", features = ["derive"] }
9+
serde_json = "1.0.142"

LICENSE

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
MIT License
2+
3+
Copyright (c) 2025 FloorTech
4+
5+
Permission is hereby granted, free of charge, to any person obtaining a copy
6+
of this software and associated documentation files (the "Software"), to deal
7+
in the Software without restriction, including without limitation the rights
8+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9+
copies of the Software, and to permit persons to whom the Software is
10+
furnished to do so, subject to the following conditions:
11+
12+
The above copyright notice and this permission notice shall be included in all
13+
copies or substantial portions of the Software.
14+
15+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21+
SOFTWARE.

example/index.html

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
<!doctype html>
2+
<html lang="en">
3+
4+
<head>
5+
<meta charset="utf-8" />
6+
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no" />
7+
<meta name="description" content="Hello!" />
8+
<link rel="stylesheet" href="style.css" />
9+
<script type="module" src="script.js"></script>
10+
</head>
11+
12+
13+
<body>
14+
<h1>Hello, World!</h1>
15+
<span>Shart!!!</span>
16+
</body>
17+
18+
</html>

example/index.sshtml

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
<!doctype html>
2+
<html lang="en">
3+
4+
<sshtml::head {"other_tags": ["<meta charset=\"utf-8\" />","<meta name=\"viewport\" content=\"width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no\" />"],"meta": {"description": "Hello!"},"styles": ["style.css"],"scripts": [{"type": "module","src": "script.js"}]} />
5+
6+
<body>
7+
<h1>Hello, World!</h1>
8+
<sshtml::component shart.sshtml />
9+
</body>
10+
11+
</html>

example/index.sshtml.json

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
{
2+
"other_tags": [
3+
"<meta charset=\"utf-8\" />",
4+
"<meta name=\"viewport\" content=\"width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no\" />"
5+
],
6+
"meta": {
7+
"description": "Hello!"
8+
},
9+
"styles": [
10+
"style.css"
11+
],
12+
"scripts": [
13+
{
14+
"type": "module",
15+
"src": "script.js"
16+
}
17+
]
18+
}

example/shart.html

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
<span>Shart!!!</span>

example/shart.sshtml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
<span>Shart!!!</span>

rust-toolchain.toml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
[toolchain]
2+
channel = "nightly"

src/main.rs

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
use clap::Parser;
2+
use std::io;
3+
mod sshtml;
4+
5+
#[derive(Parser)]
6+
#[command(name = "sshtml")]
7+
#[command(version = "0.1.0")]
8+
#[command(author = "FloorTech")]
9+
#[command(
10+
about = "Allows users to input StupidSimple HTML, and outputs normal and static HTML that works on most platforms."
11+
)]
12+
struct Cli {
13+
#[arg(short, long)]
14+
input: String,
15+
16+
#[arg(short, long)]
17+
output: Option<String>,
18+
19+
#[arg(short, long, default_value_t = false)]
20+
comments: bool,
21+
}
22+
23+
fn main() -> io::Result<()> {
24+
let args: Cli = Cli::parse();
25+
let input_file: String = args.input;
26+
27+
if !input_file.ends_with(".sshtml") {
28+
return Err(io::Error::new(
29+
io::ErrorKind::InvalidInput,
30+
"Input must be a .sshtml file!",
31+
));
32+
}
33+
34+
let output_file: String = args
35+
.output
36+
.clone()
37+
.unwrap_or_else(|| input_file.replace(".sshtml", ".html"));
38+
39+
if !output_file.ends_with(".html") {
40+
return Err(io::Error::new(
41+
io::ErrorKind::InvalidInput,
42+
"Output must be a .html file!",
43+
));
44+
}
45+
46+
sshtml::file_readparse(input_file, output_file, args.comments)
47+
}

0 commit comments

Comments
 (0)