changeset 1653:418b610e887b

docs work
author Franklin Schmidt <fschmidt@gmail.com>
date Thu, 31 Mar 2022 22:12:40 -0600
parents d5779a264a4a
children 3f28ea044a32
files website/src/diff.html.luan website/src/goodjava.html.luan website/src/lib/Shared.luan website/src/manual.html.luan website/src/site.css
diffstat 5 files changed, 358 insertions(+), 195 deletions(-) [+]
line wrap: on
line diff
diff -r d5779a264a4a -r 418b610e887b website/src/diff.html.luan
--- a/website/src/diff.html.luan	Thu Mar 31 19:04:59 2022 -0600
+++ b/website/src/diff.html.luan	Thu Mar 31 22:12:40 2022 -0600
@@ -5,84 +5,28 @@
 local Shared = require "site:/lib/Shared.luan"
 local head = Shared.head or error()
 local docs_header = Shared.docs_header or error()
+local show_toc = Shared.show_toc or error()
+local show_content = Shared.show_content or error()
 
 
-return function()
-	Io.stdout = Http.response.text_writer()
+local content = {
+	intro = {
+		title = "Introduction"
+		content = function()
 %>
-<!doctype html>
-<html>
-	<head>
-<%		head() %>
-		<title>How Luan differs from Lua</title>
-	</head>
-	<body>
-<%		docs_header() %>
-		<div content>
-
-<h1><a href="diff.html">How Luan differs from Lua</a></h1>
-
-<p>This document explains how Luan differs from <a href="http://www.lua.org">Lua</a> as described in the <a href="http://www.lua.org/manual/5.3/">Lua 5.3 Reference Manual</a>.</p>
-
-<hr/>
-
-<h2>Contents</h2>
-
-<div contents><a href="#intro">Introduction</a></div>
-
-<div contents>
-	<a href="#basic">Basic Concepts</a>
-	<ul>
-		<li><a href="#types">Values and Types</a></li>
-		<li><a href="#env">Environments</a></li>
-		<li><a href="#error">Error Handling</a></li>
-		<li><a href="#meta">Metatables and Metamethods</a></li>
-		<li><a href="#gc">Garbage Collection</a></li>
-		<li><a href="#coroutines">Coroutines</a></li>
-	</ul>
-</div>
-
-<div contents>
-	<a href="#lang">The Language</a>
-	<ul>
-		<li><a href="#lex">Lexical Conventions</a></li>
-		<li><a href="#vars">Variables</a></li>
-		<li>
-			<a href="#stmt">Statements</a>
-			<ul>
-				<li><a href="#control">Control Structures</a></li>
-				<li><a href="#for">For Statement</a></li>
-				<li><a href="#try">Try Statement</a></li>
-				<li><a href="#logical">Logical Statements</a></li>
-				<li><a href="#template_stmt">Template Statements</a></li>
-			</ul>
-		</li>
-		<li>
-			<a href="#expr">Expressions</a>
-			<ul>
-				<li><a href="#conversions">Coercions and Conversions</a></li>
-				<li><a href="#bit">Bitwise Operators</a></li>
-				<li><a href="#logical_ops">Logical Operators</a></li>
-				<li><a href="#concatenation">Concatenation</a></li>
-				<li><a href="#constructors">Table Constructors</a></li>
-				<li><a href="#fn_calls">Function Calls</a></li>
-			</ul>
-		</li>
-	</ul>
-</div>
-
-<hr/>
-
-<h2 heading><a name="intro" href="#intro">Introduction</a></h2>
-
 <p>Lua is one of the simplest languages available, but Luan is even simpler.  This means Luan removes more than it adds.  Most of what is added is added in the library, not in the language itself.</p>
 
 <p>Luan is implemented in Java and is tightly integrated with Java.  This makes it an excellent scripting language for Java.</p>
-
-<h2 heading><a name="basic" href="#basic">Basic Concepts</a></h2>
-
-<h3 heading><a name="types" href="#types">Values and Types</a></h3>
-
+<%
+		end
+	}
+	basic = {
+		title = "Basic Concepts"
+		subs = {
+			types = {
+				title = "Values and Types"
+				content = function()
+%>
 <p>Luan does not have the Lua <em>thread</em> type.  Luan adds a <em>binary</em> type that Lua doesn't have.  This is because Lua strings can represent binary while Luan strings cannot.</p>
 
 <p>The Luan <em>Nil</em> type is implemented as the Java <em>null</em>.  The Luan <em>Boolean</em> type is implemented as the Java <em>Boolean</em> type.  The Luan <em>Number</em> type is implemented as the Java <em>Number</em> type.  The Luan <em>String</em> type is implemented as the Java <em>String</em> type.  Actual numbers may be any subclass of the Java <em>Number</em> class.</p>
@@ -94,62 +38,104 @@
 <p>The Luan <em>binary</em> type is the Java <em>byte[ ]</em> type which is an array of bytes.</p>
 
 <p>The Luan <em>table</em> type is just like its Lua equivalent, but implemented in Java.</p>
-
-<h3 heading><a name="env" href="#env">Environments</a></h3>
-
+<%
+				end
+			}
+			env = {
+				title = "Environments"
+				content = function()
+%>
 <p>Luan has no global environment at all, no <code>_G</code>.  By default, Luan doesn't define <code>_ENV</code> either, but if you define it as a local table in a chunk, then it acts like it does in Lua.  When <code>_ENV</code> isn't defined, there are no global variables and an unrecognized variable name produces a compile error.</p>
 
 <p>Every module is initialized with one local function: <code>require</code>.  The module then uses this function to get access to whatever else it needs.</p>
-
-<h3 heading><a name="error" href="#error">Error Handling</a></h3>
-
+<%
+				end
+			}
+			error = {
+				title = "Error Handling"
+				content = function()
+%>
 <p>Luan has the function <code>error</code> but does not have <code>pcall</code> or <code>xpcall</code>.  Luan adds the <a href="#try">try statement</a> instead.  Luan errors are implemented as an error table, not as a message object.</p>
-
-<h3 heading><a name="meta" href="#meta">Metatables and Metamethods</a></h3>
-
+<%
+				end
+			}
+			meta = {
+				title = "Metatables and Metamethods"
+				content = function()
+%>
 <p>Luan only has metatable for tables, not for other types.</p>
 
 <p>Luan does not support the <b>call</b> metamethod.  There is nothing that one can do with the <b>call</b> metamethod that can't be done more cleanly with closures, so this was left out.</p>
-
-<h3 heading><a name="gc" href="#gc">Garbage Collection</a></h3>
-
+<%
+				end
+			}
+			gc = {
+				title = "Garbage Collection"
+				content = function()
+%>
 <p>Luan uses Java garbage collection.  Luan has no special garbage collection methods.</p>
 
 <p>Luan does not yet have weak tables but this will be added.</p>
-
-<h3 heading><a name="coroutines" href="#coroutines">Coroutines</a></h3>
-
+<%
+				end
+			}
+			coroutines = {
+				title = "Coroutines"
+				content = function()
+%>
 <p>Luan does not have coroutines.  Coroutines is a complex concept that isn't needed in a simple language, so it was left out.</p>
-
-<h2 heading><a name="lang" href="#lang">The Language</a></h2>
-
-<h3 heading><a name="lex" href="#lex">Lexical Conventions</a></h3>
-
+<%
+				end
+			}
+		}
+	}
+	lang = {
+		title = "The Language"
+		subs = {
+			lex = {
+				title = "Lexical Conventions"
+				content = function()
+%>
 <p>Unlike Lua, Luan considers the end of a line to be the end of a statement.  This catches errors and encourages readability.  If you want to continue a statement on another line, you can use a backslash followed by a newline which will be treated as white space.</p>
 
 <p>Luan has exactly the same set of keywords as Lua and has the same other lexical conventions.</p>
-
-<h3 heading><a name="vars" href="#vars">Variables</a></h3>
-
-<p>
-By default, there are no global variables and an undefined variable produces a compile error.  To enable global variables, one must define <code>_ENV</code>.  Avoiding global variables makes it much easier to catch errors at compile time.
-
-<h3 heading><a name="stmt" href="#stmt">Statements</a></h3>
-
+<%
+				end
+			}
+			vars = {
+				title = "Variables"
+				content = function()
+%>
+<p>By default, there are no global variables and an undefined variable produces a compile error.  To enable global variables, one must define <code>_ENV</code>.  Avoiding global variables makes it much easier to catch errors at compile time.</p>
+<%
+				end
+			}
+			stmt = {
+				title = "Statements"
+				content = function()
+%>
 <p>Luan adds the block terminators <b>end_do</b>, <b>end_for</b>, <b>end_function</b>, <b>end_if</b>, <b>end_try</b>, and <b>end_while</b>.  These can be used to end the appropriate block type, but <b>end</b> can also be used to end any block.</p>
 
 <p>Most statements in Luan are the same as Lua.  Only those statements that differ will be listed here.</p>
-
-<h4 heading><a name="control" href="#control">Control Structures</a></h4>
-
+<%
+				end
+				subs = {
+					control = {
+						title = "Control Structures"
+						content = function()
+%>
 <p>The Luan <b>if</b>, <b>while</b>, and <b>repeat</b> statement are the same as in Lua except that the condition expression must return a boolean value.  Any other value type will produce an error.  This helps catch errors and makes code more readable.</p>
 
 <p>Luan adds the <b>continue</b> statement which is used inside loops.</p>
 
 <p>Luan does not have a <b>goto</b> statement.</p>
-
-<h4 heading><a name="for" href="#for">For Statement</a></h4>
-
+<%
+						end
+					}
+					["for"] = {
+						title = "For Statement"
+						content = function()
+%>
 <p>Luan has no numeric <b>for</b> statement.  Luan only has generic <b>for</b> statement.  Instead of the numeric <b>for</b> statement, Luan uses the <code>range</code> function in a generic <b>for</b> statement like this:</p>
 
 <pre>
@@ -174,55 +160,122 @@
 		end
 	end
 </pre>
-
-
-<h4 heading><a name="try" href="#for">Try Statement</a></h4>
-
+<%
+						end
+					}
+					["try"] = {
+						title = "Try Statement"
+						content = function()
+%>
 <p>Unlike Lua, Luan has a <b>try</b> statement.  See  <a href="manual.html#try">Try Statement</a> in the Luan Reference Manual.  This also eliminates the need for Lua's <b>pcall</b> function which Luan doesn't have.</p>
-
-<h4 heading><a name="logical" href="#logical">Logical Statements</a></h4>
-
+<%
+						end
+					}
+					logical = {
+						title = "Logical Statements"
+						content = function()
+%>
 <p>Unlike Lua, Luan allows <b>or</b> and <b>and</b> expressions to be stand-alone statements.  This is useful in cases like this:</p>
 
 <pre>
 	x==5 or error "x should be 5"
 </pre>
-
-<h4 heading><a name="template_stmt" href="#template_stmt">Template Statements</a></h4>
-
+<%
+						end
+					}
+					template_stmt = {
+						title = "Template Statements"
+						content = function()
+%>
 <p>Template statements are a Luan addition that don't exist in Lua.  See <a href="manual.html#template_stmt">Template Statements</a> in the Luan Reference Manual.</p>
-
-
-<h3 heading><a name="expr" href="#expr">Expressions</a></h3>
-
-<h4 heading><a name="conversions" href="#conversions">Coercions and Conversions</a></h4>
-
+<%
+						end
+					}
+				}
+			}
+			expr = {
+				title = "Expressions"
+				subs = {
+					conversions = {
+						title = "Coercions and Conversions"
+						content = function()
+%>
 <p>Unlike Lua, Luan does not do automatic conversions of strings to numbers.</p>
-
-<h4 heading><a name="bit" href="#bit">Bitwise Operators</a></h4>
-
+<%
+						end
+					}
+					bit = {
+						title = "Bitwise Operators"
+						content = function()
+%>
 <p>Bitwise operators appear to be a new addition to Lua 5.3 and didn't exist in Lua 5.2.  Luan does not support bitwise operators, but these can be added if there is a need.</p>
-
-<h4 heading><a name="logical_ops" href="#logical_ops">Logical Operators</a></h4>
-
+<%
+						end
+					}
+					logical_ops = {
+						title = "Logical Operators"
+						content = function()
+%>
 <p>The only change in Luan is that <b>not</b> must take a boolean argument.  This helps catch errors and makes code more readable.</p>
-
-<h4 heading><a name="concatenation" href="#concatenation">Concatenation</a></h4>
-
-<p>Unlike Lua, Luan converts all concatenation operands to strings.
-
-<h4 heading><a name="constructors" href="#constructors">Table Constructors</a></h4>
-
+<%
+						end
+					}
+					concatenation = {
+						title = "Concatenation"
+						content = function()
+%>
+<p>Unlike Lua, Luan converts all concatenation operands to strings.</p>
+<%
+						end
+					}
+					constructors = {
+						title = "Table Constructors"
+						content = function()
+%>
 <p>Unlike Lua, Luan considers an <b>end_of_line</b> to be a field separator in a table constructor.</p>
-
-<h4 heading><a name="fn_calls" href="#fn_calls">Function Calls</a></h4>
-
+<%
+						end
+					}
+					fn_calls = {
+						title = "Function Calls"
+						content = function()
+%>
 <p>Unlike Lua, Luan does not allow extra non-nil arguments to be passed to a function.  In Luan, this causes an error.  This change helps find coding mistakes that would be very hard to detect otherwise.</p>
 
 <p>Luan does not support Lua's <code>v:name(args)</code> style object-oriented function call.  Object oriented programming is done in Luan using closures, so this feature is not needed.</p>
 
 <p>Luan doesn't support <em>proper tail calls</em>.  Because Java doesn't support this cleanly, this was left out.</p>
+<%
+						end
+					}
+				}
+			}
+		}
+	}
+}
 
