Module pl.pretty

Pretty-printing Lua tables

Functions

dump (t, ..., file) dump a Lua table out to a file or stdout
read (s) read a string representation of a Lua table.
write (tbl, space, not_clever, a) create a string representation of a Lua table.


Functions

dump (t, ..., file)
dump a Lua table out to a file or stdout

Parameters:

  • t: a table
  • ...:
  • file: (optional) file name
read (s)
read a string representation of a Lua table. Uses loadstring, but tries to be cautious about loading arbitrary code! It is expecting a string of the form '{...}', with perhaps some whitespace before or after the curly braces. An empty environment is used, and any occurance of the keyword 'function' will be considered a problem.

Parameters:

  • s:
write (tbl, space, not_clever, a)
create a string representation of a Lua table.

Parameters:

  • tbl:
  • space: the indent to use (defaults to two spaces)
  • not_clever: (defaults to false) use for plain output, e.g {['key']=1}
  • a: table

Return value:

    a string

Valid XHTML 1.0!