Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Expose Gumbo initialization options, output status #2

Merged
merged 1 commit into from Jan 31, 2024
Merged

Expose Gumbo initialization options, output status #2

merged 1 commit into from Jan 31, 2024

Conversation

macdrevx
Copy link
Collaborator

@macdrevx macdrevx commented Jan 31, 2024

Allows configuring options like max_tree_depth and checking to see whether the parse was successful.

Comment on lines -17 to +26
let outputResult = withUnsafePointer(to: kGumboDefaultOptions) { (optionsPointer) -> Result<UnsafeMutablePointer<GumboOutput>, Never> in
.success(gumbo_parse_with_options(optionsPointer, htmlBuffer, htmlBuffer.count))
let outputResult = withUnsafePointer(to: options) { (optionsPointer) -> UnsafeMutablePointer<GumboOutput> in
gumbo_parse_with_options(optionsPointer, htmlBuffer, htmlBuffer.count)
}

self.htmlBuffer = htmlBuffer

// Safe to force try here since the outputResult only returns success.
self.gumboOutput = try! outputResult.get()
self.gumboOutput = outputResult
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@gshahbazian wrapping with Result seemed unnecessary here, but happy to revert that change if there's a good reason for it.

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I can't see any either

@macdrevx macdrevx changed the title Expose Gumbo initialization options Expose Gumbo initialization options, output status Jan 31, 2024
Copy link
Owner

@gshahbazian gshahbazian left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Woo!

@macdrevx macdrevx merged commit 1055af6 into gshahbazian:master Jan 31, 2024
1 check passed
@macdrevx macdrevx deleted the expose-options branch January 31, 2024 21:36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants