Skip to content

Latest commit

 

History

History
66 lines (45 loc) · 1.49 KB

README.md

File metadata and controls

66 lines (45 loc) · 1.49 KB

luabidi

Lua implementation of the Unicode Bidirectional Algorithm, as specified in UAX #9.

Installing

luarocks install luabidi

Documentation

Quickstart

local bidi = require('bidi')
local serpent  = require('serpent') -- luarocks install serpent

local text = {0x06CC, 0x06C1} -- "یہ" U+06CC U+06C1

local reordered_text = bidi.get_visual_reordering(text)

-- hex representation
for i,v in ipairs(reordered_text) do
  reordered_text[i] = string.format("U+%04X", v)
end

for i,v in ipairs(text) do
  text[i] = string.format("U+%04X", v)
end

print("Original codepoints (in logical order): " .. serpent.line(text,{comment = false}))
print("Visual reordering: " .. serpent.line(reordered_text,{comment = false})) -- should be { "U+06C1", "U+06CC"}

More sample code in the examples folder.

Development

Building

luarocks make

Testing and Linting

In order to make changes to the code and run the tests, the following dependencies need to be installed:

  • Bustedluarocks install busted
  • luacheckluarocks install luacheck

Run the test suite:

make spec

Lint the codebase:

make lint

Contact

Open a Github issue, or email me at [email protected].