Lua HTML5 parser and DOM API (mirrored from https://gitlab.com/craigbarnes/lua-gumbo)
Switch branches/tags
Clone or download
craigbarnes Add workaround for LuaRocks misfeature
Changing the semantics of commands based on filesystem permissions is
truly idiotic.
Latest commit 19937b8 Sep 10, 2018
Permalink
Failed to load latest commit information.
docs Add documentation for some DOM Element properties Jul 20, 2018
examples Clean up table_align_fix example and rewrite to use Node:walk() Aug 16, 2017
gumbo Use Node.nodeType instead of Node.type in innerHTML/outerHTML helper Jul 31, 2018
lib Remove trailing semicolon from GUMBO_VECTOR_INIT macro Sep 9, 2018
mk Optimize parser code Sep 4, 2018
test Move GitLab CI config to default location Sep 10, 2018
.distinfo Add .distinfo file Mar 24, 2017
.editorconfig Update .editorconfig and .gitattributes May 13, 2018
.gitattributes Move GitLab CI config to default location Sep 10, 2018
.gitignore Improve error message given by gumbo.parseFile() for invalid arg type Jun 20, 2018
.gitlab-ci.yml Add workaround for LuaRocks misfeature Sep 10, 2018
.luacheckrc Add "include_files" table to .luacheckrc Jul 26, 2017
.luacov Remove "deletestats = true" from luacov configuration Dec 3, 2015
.travis.yml Disallow CMake build on Unix unless -DALLOW_ANY_OS=1 is used Sep 4, 2018
CMakeLists.txt Disallow CMake build on Unix unless -DALLOW_ANY_OS=1 is used Sep 4, 2018
GNUmakefile Add "make vars" target to print basic system info and use on GitLab CI Jul 15, 2018
LICENSE Switch to the Apache 2.0 license Sep 29, 2017
README.md Update note in README.md regarding support for Windows Jul 31, 2018
appveyor.yml Use CMake "Debug" build type when running on Appveyor Jul 13, 2018
gumbo.lua Don't call assert() on metatable fields in unpackMetatables() Jul 31, 2018
makefile Clear default .SUFFIXES list in proxy makefile May 9, 2017
rockspec.in Fix previous commit May 2, 2018
runtests.lua Add some tests for parser edge cases Aug 23, 2018

README.md

Synopsis

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.

Requirements

Installation

To install the latest release via LuaRocks, first ensure the requirements listed above are installed, then use the command:

luarocks install gumbo

Note: The 0.4 release only supports Unix-like systems. However, the current git master branch has support for Windows (via CMake), which will be available in the next release.

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.

For full API documentation, see: https://craigbarnes.gitlab.io/lua-gumbo/.

Example

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.

local gumbo = require "gumbo"
local document = gumbo.parse('<div id="foo">Hello World</div>')
local foo = document:getElementById("foo")
local text = foo.childNodes[1].data
print(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.

See also: https://craigbarnes.gitlab.io/lua-gumbo/#examples.