<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>lua nova &#187; web</title>
	<atom:link href="http://luanova.org/tag/web/feed/" rel="self" type="application/rss+xml" />
	<link>http://luanova.org</link>
	<description>welcome to the moon</description>
	<lastBuildDate>Thu, 20 May 2010 16:18:20 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0</generator>
		<item>
		<title>Guardian of the Imperial Inkstand</title>
		<link>http://luanova.org/imperialguardian/</link>
		<comments>http://luanova.org/imperialguardian/#comments</comments>
		<pubDate>Fri, 22 Jan 2010 12:34:33 +0000</pubDate>
		<dc:creator>wra1th</dc:creator>
				<category><![CDATA[Lua]]></category>
		<category><![CDATA[web]]></category>

		<guid isPermaLink="false">http://luanova.org/?p=46</guid>
		<description><![CDATA[Some experiences of using Lua to create and maintain websites for other people. Making a website just for yourself is one matter; doing it for others brings into play a range of quite separate considerations, that affect even the technical matters of design and implementation. You are the pig in the middle, the bacon in [...]]]></description>
			<content:encoded><![CDATA[<p><em>Some experiences of using Lua to create and maintain websites
for other people</em>.</p>

<p>Making a website just for yourself is one matter; doing it for others
brings into play a range of quite separate considerations, that affect
even the technical matters of design and implementation. You are the
pig in the middle, the bacon in the sandwich, sitting between the site
on one side and its commissioners on the other. I am a slow learner, but
after a dozen years of experience of different commissions I have come to
some definite general conclusions.</p>

<p>First, even for modest websites, plenty of time is needed for preparation,
before you even start thinking about design or implementation; time for
establishing a proper protocol between yourself and those who have
commissioned you. Ensure that all communications between yourself and them
pass through a single intermediary, a spokesperson who can shield you from
the disagreements and internal rivalries into which it may be fatal to be
drawn. Your commissioners may well have a committee charged with
responsibility for the proposed website, and it will probably delegate its
duties to a number of people: Mr X the timetable, Miss Y the graphics,
Dr Z the document archive, &#8230; . Fine. Nice to know you, Mr X, Miss Y,
Dr Z, &#8230;
Have nothing to do with these arrangements. Insist that they all communicate
only through the spokesperson. The spokesperson will have to channel
information in both directions. That way, with any luck, you will not
have to explain more than a dozen times why web pages look different in
different browsers, and why enormous TIFF files intended for high quality
printing are not appropriate for graphics on web pages, because they
will take rather a long time to download.</p>

<p>To be realistic, it is too much to expect the more important members
of the website committee to stick to this regime. In any case, out
of friendliness they may want to express themselves personally. It
is for that reason that I recommend that during the development phase
of the website each page should contain within its header the tags</p>

<pre><code>&lt;meta  http-equiv="pragma" content="no-cache" /&gt;
&lt;meta  http-equiv="cache-control" content="no-cache" /&gt;
</code></pre>

<p>because otherwise you will have the committee chairman sending you
messages accusing you of not getting on with the job: &#8220;Hi Gavin,
Mr X says he sent you that stuff about emergency car-parking
three weeks ago and it still is not up on the website.&#8221;; and then
you will have to explain to a deeply suspicious technophobe all about
how browsers cache webpages and that he is still looking at the pages
that his browser cached three weeks ago, and no, you cannot tell him
how to clear the cache for himself because you do not know what operating
system or browser he is using (&#8220;operating system? what is that,
old boy?&#8221;).</p>

<p>I struck an extraordinary glitch when I was making the <a href="http://www.wra1th.plus.com/byzcong/">website</a> for the
twenty-first International Congress of Byzantine Studies, which took
place in London from 21 to 26 August 2006. It was a prestigious affair,
with the Prince of Wales as patron and a long list of eminent sponsoring
organizations. Clarence House had been persuaded to send me a facsimile
of a signed letter of welcome from HRH, in receipt of which I had to
sign an undertaking that I would not permit any improper use of it. I
put a link to it from the sponsors&#8217; page.</p>

<p>The organizing committee of the conference had obtained a lovely jpeg
from the British Museum, of a Byzantine wooden carving of an angel.
They used this to make a poster. I used a jpeg of that to make
the entry page of the site. Clicking on the angel was to bring one
to a page listing the sponsors, including HRH, and inviting the viewer
to choose either the English or the French version of the website.
In my innocence, I called the page &#8220;sponsor.html&#8221;. When it was up for
review by the organizing committee I began to get puzzled queries from
them. &#8220;I clicked on the angel, and nothing happened&#8221;, about half of them
reported. I had no problem, nor did the other half. It was very mysterious.
Eventually research showed the culprit to be an arrogant piece of Norton
AntiVirus software running on the computers of some committee members.
It had decided that &#8220;sponsor&#8221; was obscene or dangerous, apparently.
Thus was HRH&#8217;s letter censored by Norton. In the end I changed the file&#8217;s
name to &#8220;spons.html&#8221; and the problem went away. The moral, I suppose,
is that you have to fathom some pretty sick minds if your webpages
are to be viewable by the public.</p>

<p>It is time to turn from the human to the coding side of things. I have
always believed that the best principle is to keep all as simple as
possible. As none of my sites have been designed for huge traffic I have
always shunned client-side scripting. It is usually unnecessary. One
should also keep in mind that many users may not have the latest browser.
In any case, adoption of WAI (the <a href="http://www.w3.org/WAI/">Web Accessibility Initiative</a> ) is
mandatory for .gov.uk websites, and it makes sense for any site
that is to be used by the public, especially an academic public
that is not likely to have the latest hardware.</p>

<p>I always create my websites on my own machine. I generally divide
the directory for website-creation into two subdirectories: &#8220;site&#8221;,
to contain all the stuff to be uploaded to the server, and &#8220;data&#8221;
to hold the gubbins from which the website is to be created, usually
as a &#8220;make&#8221; project. The contents of the webpages I classify into
three groups:</p>

<ol>
<li><strong>furniture</strong> &#8211; the graphics and css stuff that determine a common theme;</li>
<li><strong>permanent content</strong> &#8211; usually text;</li>
<li><strong>formatted mutable data</strong> &#8211; usually held as a textual database, as lists of labelled records, for ease of updating with a text editor.</li>
</ol>

<p>I use Lua format for the databases and Lua scripts to input from the
data-directory and output the finished pages to the site-directory.
To begin with, for the Art Historians&#8217; Millennium bash, I used a Lua
program, called Weave, which I had developed for creating web pages.
Over time I improved it by generalizing to the production of any
sort of marked-up text. Eventually it simply got replaced by a Lua
library. I must make another blog about this, because Lua&#8217;s way
with strings was a key factor in the design of this software.
I also produced a Lua program, Infuse, to perform the abstract
task of pouring content into template files &#8211; a sort of mail-merge.
It was the actual experience of coping with the commissioned websites
that drove me to keep reinventing. The frustrating thing was that I
dared not change over to a newer regime until the project was completed.
By starting sufficiently early I could create my templates for
the approval of the commissioners, before the flood of content
hit me. It was important to have a design sufficiently flexible to
cope with sudden changes of tack. The Lua format for labelled
records was good in this respect, because extra fields could always
be added. By contrast, CSV format would have been hopeless.</p>

<p>Lua&#8217;s extreme portability was handy. My own machine ran neither
Windows, Linux nor MacOS. Yet when I did a website for an artist,
whose agent needed to take over the running of it, even though the
agent used Windows, there was no problem getting everything working
on his machine.</p>

<p>For the Byzantine Congress I was told that I had been appointed
&#7952;&#960;&#8054; &#964;&#959;&#8160; &#954;&#945;&#957;&#953;&#954;&#955;&#949;&#8055;&#959;&#965; ,
guardian of the imperial inkstand, so named because it was in the shape
of a little dog (canicula). To find out more about this prestigious
office, use Google.</p>

<p><a href="http://www.wra1th.plus.com/">Gavin Wraith</a></p>

<h2>Ropes are better than Strings: A Technical Appendix</h2>

<p>In Lua strings are immutable values. This means that you
should avoid building up strings out of small pieces,
because although they will eventually be garbage-collected,
all the intermediate stages of your construction will still be
there taking up storage. Building up a string of n characters
by consecutive concatenations will use a number of bytes
varying quadratically with n. So concatenations are something
to be avoided. What about the construction of web pages,
where markup and text must be intertwined? Surely that will
involve lots of concatenations?</p>

<p>Actually, no &#8211; it need not. Whether we think of an html document
as text with markup inserted, or whether we think of it as a
structure of nested tag-pairs with text inserted, either way we
are led to the concept of strings-with-holes. To be more formal
we define the datatype of &#8220;ropes&#8221; recursively by:</p>

<pre><code>rope = string | list of rope
</code></pre>

<p>In Lua syntax, a rope either looks like</p>

<pre><code>[[ ..... ]]
</code></pre>

<p>or like</p>

<pre><code>{ ........ }
</code></pre>

<p>where the contents of the braces are a comma separated list of
ropes.</p>

<p>Put another way, a rope is a tree whose leaves are strings. We
can think of it as a string that has been broken apart leaving gaps.
If we walk over a rope, depth first, printing out the leaves to a file,
then we can construct our marked-up text without doing any
string-concatenation at all.</p>

<p>So this code</p>

<pre><code>&lt;a href="http://luanova.org/"&gt;LuaNova&lt;/a&gt;
</code></pre>

<p>can be obtained by printing out the rope</p>


<div class="wp_syntax"><div class="code"><pre class="lua" style="font-family:monospace;">     <span style="color: #66cc66;">&#123;</span>
     <span style="color: #66cc66;">&#123;</span>
      <span style="color: #66cc66;">&#91;</span><span style="color: #66cc66;">&#91;</span><span style="color: #66cc66;">&lt;</span>a <span style="color: #66cc66;">&#93;</span><span style="color: #66cc66;">&#93;</span>,
      <span style="color: #66cc66;">&#123;</span>
       <span style="color: #66cc66;">&#91;</span><span style="color: #66cc66;">&#91;</span>href<span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;]],
       [[http://luanova.org/]],
       [[&quot;</span><span style="color: #66cc66;">&#93;</span><span style="color: #66cc66;">&#93;</span>,
      <span style="color: #66cc66;">&#125;</span>,
      <span style="color: #66cc66;">&#91;</span><span style="color: #66cc66;">&#91;</span><span style="color: #66cc66;">&gt;</span><span style="color: #66cc66;">&#93;</span><span style="color: #66cc66;">&#93;</span>,
     <span style="color: #66cc66;">&#125;</span>,
     <span style="color: #66cc66;">&#91;</span><span style="color: #66cc66;">&#91;</span>LuaNova<span style="color: #66cc66;">&#93;</span><span style="color: #66cc66;">&#93;</span>,
     <span style="color: #66cc66;">&#91;</span><span style="color: #66cc66;">&#91;</span><span style="color: #66cc66;">&lt;/</span>a<span style="color: #66cc66;">&gt;</span><span style="color: #66cc66;">&#93;</span><span style="color: #66cc66;">&#93;</span>,
     <span style="color: #66cc66;">&#125;</span></pre></div></div>


<p>If we define</p>


<div class="wp_syntax"><div class="code"><pre class="lua" style="font-family:monospace;">     link <span style="color: #66cc66;">=</span> <span style="color: #b1b100;">function</span> <span style="color: #66cc66;">&#40;</span>url<span style="color: #66cc66;">&#41;</span>
            <span style="color: #b1b100;">return</span> <span style="color: #b1b100;">function</span> <span style="color: #66cc66;">&#40;</span>label<span style="color: #66cc66;">&#41;</span>
                    <span style="color: #b1b100;">return</span> <span style="color: #66cc66;">&#123;</span>
     <span style="color: #66cc66;">&#123;</span>
      <span style="color: #66cc66;">&#91;</span><span style="color: #66cc66;">&#91;</span><span style="color: #66cc66;">&lt;</span>a <span style="color: #66cc66;">&#93;</span><span style="color: #66cc66;">&#93;</span>,
      <span style="color: #66cc66;">&#123;</span>
       <span style="color: #66cc66;">&#91;</span><span style="color: #66cc66;">&#91;</span>href<span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;]],
       url,
       [[&quot;</span><span style="color: #66cc66;">&#93;</span><span style="color: #66cc66;">&#93;</span>,
      <span style="color: #66cc66;">&#125;</span>,
      <span style="color: #66cc66;">&#91;</span><span style="color: #66cc66;">&#91;</span><span style="color: #66cc66;">&gt;</span><span style="color: #66cc66;">&#93;</span><span style="color: #66cc66;">&#93;</span>,
     <span style="color: #66cc66;">&#125;</span>,
     label,
     <span style="color: #66cc66;">&#91;</span><span style="color: #66cc66;">&#91;</span><span style="color: #66cc66;">&lt;/</span>a<span style="color: #66cc66;">&gt;</span><span style="color: #66cc66;">&#93;</span><span style="color: #66cc66;">&#93;</span>,
     <span style="color: #66cc66;">&#125;</span> <span style="color: #b1b100;">end</span> <span style="color: #b1b100;">end</span></pre></div></div>


<p>then our rope is just the value of</p>


<div class="wp_syntax"><div class="code"><pre class="lua" style="font-family:monospace;">    link <span style="color: #ff0000;">&quot;http://luanova.org/&quot;</span> <span style="color: #ff0000;">&quot;LuaNova&quot;</span></pre></div></div>


<p>There are two sorts of markup: &#8220;monotags&#8221; and &#8220;tags&#8221;.</p>

<p>By a monotag I mean something like</p>

<pre><code>&lt;tag_name attr /&gt;
</code></pre>

<p>and we can implement this as a function from ropes to ropes:</p>


<div class="wp_syntax"><div class="code"><pre class="lua" style="font-family:monospace;">    <span style="color: #b1b100;">function</span><span style="color: #66cc66;">&#40;</span>attr<span style="color: #66cc66;">&#41;</span> <span style="color: #b1b100;">return</span> <span style="color: #66cc66;">&#123;</span><span style="color: #ff0000;">&quot;&lt;tag_name &quot;</span>,attr,<span style="color: #ff0000;">&quot; /&gt;&quot;</span><span style="color: #66cc66;">&#125;</span> <span style="color: #b1b100;">end</span></pre></div></div>


<p>By a tag I mean something like</p>

<pre><code>&lt;tag_id attr&gt;stuff&lt;/tag_id&gt;
</code></pre>

<p>which we can implement as a function from ropes to functions from
ropes to ropes:</p>


<div class="wp_syntax"><div class="code"><pre class="lua" style="font-family:monospace;">     <span style="color: #b1b100;">function</span><span style="color: #66cc66;">&#40;</span>attr<span style="color: #66cc66;">&#41;</span>
      <span style="color: #b1b100;">return</span> <span style="color: #b1b100;">function</span><span style="color: #66cc66;">&#40;</span>stuff<span style="color: #66cc66;">&#41;</span> <span style="color: #b1b100;">return</span>
             <span style="color: #66cc66;">&#123;</span><span style="color: #ff0000;">&quot;&lt;tag_id &quot;</span>,attr,<span style="color: #ff0000;">&quot;&gt;&quot;</span>,stuff,<span style="color: #ff0000;">&quot;&lt;/tag_id&gt;&quot;</span><span style="color: #66cc66;">&#125;</span>
             <span style="color: #b1b100;">end</span>
     <span style="color: #b1b100;">end</span></pre></div></div>


<p>To simplify construction of webpages I invented a little language,
which I called <em>Weave</em>, as a fragment of Lua using strings and ropes
and named functions for the tags and monotags of HTML (see <a href="http://www.lua.org/notes/ltn010a.html">Lua technical
note 30</a> .)
After a while I broadened Weave&#8217;s abilities
so that it could cope with any sort of markup and no longer had
HTML&#8217;s tags and monotags built in. I introduced empty tables called
&#8220;TAG&#8221; and &#8220;MONOTAG&#8221; with metatables, so that using the __index key
I could define tag and monotag functions with notations like
&#8220;TAG.a&#8221; and &#8220;MONOTAG.img&#8221; and so on. This was more flexible, but it
did mean that the user had to define her own tags before building
a webpage. That did not matter, because by then CSS had appeared and
most webpages needed only a handful of tags and monotags. Eventually
I did away with Weave as a separate entity and simply used the Lua
module &#8220;xhtml&#8221; instead.</p>

<p>To create a very trivial webpage &#8220;foo.html&#8221; in the current directory,
run a Lua script as follows:</p>


<div class="wp_syntax"><div class="code"><pre class="lua" style="font-family:monospace;">     #<span style="color: #66cc66;">!</span> lua
     <span style="color: #b1b100;">require</span> <span style="color: #ff0000;">&quot;xhtml&quot;</span>
     <span style="color: #b1b100;">do</span>
     <span style="color: #b1b100;">local</span> mydoc <span style="color: #66cc66;">=</span> BEGIN <span style="color: #ff0000;">&quot;foo.html&quot;</span>
     <span style="color: #b1b100;">local</span> hstyle <span style="color: #66cc66;">=</span> <span style="color: #66cc66;">&#91;</span><span style="color: #66cc66;">&#91;</span>style<span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;text-align: centre;&quot;</span><span style="color: #66cc66;">&#93;</span><span style="color: #66cc66;">&#93;</span>
     <span style="color: #b1b100;">local</span> myheader, link <span style="color: #66cc66;">=</span> xhtml.TAG.h1, xhtml.link
     mydoc.BODY <span style="color: #66cc66;">=</span> <span style="color: #66cc66;">&#123;</span>
                   myheader <span style="color: #66cc66;">&#40;</span>hstyle<span style="color: #66cc66;">&#41;</span> <span style="color: #ff0000;">&quot;Try this&quot;</span><span style="color: #66cc66;">;</span>
                   link <span style="color: #ff0000;">&quot;http://luanova.org/&quot;</span> <span style="color: #ff0000;">&quot;Lua Nova&quot;</span><span style="color: #66cc66;">;</span>
                  <span style="color: #66cc66;">&#125;</span>
     END<span style="color: #66cc66;">&#40;</span>mydoc<span style="color: #66cc66;">&#41;</span> <span style="color: #808080; font-style: italic;">-- write the rope out to file</span>
     <span style="color: #b1b100;">end</span> <span style="color: #808080; font-style: italic;">-- do</span></pre></div></div>


<p>OK, this takes almost as long as creating the webpage by hand, for
this trivial example. But it should not take too much imagination
to see the possibilities. Practically every webpage I have created
for the last ten years has used this method.</p>

<p>Here are the relevant modules:</p>

<p><strong>weave.lua</strong></p>


<div class="wp_syntax"><div class="code"><pre class="lua" style="font-family:monospace;">     <span style="color: #808080; font-style: italic;">--[[
         The rope datatype is defined recursively:
&nbsp;
         data rope = string | list of rope.
&nbsp;
       Use:  status,err = rope.walk(rope,function)
             print(table.concat(err,&quot;.&quot;))
       Error message prints out index at each level.
     ]]</span>
     <span style="color: #b1b100;">local</span> <span style="color: #b1b100;">pcall</span> <span style="color: #66cc66;">=</span> <span style="color: #b1b100;">pcall</span>
     <span style="color: #b1b100;">local</span> <span style="color: #b1b100;">type</span> <span style="color: #66cc66;">=</span> <span style="color: #b1b100;">type</span>
     <span style="color: #b1b100;">local</span> <span style="color: #b1b100;">ipairs</span> <span style="color: #66cc66;">=</span> <span style="color: #b1b100;">ipairs</span>
     <span style="color: #b1b100;">local</span> <span style="color: #b1b100;">tostring</span> <span style="color: #66cc66;">=</span> <span style="color: #b1b100;">tostring</span>
     <span style="color: #b1b100;">local</span> <span style="color: #b1b100;">assert</span> <span style="color: #66cc66;">=</span> <span style="color: #b1b100;">assert</span>
     <span style="color: #b1b100;">local</span> <span style="color: #b1b100;">setmetatable</span> <span style="color: #66cc66;">=</span> <span style="color: #b1b100;">setmetatable</span>
     <span style="color: #b1b100;">local</span> open <span style="color: #66cc66;">=</span> <span style="color: #b1b100;">io.open</span>
&nbsp;
     module <span style="color: #ff0000;">&quot;weave&quot;</span>
&nbsp;
     <span style="color: #808080; font-style: italic;">-- ropes -------</span>
&nbsp;
     <span style="color: #b1b100;">local</span> t_err <span style="color: #66cc66;">=</span> <span style="color: #ff0000;">&quot;&lt;bad type: %s&gt;&quot;</span>
     <span style="color: #b1b100;">local</span> a_err <span style="color: #66cc66;">=</span> <span style="color: #ff0000;">&quot;&lt;bad arg: %s&gt;&quot;</span>
&nbsp;
     walk <span style="color: #66cc66;">=</span> <span style="color: #b1b100;">function</span><span style="color: #66cc66;">&#40;</span>x,f<span style="color: #66cc66;">&#41;</span>  <span style="color: #808080; font-style: italic;">-- apply f to leaves of tree x, depth first</span>
          <span style="color: #b1b100;">local</span> g
          g <span style="color: #66cc66;">=</span> <span style="color: #b1b100;">function</span><span style="color: #66cc66;">&#40;</span>x,e<span style="color: #66cc66;">&#41;</span> <span style="color: #808080; font-style: italic;">-- e = error stack</span>
             <span style="color: #b1b100;">local</span> x_type, status <span style="color: #66cc66;">=</span> <span style="color: #b1b100;">type</span><span style="color: #66cc66;">&#40;</span>x<span style="color: #66cc66;">&#41;</span>
             <span style="color: #b1b100;">if</span> x_type <span style="color: #66cc66;">==</span> <span style="color: #ff0000;">&quot;string&quot;</span> <span style="color: #b1b100;">then</span>
              status <span style="color: #66cc66;">=</span> <span style="color: #b1b100;">pcall</span><span style="color: #66cc66;">&#40;</span>f,x<span style="color: #66cc66;">&#41;</span>
              <span style="color: #b1b100;">if</span> <span style="color: #b1b100;">not</span> status <span style="color: #b1b100;">then</span> e<span style="color: #66cc66;">&#91;</span><span style="color: #cc66cc;">1</span>+#e<span style="color: #66cc66;">&#93;</span> <span style="color: #66cc66;">=</span> a_err:<span style="color: #b1b100;">format</span><span style="color: #66cc66;">&#40;</span>x<span style="color: #66cc66;">&#41;</span> <span style="color: #b1b100;">end</span> <span style="color: #808080; font-style: italic;">-- if</span>
                  <span style="color: #b1b100;">return</span> status,e
              <span style="color: #b1b100;">elseif</span> x_type <span style="color: #66cc66;">==</span> <span style="color: #ff0000;">&quot;table&quot;</span> <span style="color: #b1b100;">then</span>
                  e<span style="color: #66cc66;">&#91;</span><span style="color: #cc66cc;">1</span>+#e<span style="color: #66cc66;">&#93;</span> <span style="color: #66cc66;">=</span> <span style="color: #ff0000;">&quot;&quot;</span>
                  <span style="color: #b1b100;">for</span> i,y <span style="color: #b1b100;">in</span> <span style="color: #b1b100;">ipairs</span><span style="color: #66cc66;">&#40;</span>x<span style="color: #66cc66;">&#41;</span> <span style="color: #b1b100;">do</span>
                    e<span style="color: #66cc66;">&#91;</span>#e<span style="color: #66cc66;">&#93;</span> <span style="color: #66cc66;">=</span> <span style="color: #b1b100;">tostring</span><span style="color: #66cc66;">&#40;</span>i<span style="color: #66cc66;">&#41;</span>
                    status <span style="color: #66cc66;">=</span> g<span style="color: #66cc66;">&#40;</span>y,e<span style="color: #66cc66;">&#41;</span>
                    <span style="color: #b1b100;">if</span> <span style="color: #b1b100;">not</span> status <span style="color: #b1b100;">then</span> <span style="color: #b1b100;">return</span> <span style="color: #b1b100;">nil</span>,e <span style="color: #b1b100;">end</span> <span style="color: #808080; font-style: italic;">-- if</span>
                  <span style="color: #b1b100;">end</span> <span style="color: #808080; font-style: italic;">-- for</span>
                  e<span style="color: #66cc66;">&#91;</span>#e<span style="color: #66cc66;">&#93;</span> <span style="color: #66cc66;">=</span> <span style="color: #b1b100;">nil</span>
                  <span style="color: #b1b100;">return</span> <span style="color: #b1b100;">true</span>
                <span style="color: #b1b100;">else</span>
                  e<span style="color: #66cc66;">&#91;</span><span style="color: #cc66cc;">1</span>+#e<span style="color: #66cc66;">&#93;</span> <span style="color: #66cc66;">=</span> t_err:<span style="color: #b1b100;">format</span><span style="color: #66cc66;">&#40;</span>x_type<span style="color: #66cc66;">&#41;</span>
                  <span style="color: #b1b100;">return</span> <span style="color: #b1b100;">nil</span>,e
                <span style="color: #b1b100;">end</span> <span style="color: #808080; font-style: italic;">-- if</span>
              <span style="color: #b1b100;">end</span> <span style="color: #808080; font-style: italic;">-- function</span>
              <span style="color: #b1b100;">return</span> g<span style="color: #66cc66;">&#40;</span>x,<span style="color: #66cc66;">&#123;</span><span style="color: #66cc66;">&#125;</span><span style="color: #66cc66;">&#41;</span>
        <span style="color: #b1b100;">end</span>
&nbsp;
       <span style="color: #b1b100;">local</span> file_err <span style="color: #66cc66;">=</span> <span style="color: #ff0000;">&quot;cannot open %s&quot;</span>
       out <span style="color: #66cc66;">=</span> <span style="color: #b1b100;">function</span><span style="color: #66cc66;">&#40;</span>x,file<span style="color: #66cc66;">&#41;</span>
             <span style="color: #b1b100;">local</span> o <span style="color: #66cc66;">=</span> <span style="color: #b1b100;">assert</span><span style="color: #66cc66;">&#40;</span>open<span style="color: #66cc66;">&#40;</span>file,<span style="color: #ff0000;">&quot;w&quot;</span><span style="color: #66cc66;">&#41;</span>,file_err:<span style="color: #b1b100;">format</span><span style="color: #66cc66;">&#40;</span>file<span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span>
             <span style="color: #b1b100;">local</span> f <span style="color: #66cc66;">=</span> <span style="color: #b1b100;">function</span><span style="color: #66cc66;">&#40;</span>s<span style="color: #66cc66;">&#41;</span>
                       o:<span style="color: #b1b100;">write</span><span style="color: #66cc66;">&#40;</span>s <span style="color: #b1b100;">or</span> <span style="color: #ff0000;">&quot;&quot;</span><span style="color: #66cc66;">&#41;</span>
                       <span style="color: #b1b100;">return</span> <span style="color: #b1b100;">true</span>
                       <span style="color: #b1b100;">end</span> <span style="color: #808080; font-style: italic;">-- function</span>
             <span style="color: #b1b100;">local</span> status,err <span style="color: #66cc66;">=</span> walk<span style="color: #66cc66;">&#40;</span>x,f<span style="color: #66cc66;">&#41;</span>
             o:close<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>
             <span style="color: #b1b100;">return</span> status,err
             <span style="color: #b1b100;">end</span> <span style="color: #808080; font-style: italic;">-- function</span>
&nbsp;
       <span style="color: #808080; font-style: italic;">------ markup stuff --------------</span>
       <span style="color: #808080; font-style: italic;">--[[
       Two types of tag:
&nbsp;
         monotag    &lt;foo attributestring /&gt;
         tag    &lt;foo attributestring&gt; rope &lt;/foo&gt;
&nbsp;
       where attributestring could be empty.
         ]]</span>
&nbsp;
       <span style="color: #b1b100;">local</span> monotagger <span style="color: #66cc66;">=</span> <span style="color: #66cc66;">&#123;</span>
       __index <span style="color: #66cc66;">=</span> <span style="color: #b1b100;">function</span> <span style="color: #66cc66;">&#40;</span>_,tag<span style="color: #66cc66;">&#41;</span>
                 <span style="color: #b1b100;">assert</span><span style="color: #66cc66;">&#40;</span><span style="color: #b1b100;">type</span><span style="color: #66cc66;">&#40;</span>tag<span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">==</span> <span style="color: #ff0000;">&quot;string&quot;</span><span style="color: #66cc66;">&#41;</span>
                 <span style="color: #b1b100;">return</span> <span style="color: #b1b100;">function</span> <span style="color: #66cc66;">&#40;</span>attr<span style="color: #66cc66;">&#41;</span>
                        <span style="color: #b1b100;">local</span> o <span style="color: #66cc66;">=</span> <span style="color: #66cc66;">&#123;</span><span style="color: #ff0000;">&quot;&lt;&quot;</span>,tag<span style="color: #66cc66;">&#125;</span>
                        <span style="color: #b1b100;">if</span> attr <span style="color: #b1b100;">and</span> <span style="color: #66cc66;">&#40;</span>#attr <span style="color: #66cc66;">&gt;</span> <span style="color: #cc66cc;">0</span><span style="color: #66cc66;">&#41;</span> <span style="color: #b1b100;">then</span>
                          o<span style="color: #66cc66;">&#91;</span><span style="color: #cc66cc;">1</span>+#o<span style="color: #66cc66;">&#93;</span> <span style="color: #66cc66;">=</span> <span style="color: #ff0000;">&quot; &quot;</span>
                          o<span style="color: #66cc66;">&#91;</span><span style="color: #cc66cc;">1</span>+#o<span style="color: #66cc66;">&#93;</span> <span style="color: #66cc66;">=</span> attr
                        <span style="color: #b1b100;">end</span> <span style="color: #808080; font-style: italic;">-- if</span>
                        o<span style="color: #66cc66;">&#91;</span><span style="color: #cc66cc;">1</span>+#o<span style="color: #66cc66;">&#93;</span> <span style="color: #66cc66;">=</span> <span style="color: #ff0000;">&quot; /&gt;&quot;</span>
                        <span style="color: #b1b100;">return</span> o
                        <span style="color: #b1b100;">end</span> <span style="color: #808080; font-style: italic;">-- function</span>
                  <span style="color: #b1b100;">end</span> <span style="color: #808080; font-style: italic;">-- function</span>
                 <span style="color: #66cc66;">&#125;</span>
&nbsp;
       <span style="color: #b1b100;">local</span> bitagger <span style="color: #66cc66;">=</span> <span style="color: #66cc66;">&#123;</span>
       __index <span style="color: #66cc66;">=</span> <span style="color: #b1b100;">function</span> <span style="color: #66cc66;">&#40;</span>_,tag<span style="color: #66cc66;">&#41;</span>
                 <span style="color: #b1b100;">assert</span><span style="color: #66cc66;">&#40;</span><span style="color: #b1b100;">type</span><span style="color: #66cc66;">&#40;</span>tag<span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">==</span> <span style="color: #ff0000;">&quot;string&quot;</span><span style="color: #66cc66;">&#41;</span>
                 <span style="color: #b1b100;">return</span> <span style="color: #b1b100;">function</span> <span style="color: #66cc66;">&#40;</span>attr<span style="color: #66cc66;">&#41;</span>
                        <span style="color: #b1b100;">return</span> <span style="color: #b1b100;">function</span> <span style="color: #66cc66;">&#40;</span>rope<span style="color: #66cc66;">&#41;</span>
                         <span style="color: #b1b100;">local</span> o <span style="color: #66cc66;">=</span> <span style="color: #66cc66;">&#123;</span><span style="color: #ff0000;">&quot;&lt;&quot;</span>,tag<span style="color: #66cc66;">&#125;</span>
                         <span style="color: #b1b100;">if</span> attr <span style="color: #b1b100;">and</span> <span style="color: #66cc66;">&#40;</span>#attr <span style="color: #66cc66;">&gt;</span> <span style="color: #cc66cc;">0</span><span style="color: #66cc66;">&#41;</span> <span style="color: #b1b100;">then</span>
                          o<span style="color: #66cc66;">&#91;</span><span style="color: #cc66cc;">1</span>+#o<span style="color: #66cc66;">&#93;</span> <span style="color: #66cc66;">=</span> <span style="color: #ff0000;">&quot; &quot;</span>
                          o<span style="color: #66cc66;">&#91;</span><span style="color: #cc66cc;">1</span>+#o<span style="color: #66cc66;">&#93;</span> <span style="color: #66cc66;">=</span> attr
                         <span style="color: #b1b100;">end</span> <span style="color: #808080; font-style: italic;">-- if</span>
                         o<span style="color: #66cc66;">&#91;</span><span style="color: #cc66cc;">1</span>+#o<span style="color: #66cc66;">&#93;</span> <span style="color: #66cc66;">=</span> <span style="color: #ff0000;">&quot;&gt;&quot;</span>
                         o<span style="color: #66cc66;">&#91;</span><span style="color: #cc66cc;">1</span>+#o<span style="color: #66cc66;">&#93;</span> <span style="color: #66cc66;">=</span> rope
                         o<span style="color: #66cc66;">&#91;</span><span style="color: #cc66cc;">1</span>+#o<span style="color: #66cc66;">&#93;</span> <span style="color: #66cc66;">=</span> <span style="color: #ff0000;">&quot;&lt;/&quot;</span>
                         o<span style="color: #66cc66;">&#91;</span><span style="color: #cc66cc;">1</span>+#o<span style="color: #66cc66;">&#93;</span> <span style="color: #66cc66;">=</span> tag
                         o<span style="color: #66cc66;">&#91;</span><span style="color: #cc66cc;">1</span>+#o<span style="color: #66cc66;">&#93;</span> <span style="color: #66cc66;">=</span> <span style="color: #ff0000;">&quot;&gt;&quot;</span>
                         <span style="color: #b1b100;">return</span> o
                  <span style="color: #b1b100;">end</span> <span style="color: #b1b100;">end</span> <span style="color: #b1b100;">end</span>
                  <span style="color: #66cc66;">&#125;</span>
       MONOTAG, TAG <span style="color: #66cc66;">=</span> <span style="color: #66cc66;">&#123;</span><span style="color: #66cc66;">&#125;</span>,<span style="color: #66cc66;">&#123;</span><span style="color: #66cc66;">&#125;</span>
       <span style="color: #b1b100;">setmetatable</span><span style="color: #66cc66;">&#40;</span>MONOTAG,monotagger<span style="color: #66cc66;">&#41;</span>
       <span style="color: #b1b100;">setmetatable</span><span style="color: #66cc66;">&#40;</span>TAG,bitagger<span style="color: #66cc66;">&#41;</span></pre></div></div>


<p><strong>xhtml.lua</strong></p>


<div class="wp_syntax"><div class="code"><pre class="lua" style="font-family:monospace;">       <span style="color: #808080; font-style: italic;">--[[ The xhtml library exports
&nbsp;
         TAG, MONOTAG, BEGIN, END, TEXT, SPACE, REM and link
&nbsp;
       ]]</span>
&nbsp;
&nbsp;
       <span style="color: #b1b100;">require</span> <span style="color: #ff0000;">&quot;weave&quot;</span>
&nbsp;
       <span style="color: #b1b100;">local</span> <span style="color: #b1b100;">assert</span> <span style="color: #66cc66;">=</span> <span style="color: #b1b100;">assert</span>
       <span style="color: #b1b100;">local</span> <span style="color: #b1b100;">type</span> <span style="color: #66cc66;">=</span> <span style="color: #b1b100;">type</span>
       <span style="color: #b1b100;">local</span> <span style="color: #b1b100;">pairs</span> <span style="color: #66cc66;">=</span> <span style="color: #b1b100;">pairs</span>
       <span style="color: #b1b100;">local</span> <span style="color: #b1b100;">print</span> <span style="color: #66cc66;">=</span> <span style="color: #b1b100;">print</span>
       <span style="color: #b1b100;">local</span> this <span style="color: #66cc66;">=</span> arg<span style="color: #66cc66;">&#91;</span><span style="color: #cc66cc;">0</span><span style="color: #66cc66;">&#93;</span>
       <span style="color: #b1b100;">local</span> leaf <span style="color: #66cc66;">=</span> this:match<span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">&quot;<span style="color: #000099; font-weight: bold;">\\</span>([^<span style="color: #000099; font-weight: bold;">\\</span>]*)$&quot;</span><span style="color: #66cc66;">&#41;</span>
       <span style="color: #b1b100;">local</span> weave <span style="color: #66cc66;">=</span> weave
       <span style="color: #b1b100;">local</span> walk <span style="color: #66cc66;">=</span> weave.walk
       <span style="color: #b1b100;">local</span> out <span style="color: #66cc66;">=</span> weave.out
&nbsp;
       <span style="color: #b1b100;">local</span> concat <span style="color: #66cc66;">=</span> <span style="color: #b1b100;">table.concat</span>
&nbsp;
       module <span style="color: #ff0000;">&quot;xhtml&quot;</span>
&nbsp;
       MONOTAG <span style="color: #66cc66;">=</span> weave.MONOTAG
       TAG <span style="color: #66cc66;">=</span> weave.TAG
&nbsp;
       <span style="color: #b1b100;">local</span> doctype <span style="color: #66cc66;">=</span> <span style="color: #66cc66;">&#91;</span><span style="color: #66cc66;">&#91;</span>
       <span style="color: #66cc66;">&lt;!</span>DOCTYPE html PUBLIC <span style="color: #ff0000;">&quot;-//W3C//DTD XHTML 1.0 Transitional//EN&quot;</span>
       <span style="color: #ff0000;">&quot;http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd&quot;</span><span style="color: #66cc66;">&gt;</span><span style="color: #66cc66;">&#93;</span><span style="color: #66cc66;">&#93;</span>
&nbsp;
       <span style="color: #b1b100;">local</span> HTML <span style="color: #66cc66;">=</span> TAG.html <span style="color: #66cc66;">&#91;</span><span style="color: #66cc66;">&#91;</span>
       xmlns<span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;http://www.w3.org/1999/xhtml&quot;</span> xml:lang<span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;en&quot;</span> lang<span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;en&quot;</span><span style="color: #66cc66;">&#93;</span><span style="color: #66cc66;">&#93;</span>
&nbsp;
       <span style="color: #b1b100;">local</span> nl <span style="color: #66cc66;">=</span> <span style="color: #ff0000;">&quot;<span style="color: #000099; font-weight: bold;">\n</span>&quot;</span>
&nbsp;
       BEGIN <span style="color: #66cc66;">=</span> <span style="color: #b1b100;">function</span><span style="color: #66cc66;">&#40;</span>filename<span style="color: #66cc66;">&#41;</span>
               <span style="color: #b1b100;">if</span> filename <span style="color: #b1b100;">then</span>
                 <span style="color: #b1b100;">assert</span><span style="color: #66cc66;">&#40;</span><span style="color: #b1b100;">type</span><span style="color: #66cc66;">&#40;</span>filename<span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">==</span> <span style="color: #ff0000;">&quot;string&quot;</span>,<span style="color: #ff0000;">&quot;BEGIN takes a string or nil&quot;</span><span style="color: #66cc66;">&#41;</span>
               <span style="color: #b1b100;">end</span> <span style="color: #808080; font-style: italic;">-- if</span>
               <span style="color: #b1b100;">return</span> <span style="color: #66cc66;">&#123;</span> FILE <span style="color: #66cc66;">=</span> filename <span style="color: #b1b100;">or</span> this..<span style="color: #ff0000;">&quot;.html&quot;</span><span style="color: #66cc66;">;</span> <span style="color: #66cc66;">&#125;</span>
               <span style="color: #b1b100;">end</span>
&nbsp;
       <span style="color: #b1b100;">local</span> META,LINK <span style="color: #66cc66;">=</span> MONOTAG.meta,MONOTAG.link
       <span style="color: #b1b100;">local</span> HEAD,BODY,TITLE <span style="color: #66cc66;">=</span> TAG.head <span style="color: #ff0000;">&quot;&quot;</span>,TAG.body,TAG.title <span style="color: #ff0000;">&quot;&quot;</span>
       <span style="color: #b1b100;">local</span> css <span style="color: #66cc66;">=</span> <span style="color: #66cc66;">&#91;</span><span style="color: #66cc66;">&#91;</span>rel<span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;stylesheet&quot;</span> <span style="color: #b1b100;">type</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;text/css&quot;</span> media<span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;screen&quot;</span> href<span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;&quot;</span><span style="color: #66cc66;">&#93;</span><span style="color: #66cc66;">&#93;</span>
&nbsp;
       END <span style="color: #66cc66;">=</span> <span style="color: #b1b100;">function</span><span style="color: #66cc66;">&#40;</span>rope<span style="color: #66cc66;">&#41;</span>
             <span style="color: #b1b100;">local</span> file <span style="color: #66cc66;">=</span> rope.FILE
             <span style="color: #b1b100;">local</span> style <span style="color: #66cc66;">=</span> rope.STYLE
             <span style="color: #b1b100;">local</span> doc <span style="color: #66cc66;">=</span> <span style="color: #66cc66;">&#123;</span>
              rope.DOCTYPE <span style="color: #b1b100;">or</span> doctype<span style="color: #66cc66;">;</span>
              nl<span style="color: #66cc66;">;</span>
              HTML <span style="color: #66cc66;">&#123;</span>
               nl<span style="color: #66cc66;">;</span>
               HEAD <span style="color: #66cc66;">&#123;</span>
                nl<span style="color: #66cc66;">;</span>
                TITLE <span style="color: #66cc66;">&#40;</span>rope.TITLE <span style="color: #b1b100;">or</span> leaf<span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">;</span>
                nl<span style="color: #66cc66;">;</span>
                META <span style="color: #66cc66;">&#91;</span><span style="color: #66cc66;">&#91;</span>name<span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;Generator&quot;</span> content<span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;Lua&quot;</span><span style="color: #66cc66;">&#93;</span><span style="color: #66cc66;">&#93;</span><span style="color: #66cc66;">;</span>
                nl<span style="color: #66cc66;">;</span>
                META <span style="color: #66cc66;">&#91;</span><span style="color: #66cc66;">&#91;</span>name<span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;MSSmartTagsPreventParsing&quot;</span> content<span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;TRUE&quot;</span><span style="color: #66cc66;">&#93;</span><span style="color: #66cc66;">&#93;</span><span style="color: #66cc66;">;</span>
                nl<span style="color: #66cc66;">;</span>
                rope.HEAD <span style="color: #b1b100;">or</span> <span style="color: #ff0000;">&quot;&quot;</span><span style="color: #66cc66;">;</span>
                style <span style="color: #b1b100;">and</span> LINK <span style="color: #66cc66;">&#123;</span>css<span style="color: #66cc66;">;</span>style<span style="color: #66cc66;">;</span><span style="color: #ff0000;">'&quot;'</span><span style="color: #66cc66;">&#125;</span> <span style="color: #b1b100;">or</span> <span style="color: #ff0000;">&quot;&quot;</span><span style="color: #66cc66;">;</span>
                    <span style="color: #66cc66;">&#125;</span><span style="color: #66cc66;">;</span>
                nl<span style="color: #66cc66;">;</span>
                BODY <span style="color: #66cc66;">&#40;</span>rope.ATTR <span style="color: #b1b100;">or</span> <span style="color: #ff0000;">&quot;&quot;</span><span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#40;</span>rope.BODY <span style="color: #b1b100;">or</span> <span style="color: #ff0000;">&quot;&quot;</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">;</span>
                nl<span style="color: #66cc66;">;</span>
                  <span style="color: #66cc66;">&#125;</span><span style="color: #66cc66;">;</span>
                          <span style="color: #66cc66;">&#125;</span>
              status, err <span style="color: #66cc66;">=</span> out<span style="color: #66cc66;">&#40;</span>doc,file<span style="color: #66cc66;">&#41;</span>
              <span style="color: #b1b100;">if</span> <span style="color: #b1b100;">not</span> status <span style="color: #b1b100;">then</span> <span style="color: #b1b100;">print</span><span style="color: #66cc66;">&#40;</span>concat<span style="color: #66cc66;">&#40;</span>err,<span style="color: #ff0000;">'.'</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span> <span style="color: #b1b100;">end</span> <span style="color: #808080; font-style: italic;">-- if</span>
              <span style="color: #b1b100;">end</span> <span style="color: #808080; font-style: italic;">--function</span>
&nbsp;
       <span style="color: #b1b100;">local</span> entity <span style="color: #66cc66;">=</span> <span style="color: #66cc66;">&#123;</span>
         <span style="color: #66cc66;">&#91;</span><span style="color: #ff0000;">&quot;&lt;&quot;</span><span style="color: #66cc66;">&#93;</span> <span style="color: #66cc66;">=</span> <span style="color: #ff0000;">&quot;&amp;lt;&quot;</span>,
         <span style="color: #66cc66;">&#91;</span><span style="color: #ff0000;">&quot;&gt;&quot;</span><span style="color: #66cc66;">&#93;</span> <span style="color: #66cc66;">=</span> <span style="color: #ff0000;">&quot;&amp;gt;&quot;</span>,
         <span style="color: #66cc66;">&#91;</span><span style="color: #ff0000;">&quot;&amp;&amp;&quot;</span><span style="color: #66cc66;">&#93;</span> <span style="color: #66cc66;">=</span> <span style="color: #ff0000;">&quot;&amp;amp;&quot;</span>,
                      <span style="color: #66cc66;">&#125;</span>
       <span style="color: #b1b100;">local</span> catchall <span style="color: #66cc66;">=</span> <span style="color: #ff0000;">&quot;(.)&quot;</span>
       <span style="color: #b1b100;">local</span> entify <span style="color: #66cc66;">=</span> <span style="color: #b1b100;">function</span> <span style="color: #66cc66;">&#40;</span>c<span style="color: #66cc66;">&#41;</span>
                      <span style="color: #b1b100;">local</span> n,fmts <span style="color: #66cc66;">=</span> c:byte<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>,<span style="color: #ff0000;">&quot;&amp;#%s;&quot;</span>
                      <span style="color: #b1b100;">return</span> <span style="color: #66cc66;">&#40;</span>n <span style="color: #66cc66;">&gt;</span> <span style="color: #cc66cc;">127</span><span style="color: #66cc66;">&#41;</span> <span style="color: #b1b100;">and</span> fmts:<span style="color: #b1b100;">format</span><span style="color: #66cc66;">&#40;</span>n<span style="color: #66cc66;">&#41;</span> <span style="color: #b1b100;">or</span> c
                      <span style="color: #b1b100;">end</span> <span style="color: #808080; font-style: italic;">-- function</span>
&nbsp;
       TEXT <span style="color: #66cc66;">=</span> <span style="color: #b1b100;">function</span><span style="color: #66cc66;">&#40;</span>rope<span style="color: #66cc66;">&#41;</span>
              <span style="color: #b1b100;">local</span> o <span style="color: #66cc66;">=</span> <span style="color: #66cc66;">&#123;</span><span style="color: #66cc66;">&#125;</span>
              <span style="color: #b1b100;">local</span> f <span style="color: #66cc66;">=</span> <span style="color: #b1b100;">function</span><span style="color: #66cc66;">&#40;</span>s<span style="color: #66cc66;">&#41;</span>
                  <span style="color: #b1b100;">local</span> status <span style="color: #66cc66;">=</span> <span style="color: #b1b100;">type</span><span style="color: #66cc66;">&#40;</span>s<span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">==</span> <span style="color: #ff0000;">&quot;string&quot;</span>
                  <span style="color: #b1b100;">if</span> status <span style="color: #b1b100;">then</span>
                    <span style="color: #b1b100;">for</span> symb,ent <span style="color: #b1b100;">in</span> <span style="color: #b1b100;">pairs</span><span style="color: #66cc66;">&#40;</span>entity<span style="color: #66cc66;">&#41;</span> <span style="color: #b1b100;">do</span>
                      s <span style="color: #66cc66;">=</span> s:<span style="color: #b1b100;">gsub</span><span style="color: #66cc66;">&#40;</span>symb,ent<span style="color: #66cc66;">&#41;</span>
                    <span style="color: #b1b100;">end</span> <span style="color: #808080; font-style: italic;">-- for</span>
                    s <span style="color: #66cc66;">=</span> s:<span style="color: #b1b100;">gsub</span><span style="color: #66cc66;">&#40;</span>catchall,entify<span style="color: #66cc66;">&#41;</span>
                    o<span style="color: #66cc66;">&#91;</span><span style="color: #cc66cc;">1</span>+#o<span style="color: #66cc66;">&#93;</span> <span style="color: #66cc66;">=</span> s
                  <span style="color: #b1b100;">end</span> <span style="color: #808080; font-style: italic;">-- if</span>
                   <span style="color: #b1b100;">return</span> status
                 <span style="color: #b1b100;">end</span> <span style="color: #808080; font-style: italic;">-- function</span>
              walk<span style="color: #66cc66;">&#40;</span>rope,f<span style="color: #66cc66;">&#41;</span>
              <span style="color: #b1b100;">return</span> o
              <span style="color: #b1b100;">end</span> <span style="color: #808080; font-style: italic;">-- function</span>
&nbsp;
       SPACE <span style="color: #66cc66;">=</span> <span style="color: #b1b100;">function</span><span style="color: #66cc66;">&#40;</span>n<span style="color: #66cc66;">&#41;</span>
               <span style="color: #b1b100;">assert</span><span style="color: #66cc66;">&#40;</span><span style="color: #b1b100;">type</span><span style="color: #66cc66;">&#40;</span>n<span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">==</span> <span style="color: #ff0000;">&quot;number&quot;</span>,<span style="color: #ff0000;">&quot;SPACE takes a number&quot;</span><span style="color: #66cc66;">&#41;</span>
               <span style="color: #b1b100;">local</span> s <span style="color: #66cc66;">=</span> <span style="color: #ff0000;">&quot;&amp;nbsp;&quot;</span>
               <span style="color: #b1b100;">return</span> s:rep<span style="color: #66cc66;">&#40;</span>n<span style="color: #66cc66;">&#41;</span>
               <span style="color: #b1b100;">end</span> <span style="color: #808080; font-style: italic;">-- function</span>
&nbsp;
       REM <span style="color: #66cc66;">=</span> <span style="color: #b1b100;">function</span><span style="color: #66cc66;">&#40;</span>s<span style="color: #66cc66;">&#41;</span> <span style="color: #b1b100;">return</span> <span style="color: #66cc66;">&#123;</span> <span style="color: #ff0000;">&quot;<span style="color: #000099; font-weight: bold;">\n</span>&lt;!-- &quot;</span><span style="color: #66cc66;">;</span>s<span style="color: #66cc66;">;</span><span style="color: #ff0000;">&quot; --&gt;<span style="color: #000099; font-weight: bold;">\n</span>&quot;</span><span style="color: #66cc66;">;</span> <span style="color: #66cc66;">&#125;</span> <span style="color: #b1b100;">end</span> <span style="color: #808080; font-style: italic;">-- function</span>
       link <span style="color: #66cc66;">=</span> <span style="color: #b1b100;">function</span><span style="color: #66cc66;">&#40;</span>url<span style="color: #66cc66;">&#41;</span> <span style="color: #b1b100;">return</span> TAG.a <span style="color: #66cc66;">&#123;</span> <span style="color: #ff0000;">'href=&quot;'</span><span style="color: #66cc66;">;</span> url<span style="color: #66cc66;">;</span> <span style="color: #ff0000;">'&quot;'</span><span style="color: #66cc66;">;</span> <span style="color: #66cc66;">&#125;</span> <span style="color: #b1b100;">end</span> <span style="color: #808080; font-style: italic;">-- function</span></pre></div></div>

]]></content:encoded>
			<wfw:commentRss>http://luanova.org/imperialguardian/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
	</channel>
</rss>
