GumboOptions(3)

πŸ“¦
version 0.12.1 Β· 4 versions
, in fedora 43

πŸ’– 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 allocator
  • GumboDeallocatorFunction deallocator
  • void * userdata
  • int tab_stop
  • bool stop_on_first_error
  • int max_errors
  • GumboTag fragment_context
  • GumboNamespaceEnum 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