comparison website/src/manual.html.luan @ 1813:fa0e73119b7c

docs work
author Franklin Schmidt <fschmidt@gmail.com>
date Mon, 10 Jun 2024 23:19:40 -0600
parents f44dcb3fedf7
children e62c88b2883b
comparison
equal deleted inserted replaced
1812:f44dcb3fedf7 1813:fa0e73119b7c
1982 The basic library provides basic functions to Luan that don't depend on other libaries. 1982 The basic library provides basic functions to Luan that don't depend on other libaries.
1983 </p> 1983 </p>
1984 <% 1984 <%
1985 end 1985 end
1986 subs = { 1986 subs = {
1987 ["Luan.arg"] = {
1988 title = "Luan.arg"
1989 content = function()
1990 %>
1991 <p>If Luan was run from the command line then this is a list of the command line arguments. For example if one runs Luan like this:</p>
1992
1993 <code block>
1994 luan t.luan a b c
1995 </code>
1996
1997 <p>Then Luan.arg will contain:</p>
1998
1999 <code block>
2000 {
2001 [0] = "t.luan"
2002 [1] = "a"
2003 [2] = "b"
2004 [3] = "c"
2005 }
2006 </code>
2007
2008 <p>And of course <code>#Luan.arg</code> will be <code>3</code>.</p>
2009 <%
2010 end
2011 }
1987 ["Luan.do_file"] = { 2012 ["Luan.do_file"] = {
1988 title = "Luan.do_file ([uri])" 2013 title = "Luan.do_file ([uri])"
1989 content = function() 2014 content = function()
1990 %> 2015 %>
1991 <p> 2016 <p>
2175 </pre> 2200 </pre>
2176 2201
2177 <p> 2202 <p>
2178 will iterate over all key&ndash;value pairs of table <code>t</code>. 2203 will iterate over all key&ndash;value pairs of table <code>t</code>.
2179 </p> 2204 </p>
2205 <%
2206 end
2207 }
2208 ["Luan.parse"] = {
2209 title = "Luan.parse (s)"
2210 content = function()
2211 %>
2212 <p>This Luan's equivalent to Javascript's JSON.parse(), but for a Luan value. In addition to the usual JSON values, Luan.parse allows long strings and allows specifying numeric types of <i>double</i>, <i>float</i>, <i>integer</i>, and <i>long</i>. For example:</p>
2213
2214 <code block>
2215 local t = Luan.parse[=[
2216 {
2217 nothing = nil
2218 t = true
2219 f = false
2220 s = "string"
2221 ls = [[long string]]
2222 n = 3
2223 d = double(3)
2224 f = float(3)
2225 i = integer(3)
2226 l = long(3)
2227 list = { 1, 2, 3 }
2228 table = {
2229 one = 1
2230 two = 2
2231 three = 3
2232 }
2233 ["ugly-key"] = "something"
2234 }
2235 ]=]
2236 </code>
2180 <% 2237 <%
2181 end 2238 end
2182 } 2239 }
2183 ["Luan.range"] = { 2240 ["Luan.range"] = {
2184 title = "Luan.range (start, stop [, step])" 2241 title = "Luan.range (start, stop [, step])"
2289 ["Luan.stringify"] = { 2346 ["Luan.stringify"] = {
2290 title = "Luan.stringify (v [,options])" 2347 title = "Luan.stringify (v [,options])"
2291 content = function() 2348 content = function()
2292 %> 2349 %>
2293 <p> 2350 <p>
2294 Receives a value of any type and converts it to a string that is a Luan expression. <code>options</code> is a table. If <code>options.strict==true</code> then invalid types throw an error. Otherwise invalid types are represented but the resulting expression is invalid. If <code>options.number_types==true</code> then numbers will be wrapped in functions for their type. 2351 This Luan's equivalent to Javascript's JSON.stringify(), but for a Luan value.
2295 </p> 2352 <code>v</code> is a value of any type which is converted to a string that is a Luan expression. <code>options</code> may be a table or a function. If <code>options</code> is a table, it may contain the following flags whose <code>true</code> value means:
2353 </p>
2354
2355 <ul>
2356 <li><b>strict</b> - invalid types throw an error</li>
2357 <li><b>number_types</b> - numbers will be wrapped in functions for their type</li>
2358 <li><b>compressed</b> - eliminates white space</li>
2359 <li><b>inline</b> - on one line</li>
2360 <li><b>no_name_keys</b> - forces all keys to be of the form <code>["key"]</code></li>
2361 </ul>
2362
2363 <p>If <code>options</code> is a function then this function should take an argument <code>stack</code> and return an <code>options</code> table. The <code>stack</code> will be a list of keys indicating where stringify is currently processing. This allows different options to be applied at different places in a data structure.</p>
2296 <% 2364 <%
2297 end 2365 end
2298 } 2366 }
2299 ["Luan.to_string"] = { 2367 ["Luan.to_string"] = {
2300 title = "Luan.to_string (v)" 2368 title = "Luan.to_string (v)"