You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
lua-gumbo is a HTML5 parser and DOM library for Lua. It
originally started out as a set of Lua bindings for the Gumbo C
library, but has now absorbed an improved fork of it.
To install the latest release via LuaRocks use the command:
luarocks install gumbo
Usage
The gumbo module provides a parse function and a parseFile
function, which both return a Document node containing a tree of
descendant nodes. The structure and API of this tree mostly follows
the DOM Level 4 Core specification.
The following is a simple demonstration of how to find an element by ID
and print the contents of it's first child text node.
localgumbo=require"gumbo"localdocument=gumbo.parse('<div id="foo">Hello World</div>')
localfoo=document:getElementById("foo")
localtext=foo.childNodes[1].dataprint(text) --> Hello World
Note: this example omits error handling for the sake of simplicity.
Production code should wrap each step with assert() or some other,
application-specific error handling.