+
+return function()
+	Io.stdout = Http.response.text_writer()
+%>
+<!doctype html>
+<html>
+	<head>
+<%		head() %>
+		<title>How Luan differs from Lua</title>
+	</head>
+	<body>
+<%		docs_header() %>
+		<div content>
+			<h1><a href="diff.html">How Luan differs from Lua</a></h1>
+			<p>This document explains how Luan differs from <a href="http://www.lua.org">Lua</a> as described in the <a href="http://www.lua.org/manual/5.3/">Lua 5.3 Reference Manual</a>.</p>
+			<hr>
+			<h2>Contents</h2>
+			<div toc>
+<%			show_toc(content) %>
+			</div>
+			<hr>
+<%			show_content(content,2) %>
 		</div>
 	</body>
 </html>
diff -r d5779a264a4a -r 418b610e887b website/src/goodjava.html.luan
--- a/website/src/goodjava.html.luan	Thu Mar 31 19:04:59 2022 -0600
+++ b/website/src/goodjava.html.luan	Thu Mar 31 22:12:40 2022 -0600
@@ -5,6 +5,98 @@
 local Shared = require "site:/lib/Shared.luan"
 local head = Shared.head or error()
 local header = Shared.header or error()
+local show_toc = Shared.show_toc or error()
+local show_content = Shared.show_content or error()
+
+
+local content = {
+	intro = {
+		title = "Introduction"
+		content = function()
+%>
+<p>The <a href="https://hg.luan.software/luan/file/default/src/goodjava">goodjava</a> library is independent of Luan.  Luan calls goodjava but goodjava never calls Luan code.  So goodjava can be used as a Java library.  goodjava is included in the Luan jar file.</p>
+
+<p>As western programming became depraved, it became more and more difficult to find good libraries.  So rather than use modern depraved libraries, I wrote my own.  I will describe the most important libraries.</p>
+<%
+		end
+	}
+	logger = {
+		title = "goodjava.logger"
+		content = function()
+%>
+<p>This includes <a href="https://hg.luan.software/luan/file/default/src/goodjava/logger">goodjava.logger</a> which replaces <a href="https://logging.apache.org/log4j/1.2/">log4j</a>, and <a href="https://hg.luan.software/luan/file/default/src/goodjava/logging">goodjava.logging</a> which replaces <a href="http://www.slf4j.org/">slf4j</a>.  You can see <a href="https://hg.luan.software/luan/file/default/src/goodjava/logger/examples">some examples</a> of how to use my logger.  Configuration is in Java, where it should be.</p>
+
+<p>slf4j is a typical modern mess.  Just look at <a href="http://www.slf4j.org/apidocs/org/slf4j/Logger.html">slf4j's logger</a> and compare to the interface of <a href="https://hg.luan.software/luan/file/default/src/goodjava/logging/Logger.java">my logger</a>.  log4j isn't horrible but has significant problems.  This project was abandoned by its author so that he could create a horrible depraved logger called <a href="http://logback.qos.ch/">Logback</a> to fit with his depraved culture.  log4j biggest problem is that it doesn't handle logging separation properly.  It's <a href="https://logging.apache.org/log4j/1.2/apidocs/org/apache/log4j/spi/RepositorySelector.html">RepositorySelector</a> is a hack.  goodjava.logger's <a href="https://hg.luan.software/luan/file/default/src/goodjava/logger/ThreadLocalAppender.java">ThreadLocalAppender</a> solves the problem properly.</p>
+
+<p>I implemented full bridging with slf4j, both slf4j to goodjava.logging and goodjava.logging to slf4j.  This way my code is completely compatible with depraved modern code.</p>
+<%
+		end
+	}
+	parser = {
+		title = "goodjava.parser"
+		content = function()
+%>
+<p>In computer science, parsing is a big deal.  They make it complicated, of course.  But it shouldn't be.  I developed a new approach to parsing which is implemented <a href="https://hg.luan.software/luan/file/default/src/goodjava/parser/">here</a>.  It is based on a simple stack of integers that are positions in what is effectively recursive descent parsing.  I use this idea to compile Luan but also to parse <a href="https://hg.luan.software/luan/file/default/src/goodjava/json/JsonParser.java">JSON</a>, <a href="https://hg.luan.software/luan/file/default/src/goodjava/lucene/queryparser/GoodQueryParser.java">Lucene queries</a>, <a href="https://hg.luan.software/luan/file/default/src/goodjava/webserver/RequestParser.java">HTTP requests</a>, <a href="https://hg.luan.software/luan/file/default/src/luan/modules/parsers/BBCode.java">BBCode</a>, <a href="https://hg.luan.software/luan/file/default/src/luan/modules/parsers/Css.java">CSS</a>, <a href="https://hg.luan.software/luan/file/default/src/luan/modules/parsers/Csv.java">CSV</a>, <a href="https://hg.luan.software/luan/file/default/src/luan/modules/parsers/Html.java">HTML</a>, and other things.</p>
+
+<p>When I wrote the <a href="https://hg.luan.software/luan/file/default/src/goodjava/json/JsonParser.java">JSON parser</a>, it worked on the first run.  It is so much simpler than any other JSON parser.  I dare you to look for any JSON parser as simple as this one.  All my other parsers are similar.  My approach to parsing reflects my anti-modern values.  I hate theoretical nonsense and I hate needless complexity.  Think deeply about a problem (like parsing) until you see the essence of it.  Then write clean simple code to solve the problem.</p>
+<%
+		end
+	}
+	json = {
+		title = "goodjava.json"
+		content = function()
+%>
+<p>Found <a href="https://hg.luan.software/luan/file/default/src/goodjava/json">here</a>, this lets you parse or create JSON easily.</p>
+<%
+		end
+	}
+	xml = {
+		title = "goodjava.xml"
+		content = function()
+%>
+<p>Yet another case where all existing libraries are horrible, so I wrote <a href="https://hg.luan.software/luan/file/default/src/goodjava/xml">my own</a>.</p>
+<%
+		end
+	}
+	rpc = {
+		title = "goodjava.rpc"
+		content = function()
+%>
+<p>Most RPCs (remote procedure calls) these days use REST which is really absurd because HTTP was never meant for this, so it is inefficient.  So I made a simple socket-based RPC that just uses JSON <a href="https://hg.luan.software/luan/file/default/src/goodjava/rpc">here</a>.  I use this to manage my luan hosting service.</p>
+<%
+		end
+	}
+	queryparser = {
+		title = "goodjava.lucene.queryparser"
+		content = function()
+%>
+<p>This is a better implementation of <a href="https://lucene.apache.org/core/4_9_0/queryparser/org/apache/lucene/queryparser/classic/package-summary.html#package_description">Lucene's QueryParser</a> which has serious defects like only being able to query text fields.  <a href="https://hg.luan.software/luan/file/default/src/goodjava/lucene/queryparser">My implementation</a> fixes all the defects.</p>
+<%
+		end
+	}
+	webserver = {
+		title = "goodjava.webserver"
+		content = function()
+%>
+<p>This is the first part of the library that I wrote.  I wrote it after studying all available java webservers and being horrified by them.  My hatred of modern software and modern culture was fully developed by this time, so I wrote this code intending to violate every rule of modern software, and I am rather pleased with the result.  The code is very clean and simple.  <a href="https://hg.luan.software/luan/file/default/src/goodjava/webserver/">Here</a> is the source.</p>
+
+<p>The core interface is <a href="https://hg.luan.software/luan/file/default/src/goodjava/webserver/Handler.java">Handler</a>.  Note the simplicity.  This takes a <a href="https://hg.luan.software/luan/file/default/src/goodjava/webserver/Request.java">Request</a> and returns a <a href="https://hg.luan.software/luan/file/default/src/goodjava/webserver/Response.java">Response</a> (or null if the request wasn't handled). Note how these classes are simple structs with no "get" and "set" methods. They are structs that directly represent the true underlying data in the HTTP protocol. No stupid obscuring layers (like servlets). Keep it raw and simple.</p>
+
+<p>To write a server, write your own Handler or chain together existing handlers. See this <a href="https://hg.luan.software/luan/file/default/src/goodjava/webserver/examples/Example.java">example</a>.</p>
+
+<p>I use this webserver by itself for development, and behind nginx for production. I have only implemented what I need as I need it. I haven't tried to make this a production-ready stand-alone webserver. That is much more work.</p>
+<%
+		end
+	}
+	mail = {
+		title = "goodjava.mail"
+		content = function()
+%>
+<p>The last horrible modern library that I replaced is <a href="https://javaee.github.io/javamail/">java.mail</a>.  <a href="https://hg.luan.software/luan/file/default/src/goodjava/mail">My code</a> to send mail is a little over 200 lines.  It is a thin layer on top of SMTP and MIME.</p>
+<%
+		end
+	}
+}
 
 
 return function()
@@ -19,57 +111,14 @@
 	<body>
 <%		header() %>
 		<div content>
-
-		<h1>The goodjava Library</h1>
-
-		<p>The <a href="https://hg.luan.software/luan/file/default/src/goodjava">goodjava</a> library is independent of Luan.  Luan calls goodjava but goodjava never calls Luan code.  So goodjava can be used as a Java library.  goodjava is included in the Luan jar file.</p>
-
-		<p>As western programming became depraved, it became more and more difficult to find good libraries.  So rather than use modern depraved libraries, I wrote my own.  I will describe the most important libraries.</p>
-
-		<h2>goodjava.logger</h2>
-
-		<p>This includes <a href="https://hg.luan.software/luan/file/default/src/goodjava/logger">goodjava.logger</a> which replaces <a href="https://logging.apache.org/log4j/1.2/">log4j</a>, and <a href="https://hg.luan.software/luan/file/default/src/goodjava/logging">goodjava.logging</a> which replaces <a href="http://www.slf4j.org/">slf4j</a>.  You can see <a href="https://hg.luan.software/luan/file/default/src/goodjava/logger/examples">some examples</a> of how to use my logger.  Configuration is in Java, where it should be.</p>
-
-		<p>slf4j is a typical modern mess.  Just look at <a href="http://www.slf4j.org/apidocs/org/slf4j/Logger.html">slf4j's logger</a> and compare to the interface of <a href="https://hg.luan.software/luan/file/default/src/goodjava/logging/Logger.java">my logger</a>.  log4j isn't horrible but has significant problems.  This project was abandoned by its author so that he could create a horrible depraved logger called <a href="http://logback.qos.ch/">Logback</a> to fit with his depraved culture.  log4j biggest problem is that it doesn't handle logging separation properly.  It's <a href="https://logging.apache.org/log4j/1.2/apidocs/org/apache/log4j/spi/RepositorySelector.html">RepositorySelector</a> is a hack.  goodjava.logger's <a href="https://hg.luan.software/luan/file/default/src/goodjava/logger/ThreadLocalAppender.java">ThreadLocalAppender</a> solves the problem properly.</p>
-
-		<p>I implemented full bridging with slf4j, both slf4j to goodjava.logging and goodjava.logging to slf4j.  This way my code is completely compatible with depraved modern code.</p>
-
-		<h2>goodjava.parser</h2>
-
-		<p>In computer science, parsing is a big deal.  They make it complicated, of course.  But it shouldn't be.  I developed a new approach to parsing which is implemented <a href="https://hg.luan.software/luan/file/default/src/goodjava/parser/">here</a>.  It is based on a simple stack of integers that are positions in what is effectively recursive descent parsing.  I use this idea to compile Luan but also to parse <a href="https://hg.luan.software/luan/file/default/src/goodjava/json/JsonParser.java">JSON</a>, <a href="https://hg.luan.software/luan/file/default/src/goodjava/lucene/queryparser/GoodQueryParser.java">Lucene queries</a>, <a href="https://hg.luan.software/luan/file/default/src/goodjava/webserver/RequestParser.java">HTTP requests</a>, <a href="https://hg.luan.software/luan/file/default/src/luan/modules/parsers/BBCode.java">BBCode</a>, <a href="https://hg.luan.software/luan/file/default/src/luan/modules/parsers/Css.java">CSS</a>, <a href="https://hg.luan.software/luan/file/default/src/luan/modules/parsers/Csv.java">CSV</a>, <a href="https://hg.luan.software/luan/file/default/src/luan/modules/parsers/Html.java">HTML</a>, and other things.</p>
-
-		<p>When I wrote the <a href="https://hg.luan.software/luan/file/default/src/goodjava/json/JsonParser.java">JSON parser</a>, it worked on the first run.  It is so much simpler than any other JSON parser.  I dare you to look for any JSON parser as simple as this one.  All my other parsers are similar.  My approach to parsing reflects my anti-modern values.  I hate theoretical nonsense and I hate needless complexity.  Think deeply about a problem (like parsing) until you see the essence of it.  Then write clean simple code to solve the problem.</p>
-
-		<h2>goodjava.json</h2>
-
-		<p>Found <a href="https://hg.luan.software/luan/file/default/src/goodjava/json">here</a>, this lets you parse or create JSON easily.</p>
-
-		<h2>goodjava.xml</h2>
-
-		<p>Yet another case where all existing libraries are horrible, so I wrote <a href="https://hg.luan.software/luan/file/default/src/goodjava/xml">my own</a>.</p>
-
-		<h2>goodjava.rpc</h2>
-
-		<p>Most RPCs (remote procedure calls) these days use REST which is really absurd because HTTP was never meant for this, so it is inefficient.  So I made a simple socket-based RPC that just uses JSON <a href="https://hg.luan.software/luan/file/default/src/goodjava/rpc">here</a>.  I use this to manage my luan hosting service.</p>
-
-		<h2>goodjava.lucene.queryparser</h2>
-
-		<p>This is a better implementation of <a href="https://lucene.apache.org/core/4_9_0/queryparser/org/apache/lucene/queryparser/classic/package-summary.html#package_description">Lucene's QueryParser</a> which has serious defects like only being able to query text fields.  <a href="https://hg.luan.software/luan/file/default/src/goodjava/lucene/queryparser">My implementation</a> fixes all the defects.</p>
-
-		<h2>goodjava.webserver</h2>
-
-		<p>This is the first part of the library that I wrote.  I wrote it after studying all available java webservers and being horrified by them.  My hatred of modern software and modern culture was fully developed by this time, so I wrote this code intending to violate every rule of modern software, and I am rather pleased with the result.  The code is very clean and simple.  <a href="https://hg.luan.software/luan/file/default/src/goodjava/webserver/">Here</a> is the source.</p>
-
-		<p>The core interface is <a href="https://hg.luan.software/luan/file/default/src/goodjava/webserver/Handler.java">Handler</a>.  Note the simplicity.  This takes a <a href="https://hg.luan.software/luan/file/default/src/goodjava/webserver/Request.java">Request</a> and returns a <a href="https://hg.luan.software/luan/file/default/src/goodjava/webserver/Response.java">Response</a> (or null if the request wasn't handled). Note how these classes are simple structs with no "get" and "set" methods. They are structs that directly represent the true underlying data in the HTTP protocol. No stupid obscuring layers (like servlets). Keep it raw and simple.</p>
-
-		<p>To write a server, write your own Handler or chain together existing handlers. See this <a href="https://hg.luan.software/luan/file/default/src/goodjava/webserver/examples/Example.java">example</a>.</p>
-
-		<p>I use this webserver by itself for development, and behind nginx for production. I have only implemented what I need as I need it. I haven't tried to make this a production-ready stand-alone webserver. That is much more work.</p>
-
-		<h2>goodjava.mail</h2>
-
-		<p>The last horrible modern library that I replaced is <a href="https://javaee.github.io/javamail/">java.mail</a>.  <a href="https://hg.luan.software/luan/file/default/src/goodjava/mail">My code</a> to send mail is a little over 200 lines.  It is a thin layer on top of SMTP and MIME.</p>
-
+			<h1><a href="goodjava.html">The goodjava Library</a></h1>
+			<hr>
+			<h2>Contents</h2>
+			<div toc>
+<%			show_toc(content) %>
+			</div>
+			<hr>
+<%			show_content(content,2) %>
 		</div>
 	</body>
 </html>
diff -r d5779a264a4a -r 418b610e887b website/src/lib/Shared.luan
--- a/website/src/lib/Shared.luan	Thu Mar 31 19:04:59 2022 -0600
+++ b/website/src/lib/Shared.luan	Thu Mar 31 22:12:40 2022 -0600
@@ -1,6 +1,7 @@
 local Luan = require "luan:Luan.luan"
 local error = Luan.error
 local ipairs = Luan.ipairs or error()
+local pairs = Luan.pairs or error()
 
 
 local Shared = {}
@@ -30,4 +31,45 @@
 	header{[[<a href="/docs.html">Documentation</a>]]}
 end
 
+local function show_toc(content)
+%>
+			<ul>
+<%
+	for id, info in pairs(content) do
+%>
+			<li><a id="c_<%=id%>" href="#<%=id%>"><%=info.title%></a>
+<%
+		local subs = info.subs
+		if subs ~= nil then
+			show_toc(subs)
+		end
+%>
+			</li>
+<%
+	end
+%>
+			</ul>
+<%
+end
+Shared.show_toc = show_toc
+
+local function nothing() end
+
+local function show_content(content,h)
+	for id, info in pairs(content) do
+%>
+			<div heading>
+				<h<%=h%>><a id="<%=id%>" href="#<%=id%>"><%=info.title%></a></h<%=h%>>
+				<a href="#c_<%=id%>">contents</a>
+			</div>
+<%
+		(info.content or nothing)()
+		local subs = info.subs
+		if subs ~= nil then
+			show_content(subs,h+1)
+		end
+	end
+end
+Shared.show_content = show_content
+
 return Shared
diff -r d5779a264a4a -r 418b610e887b website/src/manual.html.luan
--- a/website/src/manual.html.luan	Thu Mar 31 19:04:59 2022 -0600
+++ b/website/src/manual.html.luan	Thu Mar 31 22:12:40 2022 -0600
@@ -16,6 +16,15 @@
 <%		head() %>
 		<title>Luan Reference Manual</title>
 	<style>
+		div[contents] {
+			margin-bottom: 1em;
+		}
+		ul {
+			margin: 0;
+		}
+		[heading] {
+			margin-top: 2em;
+		}
 		p[keywords] {
 			font-family: monospace;
 			margin-left: 40px;
diff -r d5779a264a4a -r 418b610e887b website/src/site.css
--- a/website/src/site.css	Thu Mar 31 19:04:59 2022 -0600
+++ b/website/src/site.css	Thu Mar 31 22:12:40 2022 -0600
@@ -33,15 +33,25 @@
 	margin: 0.5em 0;
 }
 
-
-div[contents] {
-	margin-bottom: 1em;
+div[toc] ul {
+	list-style-type: none;
+}
+div[toc] > ul {
+	padding-left: 0;
 }
-ul {
+div[toc] > ul > li {
+	margin-bottom: 16px;
+}
+div[heading] {
+	display: flex;
+	justify-content: space-between;
+	margin-top: 36px;
+}
+div[heading] > * {
 	margin: 0;
 }
-[heading] {
-	margin-top: 2em;
+div[heading] > a {
+	font-size: 14px;
 }
 
 h4 code {