1
0
Fork
You've already forked gumbo-parser
0
An HTML5 parsing library in pure C99
  • HTML 56.9%
  • C 33.7%
  • C++ 4.1%
  • Ragel 3.8%
  • Python 1.3%
  • Other 0.1%
Find a file
2025年01月04日 00:31:16 +03:00
benchmarks Add baidu benchmark which has been left out of the git repository all this time. 2015年02月18日 00:24:35 -08:00
doc bump version number of supported gtest to 1.15.2 2024年11月01日 02:41:18 +03:00
examples Recognize templates in serialize and prettyprint 2015年02月17日 15:50:40 +01:00
python/gumbo make EnumMetaclass compatible with Python 3.13 2024年12月15日 22:12:08 +03:00
src fix incorrect doctype matching 2025年01月04日 00:11:51 +03:00
testdata @a9f44960a9 fix incorrect doctype matching 2025年01月04日 00:11:51 +03:00
tests fix incorrect doctype matching 2025年01月04日 00:11:51 +03:00
visualc/include return visualc/include/strings.h file 2023年09月24日 20:01:09 +03:00
.clang-format Reformat the source code with clang-format, and add a config file for formatting preferences. 2015年04月30日 17:35:26 -04:00
.gitignore make tests work with latest gtest 2023年09月25日 19:43:31 +03:00
.gitmodules drop gyp build system support 2023年09月25日 19:57:16 +03:00
autogen.sh add optional arguments to subcommands of autogen.sh script 2024年11月01日 02:39:50 +03:00
CHANGES.md set version to 0.13.0 2025年01月04日 00:31:16 +03:00
configure.ac set version to 0.13.0 2025年01月04日 00:31:16 +03:00
Doxyfile set version to 0.13.0 2025年01月04日 00:31:16 +03:00
genperf.py add support for search tag 2024年11月10日 05:13:28 +03:00
gentags.py Update gen_tags.py to exempt generated files from clang-format, and regen the tag lists. 2015年04月30日 17:28:48 -04:00
gumbo.pc.in Initial commit. 2013年08月09日 11:25:49 -07:00
Makefile.am make tests work with latest gtest 2023年09月25日 19:43:31 +03:00
README.md add package availability section to README.md 2024年11月09日 20:10:24 +03:00
setup.py set version to 0.13.0 2025年01月04日 00:31:16 +03:00

Gumbo - A pure-C HTML5 parser

Gumbo is an implementation of the HTML5 parsing algorithm implemented as a pure C99 library with no outside dependencies. It's designed to serve as a building block for other tools and libraries such as linters, validators, templating languages, and refactoring and analysis tools. This repository is a fork of original GitHub repository which has been archived by the owner on Feb 16, 2023 and is no longer maintained.

Goals & features:

  • Fully conformant with the HTML5 spec.
  • Robust and resilient to bad input.
  • Simple API that can be easily wrapped by other languages.
  • Support for source locations and pointers back to the original text.
  • Support for fragment parsing.
  • Relatively lightweight, with no outside dependencies.
  • Passes all html5lib tests, including the template tag.
  • Tested on over 2.5 billion pages from Google's index.

Non-goals:

  • Execution speed. Gumbo gains some of this by virtue of being written in C, but it is not an important consideration for the intended use-case, and was not a major design factor.
  • Support for encodings other than UTF-8. For the most part, client code can convert the input stream to UTF-8 text using another library before processing.
  • Mutability. Gumbo is intentionally designed to turn an HTML document into a parse tree, and free that parse tree all at once. It's not designed to persistently store nodes or subtrees outside of the parse tree, or to perform arbitrary DOM mutations within your program. If you need this functionality, we recommend translating the Gumbo parse tree into a mutable DOM representation more suited for the particular needs of your program before operating on it.

Wishlist (aka "We couldn't get these into the original release, but are hoping to add them soon"):

  • Full-featured error reporting.
  • Additional performance improvements.
  • DOM wrapper library/libraries (possibly within other language bindings)
  • Query libraries, to extract information from parse trees using CSS or XPATH.

Basic usage

#include <gumbo.h>
int main() {
 GumboOutput* output = gumbo_parse("<h1>Hello, World!</h1>");
 // Do stuff with output->root
 gumbo_destroy_output(&kGumboDefaultOptions, output);
}

There are a number of sample programs in the examples directory. They're built automatically by make, but can also be made individually with make <programname> (eg. make clean_text). Also don't forget to check out API documentation.

Learning more

Package availability

Packaging status

A note on API/ABI compatibility

We'll make a best effort to preserve API compatibility between releases. The initial release is a 0.9 (beta) release to solicit comments from early adopters, but if no major problems are found with the API, a 1.0 release will follow shortly, and the API of that should be considered stable. If changes are necessary, we follow semantic versioning.

We make no such guarantees about the ABI, and it's very likely that subsequent versions may require a recompile of client code. For this reason, we recommend NOT using Gumbo data structures throughout a program, and instead limiting them to a translation layer that picks out whatever data is needed from the parse tree and then converts that to persistent data structures more appropriate for the application. The API is structured to encourage this use, with a single delete function for the whole parse tree, and is not designed with mutation in mind.