diff src/bbcode/test.js.luan @ 44:96f0c3d65698

add /bbcode
author Franklin Schmidt <fschmidt@gmail.com>
date Thu, 10 Nov 2022 23:18:58 -0700
parents
children
line wrap: on
line diff
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/bbcode/test.js.luan	Thu Nov 10 23:18:58 2022 -0700
@@ -0,0 +1,19 @@
+local Luan = require "luan:Luan.luan"
+local error = Luan.error
+local Parsers = require "luan:Parsers.luan"
+local json_string = Parsers.json_string or error()
+local Io = require "luan:Io.luan"
+local output_of = Io.output_of or error()
+local Http = require "luan:http/Http.luan"
+local Bbcode = require "site:/bbcode/Bbcode.luan"
+local bbcode_to_html = Bbcode.to_html or error()
+
+
+return function()
+	local text = Http.request.parameters.text or error()
+	local html = output_of(function() bbcode_to_html(text) end)
+	Io.stdout = Http.response.text_writer()
+%>
+	document.querySelector('p[result]').innerHTML = <%= json_string(html) %>;
+<%
+end