htmlEntities for Lua

June 22, 2019 · View on GitHub

Build Status Luarocks

HTML entities decoding/encoding

Written for Lua5.3 but working with lua5.x!

Features

  • Fast!
  • No dependencies!
  • Easy to implement!

Installation

Module available through the LuaRocks. It can be installed using the luarocks command line tools.

# LuaRocks
luarocks install html-entities

Example

htmlEntities = require('htmlEntities')
print(htmlEntities.name) -- htmlEntities-for-lua
print(htmlEntities.encode('Tiago Danin :)')) -- Tiago Danin :)
print(htmlEntities.decode('Tiago Danin :)')) -- Tiago Danin :)

Documentation

API

FunctionInfo
htmlEntitiesReturn table with information about module
htmlEntities.decode(input)Decode HTML entities
string:htmlDecode()Same as above
htmlEntities.encode(input)Encode in HTML entities (in ASCII) NOTE: Emoji is not supported here!
string:htmlEncode()Same as above
htmlEntities.ASCII_HEX(input)Decode ASCII HEX
htmlEntities.ASCII_DEC(input)Decode ASCII DEC

Module Options

StringDefaultInfo
error_msg_htmlEntitiesfalseView log of erros
debug_htmlEntitiesfalsePrint output
ASCII_htmlEntitiestrueDecode of entities in ASCII
register_global_module_htmlEntitiesfalseRegister module as global
global_module_name_htmlEntities"htmlEntities"Name in global mode

Tests

To run the test suite:

# Lua
lua tests/cli.lua
# Or
lua tests/travis.lua

Contributors

Pull requests and stars are always welcome. For bugs and feature requests, please create an issue. List of all contributors.

License

MIT © Tiago Danin