mirror of
https://github.com/Dummi26/mers.git
synced 2025-03-10 14:13:52 +01:00
.
This commit is contained in:
parent
65dc9e577e
commit
9b92c5b353
@ -1,7 +1,7 @@
|
||||
<!DOCTYPE html>
|
||||
<head>
|
||||
<meta charset=“UTF-8”>
|
||||
<link rel="stylesheet" href="site/external.css">
|
||||
<link rel="stylesheet" href="external.css">
|
||||
<title>Mark :: mers</title>
|
||||
</head>
|
||||
<body>
|
||||
@ -40,7 +40,7 @@ it is by using one of the assume*() functions (similar to unwrap()s).
|
||||
<h3>HTML preprocessor to help build this document written in mers:</h3>
|
||||
<section class="container">
|
||||
<pre class="container2_left"><code>
|
||||
<!DOCTYPE html><br># This document will be processed by build.mers.<br># Lines starting with hashtags are comments and will be ignored.<br># Lines starting with dollar-signs insert special text.<br># To escape this, put a space before the hashtag or dollar sign.<br><head><br> <meta charset=“UTF-8”><br> <link rel="stylesheet" href="site/external.css"><br> <title>Mark :: mers</title><br></head><br><body><br> <h1>Mers</h1><br> <section class="container"><br> <section class="container_left2 code-border"><br> <pre><code class="mers-code-snippet"><br>$welcome_script<br> </code></pre><br> </section><br> <section class="container_right"><br> <image<br> alt="some picture related to mers (todo)"<br> src="data:image/jpg;base64,/9j/4AAQSkZJRgABAQEASABIAAD/2wBDAP//////<br> width="100%" height="100%"<br> ><br> <h3>Mers types</h3><br> <div><br> Mers uses a multiple-types system.<br> It keeps track of which types a variable could have<br> and constructs a type with that information.<br> <br><br> For example, <code>int/float</code> can represent a number - int or<br> Optional types can be <code>[]/[t]</code> - either nothing or one v<br> Mers doesn't have null, it just has the empty tuple <code>[]</code><br> </div><br> <h3>No exceptions, no crashes</h3><br> <div><br> Errors in mers are passed as values.<br> Because of the type system, you are forced to handle them explicitl<br> Mers will not crash in unexpected places, because the only way to c<br> it is by using one of the assume*() functions (similar to unwrap()s<br> </div><br> </section><br> </section><br> <hr><br> <h3>HTML preprocessor to help build this document written in mers:</h3><br> <section class="container"><br> <pre class="container2_left"><code><br>$index.html<br> </code></pre><br> <pre class="container2_right"><code class="mers-code-snippet"><br>$build_script<br> </code></pre><br> </section><br></body><br><br></code></pre>
|
||||
<!DOCTYPE html><br># This document will be processed by build.mers.<br># Lines starting with hashtags are comments and will be ignored.<br># Lines starting with dollar-signs insert special text.<br># To escape this, put a space before the hashtag or dollar sign.<br><head><br> <meta charset=“UTF-8”><br> <link rel="stylesheet" href="external.css"><br> <title>Mark :: mers</title><br></head><br><body><br> <h1>Mers</h1><br> <section class="container"><br> <section class="container_left2 code-border"><br> <pre><code class="mers-code-snippet"><br>$welcome_script<br> </code></pre><br> </section><br> <section class="container_right"><br> <image<br> alt="some picture related to mers (todo)"<br> src="data:image/jpg;base64,/9j/4AAQSkZJRgABAQEASABIAAD/2wBDAP//////<br> width="100%" height="100%"<br> ><br> <h3>Mers types</h3><br> <div><br> Mers uses a multiple-types system.<br> It keeps track of which types a variable could have<br> and constructs a type with that information.<br> <br><br> For example, <code>int/float</code> can represent a number - int or<br> Optional types can be <code>[]/[t]</code> - either nothing or one v<br> Mers doesn't have null, it just has the empty tuple <code>[]</code><br> </div><br> <h3>No exceptions, no crashes</h3><br> <div><br> Errors in mers are passed as values.<br> Because of the type system, you are forced to handle them explicitl<br> Mers will not crash in unexpected places, because the only way to c<br> it is by using one of the assume*() functions (similar to unwrap()s<br> </div><br> </section><br> </section><br> <hr><br> <h3>HTML preprocessor to help build this document written in mers:</h3><br> <section class="container"><br> <pre class="container2_left"><code><br>$index.html<br> </code></pre><br> <pre class="container2_right"><code class="mers-code-snippet"><br>$build_script<br> </code></pre><br> </section><br></body><br><br></code></pre>
|
||||
<pre class="container2_right"><code class="mers-code-snippet">
|
||||
#!/usr/bin/env mers<br><br>// helper functions<br><br>fn read_string(path string) {<br> bytes_to_string(fs_read(path).assume_no_enum()).assume_no_enum()<br>}<br>fn code_to_html(code string code_width_limit_chars int) {<br> out = ""<br> for line code.regex(".*").assume_no_enum() {<br> if code_width_limit_chars.gtoe(0).and(line.len().gt(code_width_limit_chars)) {<br> line = line.substring(0 code_width_limit_chars)<br> }<br> line = line<br> .replace("&" "&amp;")<br> .replace("<" "&lt;")<br> .replace(">" "&gt;")<br> out = out.add(line.add("<br>"))<br> }<br> out<br>}<br><br>// data<br><br>index = read_string("index.html")<br><br>index_html = index.code_to_html(75)<br>build_script = read_string("build.mers").code_to_html(-1)<br>welcome_script = read_string("welcome.mers").code_to_html(-1)<br><br>// process index.html<br><br>out = ""<br>for line index.regex("\\S*.*").assume_no_enum() {<br> if line.starts_with("#") {<br> // comment, ignore<br> } else if line.starts_with("$") {<br> if line.eq("$welcome_script") {<br> out = out.add(welcome_script)<br> } else if line.eq("$build_script") {<br> out = out.add(build_script)<br> } else if line.eq("$index.html") {<br> out = out.add(index_html)<br> }<br> } else {<br> // remove spaces<br> loop {<br> if line.starts_with(" ") {<br> line = line.substring(1)<br> } else {<br> true // break<br> }<br> }<br> out = out.add(line.add("\n"))<br> }<br>}<br><br>fs_write("../index.html" string_to_bytes(out)).assume_no_enum()<br><br></code></pre>
|
||||
</section>
|
||||
|
Loading…
Reference in New Issue
Block a user