User:Crowley666/Run locally
To run some scripts locally with Lua 5.4.3:
- Download files in proper directories:
- lua/
- ustring/
- libraryUtil.lua
- html.lua (name changed)
- th-pron.lua
- th-translit.lua
- lua/
- Change
local namespace = mw.title.getCurrentTitle().nsText
tolocal namespace = ""
, because mw.title is not supported. - Comment out every line with options in html.lua
- Enter commandline (eg. bash), change current working directory to lua/ (eg.
cd lua/
), runlua
- Run the following code:
unpack = unpack or table.unpack mw = { ustring = require("ustring/ustring"), html = require("html"), text = {} } tr = require('Module:th-translit').tr function mw.text.gsplit( text, pattern, plain ) local s, l = 1, mw.ustring.len( text ) return function () if s then local e, n = mw.ustring.find( text, pattern, s, plain ) local ret if not e then ret = mw.ustring.sub( text, s ) s = nil elseif n < e then -- Empty separator! ret = mw.ustring.sub( text, s, e ) if e < l then s = e + 1 else s = nil end else ret = e > s and mw.ustring.sub( text, s, e - 1 ) or '' s = n + 1 end return ret end end, nil, nil end
- Result:
tr("เฮิ็้ย") hə́i
- As a result, some functions in Module:th-pron are not supported.
- mwtext.JSON_PRESERVE_KEYS(1) will effect iff:
- '[]' table
- '{"0":?,"1":?,"2":?}' table, with 0...#t-1 all present.
- bliki: [1]