diff --git a/README.md b/README.md index 5b43f4d..8f51f97 100644 --- a/README.md +++ b/README.md @@ -31,6 +31,8 @@ A Minetest mod library to make modifying formspecs easier. - `formspec_ast.safe_parse(string_or_tree)`: Similar to `formspec_ast.parse`, however will delete any elements that may crash the client (or any I haven't added to the whitelist). + - `formspec_ast.formspec_escape(text)`: The same as `minetest.formspec_escape`, + should only be used when formspec_ast is being embedded outside of Minetest. ## AST diff --git a/init.lua b/init.lua index 1aa8b5b..abe568c 100644 --- a/init.lua +++ b/init.lua @@ -37,6 +37,7 @@ if minetest then modpath = minetest.get_modpath('formspec_ast') assert(minetest.get_current_modname() == 'formspec_ast', 'This mod must be called formspec_ast!') + formspec_ast.formspec_escape = minetest.formspec_escape else -- Probably running outside Minetest. modpath = rawget(_G, 'FORMSPEC_AST_PATH') or '.' @@ -67,6 +68,7 @@ else return res end formspec_ast.minetest = minetest + formspec_ast.formspec_escape = minetest.formspec_escape end formspec_ast.modpath = modpath @@ -76,4 +78,3 @@ dofile(modpath .. '/helpers.lua') dofile(modpath .. '/safety.lua') formspec_ast.modpath, formspec_ast.minetest = nil, nil -formspec_ast.formspec_escape = minetest.formspec_escape