diff --git a/index.html b/index.html index 67bf674..57f4e04 100644 --- a/index.html +++ b/index.html @@ -1,7 +1,7 @@ - + Mark :: mers @@ -40,7 +40,7 @@ it is by using one of the assume*() functions (similar to unwrap()s).

HTML preprocessor to help build this document written in mers:


-<!DOCTYPE html>
# This document will be processed by build.mers.
# Lines starting with hashtags are comments and will be ignored.
# Lines starting with dollar-signs insert special text.
# To escape this, put a space before the hashtag or dollar sign.
<head>
<meta charset=“UTF-8”>
<link rel="stylesheet" href="site/external.css">
<title>Mark :: mers</title>
</head>
<body>
<h1>Mers</h1>
<section class="container">
<section class="container_left2 code-border">
<pre><code class="mers-code-snippet">
$welcome_script
</code></pre>
</section>
<section class="container_right">
<image
alt="some picture related to mers (todo)"
src="data:image/jpg;base64,/9j/4AAQSkZJRgABAQEASABIAAD/2wBDAP//////
width="100%" height="100%"
>
<h3>Mers types</h3>
<div>
Mers uses a multiple-types system.
It keeps track of which types a variable could have
and constructs a type with that information.
<br>
For example, <code>int/float</code> can represent a number - int or
Optional types can be <code>[]/[t]</code> - either nothing or one v
Mers doesn't have null, it just has the empty tuple <code>[]</code>
</div>
<h3>No exceptions, no crashes</h3>
<div>
Errors in mers are passed as values.
Because of the type system, you are forced to handle them explicitl
Mers will not crash in unexpected places, because the only way to c
it is by using one of the assume*() functions (similar to unwrap()s
</div>
</section>
</section>
<hr>
<h3>HTML preprocessor to help build this document written in mers:</h3>
<section class="container">
<pre class="container2_left"><code>
$index.html
</code></pre>
<pre class="container2_right"><code class="mers-code-snippet">
$build_script
</code></pre>
</section>
</body>

+<!DOCTYPE html>
# This document will be processed by build.mers.
# Lines starting with hashtags are comments and will be ignored.
# Lines starting with dollar-signs insert special text.
# To escape this, put a space before the hashtag or dollar sign.
<head>
<meta charset=“UTF-8”>
<link rel="stylesheet" href="external.css">
<title>Mark :: mers</title>
</head>
<body>
<h1>Mers</h1>
<section class="container">
<section class="container_left2 code-border">
<pre><code class="mers-code-snippet">
$welcome_script
</code></pre>
</section>
<section class="container_right">
<image
alt="some picture related to mers (todo)"
src="data:image/jpg;base64,/9j/4AAQSkZJRgABAQEASABIAAD/2wBDAP//////
width="100%" height="100%"
>
<h3>Mers types</h3>
<div>
Mers uses a multiple-types system.
It keeps track of which types a variable could have
and constructs a type with that information.
<br>
For example, <code>int/float</code> can represent a number - int or
Optional types can be <code>[]/[t]</code> - either nothing or one v
Mers doesn't have null, it just has the empty tuple <code>[]</code>
</div>
<h3>No exceptions, no crashes</h3>
<div>
Errors in mers are passed as values.
Because of the type system, you are forced to handle them explicitl
Mers will not crash in unexpected places, because the only way to c
it is by using one of the assume*() functions (similar to unwrap()s
</div>
</section>
</section>
<hr>
<h3>HTML preprocessor to help build this document written in mers:</h3>
<section class="container">
<pre class="container2_left"><code>
$index.html
</code></pre>
<pre class="container2_right"><code class="mers-code-snippet">
$build_script
</code></pre>
</section>
</body>


 #!/usr/bin/env mers

// helper functions

fn read_string(path string) {
bytes_to_string(fs_read(path).assume_no_enum()).assume_no_enum()
}
fn code_to_html(code string code_width_limit_chars int) {
out = ""
for line code.regex(".*").assume_no_enum() {
if code_width_limit_chars.gtoe(0).and(line.len().gt(code_width_limit_chars)) {
line = line.substring(0 code_width_limit_chars)
}
line = line
.replace("&" "&amp;")
.replace("<" "&lt;")
.replace(">" "&gt;")
out = out.add(line.add("<br>"))
}
out
}

// data

index = read_string("index.html")

index_html = index.code_to_html(75)
build_script = read_string("build.mers").code_to_html(-1)
welcome_script = read_string("welcome.mers").code_to_html(-1)

// process index.html

out = ""
for line index.regex("\\S*.*").assume_no_enum() {
if line.starts_with("#") {
// comment, ignore
} else if line.starts_with("$") {
if line.eq("$welcome_script") {
out = out.add(welcome_script)
} else if line.eq("$build_script") {
out = out.add(build_script)
} else if line.eq("$index.html") {
out = out.add(index_html)
}
} else {
// remove spaces
loop {
if line.starts_with(" ") {
line = line.substring(1)
} else {
true // break
}
}
out = out.add(line.add("\n"))
}
}

fs_write("../index.html" string_to_bytes(out)).assume_no_enum()