This commit is contained in:
mark 2023-05-04 05:54:01 +02:00
parent 65dc9e577e
commit 9b92c5b353

View File

@ -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>
&lt;!DOCTYPE html&gt;<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>&lt;head&gt;<br> &lt;meta charset=“UTF-8”&gt;<br> &lt;link rel="stylesheet" href="site/external.css"&gt;<br> &lt;title&gt;Mark :: mers&lt;/title&gt;<br>&lt;/head&gt;<br>&lt;body&gt;<br> &lt;h1&gt;Mers&lt;/h1&gt;<br> &lt;section class="container"&gt;<br> &lt;section class="container_left2 code-border"&gt;<br> &lt;pre&gt;&lt;code class="mers-code-snippet"&gt;<br>$welcome_script<br> &lt;/code&gt;&lt;/pre&gt;<br> &lt;/section&gt;<br> &lt;section class="container_right"&gt;<br> &lt;image<br> alt="some picture related to mers (todo)"<br> src="data:image/jpg;base64,/9j/4AAQSkZJRgABAQEASABIAAD/2wBDAP//////<br> width="100%" height="100%"<br> &gt;<br> &lt;h3&gt;Mers types&lt;/h3&gt;<br> &lt;div&gt;<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> &lt;br&gt;<br> For example, &lt;code&gt;int/float&lt;/code&gt; can represent a number - int or<br> Optional types can be &lt;code&gt;[]/[t]&lt;/code&gt; - either nothing or one v<br> Mers doesn't have null, it just has the empty tuple &lt;code&gt;[]&lt;/code&gt;<br> &lt;/div&gt;<br> &lt;h3&gt;No exceptions, no crashes&lt;/h3&gt;<br> &lt;div&gt;<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> &lt;/div&gt;<br> &lt;/section&gt;<br> &lt;/section&gt;<br> &lt;hr&gt;<br> &lt;h3&gt;HTML preprocessor to help build this document written in mers:&lt;/h3&gt;<br> &lt;section class="container"&gt;<br> &lt;pre class="container2_left"&gt;&lt;code&gt;<br>$index.html<br> &lt;/code&gt;&lt;/pre&gt;<br> &lt;pre class="container2_right"&gt;&lt;code class="mers-code-snippet"&gt;<br>$build_script<br> &lt;/code&gt;&lt;/pre&gt;<br> &lt;/section&gt;<br>&lt;/body&gt;<br><br></code></pre>
&lt;!DOCTYPE html&gt;<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>&lt;head&gt;<br> &lt;meta charset=“UTF-8”&gt;<br> &lt;link rel="stylesheet" href="external.css"&gt;<br> &lt;title&gt;Mark :: mers&lt;/title&gt;<br>&lt;/head&gt;<br>&lt;body&gt;<br> &lt;h1&gt;Mers&lt;/h1&gt;<br> &lt;section class="container"&gt;<br> &lt;section class="container_left2 code-border"&gt;<br> &lt;pre&gt;&lt;code class="mers-code-snippet"&gt;<br>$welcome_script<br> &lt;/code&gt;&lt;/pre&gt;<br> &lt;/section&gt;<br> &lt;section class="container_right"&gt;<br> &lt;image<br> alt="some picture related to mers (todo)"<br> src="data:image/jpg;base64,/9j/4AAQSkZJRgABAQEASABIAAD/2wBDAP//////<br> width="100%" height="100%"<br> &gt;<br> &lt;h3&gt;Mers types&lt;/h3&gt;<br> &lt;div&gt;<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> &lt;br&gt;<br> For example, &lt;code&gt;int/float&lt;/code&gt; can represent a number - int or<br> Optional types can be &lt;code&gt;[]/[t]&lt;/code&gt; - either nothing or one v<br> Mers doesn't have null, it just has the empty tuple &lt;code&gt;[]&lt;/code&gt;<br> &lt;/div&gt;<br> &lt;h3&gt;No exceptions, no crashes&lt;/h3&gt;<br> &lt;div&gt;<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> &lt;/div&gt;<br> &lt;/section&gt;<br> &lt;/section&gt;<br> &lt;hr&gt;<br> &lt;h3&gt;HTML preprocessor to help build this document written in mers:&lt;/h3&gt;<br> &lt;section class="container"&gt;<br> &lt;pre class="container2_left"&gt;&lt;code&gt;<br>$index.html<br> &lt;/code&gt;&lt;/pre&gt;<br> &lt;pre class="container2_right"&gt;&lt;code class="mers-code-snippet"&gt;<br>$build_script<br> &lt;/code&gt;&lt;/pre&gt;<br> &lt;/section&gt;<br>&lt;/body&gt;<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;" "&amp;amp;")<br> .replace("&lt;" "&amp;lt;")<br> .replace("&gt;" "&amp;gt;")<br> out = out.add(line.add("&lt;br&gt;"))<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>