GumboOptions(3)
π NAME π
GumboOptions β bestie, this is the lil' config struct that tells the Gumbo parser how you want it to behave π
It's part of the Gumbo manual, section 3, and omg it's so much shorter than you think it is. Let's get into it β¨
πΈ SYNOPSIS πΈ
#include <gumbo.h>
π¦ Data Fields π¦
Okay so here's the whole cast of characters, no gatekeeping:
GumboAllocatorFunction allocatorGumboDeallocatorFunction deallocatorvoid * userdataint tab_stopbool stop_on_first_errorint max_errorsGumboTag fragment_contextGumboNamespaceEnum fragment_namespace
β¨ Detailed Description β¨
So GumboOptions is literally just an input struct holding configuration options for the parser π
Like, all the settings go in here. These options are what let you specify alternate memory managers, provide different error handling, etc. β all the little knobs and dials, yk?
Use kGumboDefaultOptions for sensible defaults, and only set what you need. That's it, that's the vibe. Don't be doing extra, bestie π
π Field Documentation π
π GumboAllocatorFunction GumboOptions::allocator
A memory allocator function.
Default: malloc.
π GumboDeallocatorFunction GumboOptions::deallocator
A memory deallocator function. (Yes, it's the matching counterpart, the allocator's other half, they're a package deal fr fr π«Ά)
Default: free.
π§ void* GumboOptions::userdata
An opaque object that's passed in as the first argument to all callbacks used by this library. Opaque meaning: Gumbo does not peek inside, it just hands it back to you, main character energy.
Default: NULL.
π int GumboOptions::tab_stop
The tab-stop size, for computing positions in source code that uses tabs. So like, if your source is tab-indented (no judgment, we've all been there), this is how wide a tab counts as when the parser is figuring out where things are.
Default: 8.
π bool GumboOptions::stop_on_first_error
Whether or not to stop parsing when the first error is encountered. Set it true if you want the parser to hit one bad thing and immediately be like "I'm out β".
Default: false.
π₯ int GumboOptions::max_errors
The maximum number of errors before the parser stops recording them. This is provided so that if the page is totally borked, we don't completely fill up the errors vector and exhaust memory with useless redundant errors. Honestly? Protective behavior. It's giving self-care.
Set to -1 to disable the limit.
Default: -1
π¦ GumboTag GumboOptions::fragment_context
The fragment context for parsing:
https://html.spec.whatwg.org/multipage/syntax.html#parsing-html-fragments
If GUMBO_TAG_LAST is passed here, it is assumed to be "no fragment", i.e. the regular parsing algorithm. Otherwise, pass the tag enum for the intended parent of the parsed fragment.
We use just the tag enum rather than a full node because that's enough to set all the parsing context we need, and it provides some additional flexibility for client code to act as if parsing a fragment even when a full HTML tree isn't available. Clever, right? Lowkey iconic.
Default: GUMBO_TAG_LAST
πΈ GumboNamespaceEnum GumboOptions::fragment_namespace
The namespace for the fragment context. This lets client code differentiate between, say, parsing a <title> tag in SVG vs. parsing it in HTML. Same tag, different universe, no cap π
Default: GUMBO_NAMESPACE_HTML
π Author π
Generated automatically by Doxygen for Gumbo from the source code. (Not a human, just a robot doing its lil' documentation thing π€β¨)
π That's the whole page bestie, you ate it. Now go forth and set only the options you actually need π«Ά
Version 0.12.1 Β· Fri Sep 19 2025 00:00:00 Β· GumboOptions(3) β mwah, catch you in the next manpage π
πβ
π¦ where this page comes from
- fedora 43: gumbo-parser-devel 1:0.12.1-7.fc43 Β· Apache-2.0
- fedora 43: gumbo-parser-devel 1:0.12.1-7.fc43 Β· Apache-2.0
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms