Mercurial Hosting > luan
comparison website/src/manual.html.luan @ 1929:31f006c64782
translation
author | Franklin Schmidt <fschmidt@gmail.com> |
---|---|
date | Thu, 01 May 2025 18:31:05 -0600 |
parents | 4206242c7a13 |
children |
comparison
equal
deleted
inserted
replaced
1928:e16f38f4fdfc | 1929:31f006c64782 |
---|---|
1 local Luan = require "luan:Luan.luan" | 1 local Luan = require "luan:Luan.luan" |
2 local error = Luan.error | 2 local error = Luan.error |
3 local pairs = Luan.pairs or error() | |
4 local String = require "luan:String.luan" | |
5 local replace = String.replace or error() | |
6 local Table = require "luan:Table.luan" | |
7 local concat = Table.concat or error() | |
3 local Io = require "luan:Io.luan" | 8 local Io = require "luan:Io.luan" |
4 local Http = require "luan:http/Http.luan" | 9 local Site_translator = require "luan:gpt/Site_translator.luan" |
10 local get_lang = Site_translator.get_lang or error() | |
11 local text_writer = Site_translator.text_writer or error() | |
12 local languages = Site_translator.languages or error() | |
13 local set_translated = Site_translator.set_translated or error() | |
5 local Shared = require "site:/lib/Shared.luan" | 14 local Shared = require "site:/lib/Shared.luan" |
6 local head = Shared.head or error() | 15 local head = Shared.head or error() |
7 local docs_header = Shared.docs_header or error() | 16 local docs_header = Shared.docs_header or error() |
8 local show_toc = Shared.show_toc or error() | 17 local show_toc = Shared.show_toc or error() |
9 local show_content = Shared.show_content or error() | 18 local show_content = Shared.show_content or error() |
19 local show_content_info = Shared.show_content_info or error() | |
20 local Translator = require "luan:gpt/Translator.luan" | |
21 local translate_html = Translator.translate_html or error() | |
22 local Logging = require "luan:logging/Logging.luan" | |
23 local logger = Logging.logger "manual.html" | |
10 | 24 |
11 | 25 |
12 local content = { | 26 local content = { |
13 intro = { | 27 intro = { |
14 title = "Introduction" | 28 title = "Introduction" |
159 env = { | 173 env = { |
160 title = "Environments" | 174 title = "Environments" |
161 content = function() | 175 content = function() |
162 %> | 176 %> |
163 <p> | 177 <p> |
164 The environment of a chunk starts with only one local variable: <code><a href="#require">require</a></code>. This function is used to load and access libraries and other modules. All other variables must be added to the environment using <a href="/manual.html#local_stmt">local declarations</a>. | 178 The environment of a chunk starts with only one local variable: <code><a href="#require">require</a></code>. This function is used to load and access libraries and other modules. All other variables must be added to the environment using <a href="manual.html#local_stmt">local declarations</a>. |
165 </p> | 179 </p> |
166 | 180 |
167 <p> | 181 <p> |
168 As will be discussed in <a href="#vars">Variables</a> and <a href=#assignment">Assignment</a>, | 182 As will be discussed in <a href="#vars">Variables</a> and <a href=#assignment">Assignment</a>, |
169 any reference to a free name | 183 any reference to a free name |
2540 %> | 2554 %> |
2541 <p>Returns a hex digest string of <code>s</code>. Could be defined as:</p> | 2555 <p>Returns a hex digest string of <code>s</code>. Could be defined as:</p> |
2542 | 2556 |
2543 <code block> | 2557 <code block> |
2544 function String.digest_message(algorithm,s) | 2558 function String.digest_message(algorithm,s) |
2545 return <a href="/manual.html#Binary.to_hex">Binary.to_hex</a>( <a href="/manual.html#Binary.digest_message">Binary.digest_message</a>( algorithm, <a href="/manual.html#String.to_binary">String.to_binary(s)</a> ) ) | 2559 return <a href="manual.html#Binary.to_hex">Binary.to_hex</a>( <a href="manual.html#Binary.digest_message">Binary.digest_message</a>( algorithm, <a href="manual.html#String.to_binary">String.to_binary(s)</a> ) ) |
2546 end | 2560 end |
2547 </code> | 2561 </code> |
2548 <% | 2562 <% |
2549 end | 2563 end |
2550 } | 2564 } |
3671 } | 3685 } |
3672 } | 3686 } |
3673 | 3687 |
3674 | 3688 |
3675 return function() | 3689 return function() |
3676 Io.stdout = Http.response.text_writer() | 3690 local lang = get_lang() |
3691 local html = ` | |
3677 %> | 3692 %> |
3678 <!doctype html> | 3693 <!doctype html> |
3679 <html> | 3694 <html lang="<%=lang%>"> |
3680 <head> | 3695 <head> |
3681 <% head() %> | 3696 <% head() %> |
3682 <title>Luan Reference Manual</title> | 3697 <title>Luan Reference Manual</title> |
3683 <style> | 3698 <style> |
3684 p[list] { | 3699 p[list] { |
3719 <h2>Contents</h2> | 3734 <h2>Contents</h2> |
3720 <div toc> | 3735 <div toc> |
3721 <% show_toc(content) %> | 3736 <% show_toc(content) %> |
3722 </div> | 3737 </div> |
3723 <hr> | 3738 <hr> |
3724 <% show_content(content,2) %> | 3739 <div placeholder></div> |
3725 </div> | 3740 </div> |
3726 </body> | 3741 </body> |
3727 </html> | 3742 </html> |
3728 <% | 3743 <% |
3744 ` | |
3745 if lang == "en" then | |
3746 html = replace( html, "<div placeholder></div>", `show_content(content,2)` ) | |
3747 else | |
3748 local language = languages[lang] or error(lang) | |
3749 html = translate_html(html,language) | |
3750 local parts = {} | |
3751 for id, info in pairs(content) do | |
3752 local part = `show_content_info(id,info,2)` | |
3753 part = translate_html(part,language) | |
3754 parts[#parts+1] = part | |
3755 end | |
3756 html = replace( html, "<div placeholder></div>", concat(parts) ) | |
3757 set_translated() | |
3758 end | |
3759 text_writer().write(html) | |
3729 end | 3760 end |