-
-
Notifications
You must be signed in to change notification settings - Fork 224
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
Parsing only <option selected> from a <select> list. #244
Comments
I'd suggest to create a custom formatter for Start from this Readme section. Of built-in formatters, list and table formatters handle all the children tags on their own, although they are a lot more complex than the formatter for I haven't implemented formatters for form tags myself yet because it seems rather rare use-case for |
Alternatively, you can skip all There is no {
selectors: [
{ selector: 'option', format: 'skip' },
{ selector: 'option[selected]', format: 'inline' }
]
} |
Excellent! Thanks, I’ll give this a go on Monday. |
The goal
My HTML contains
<select>
form controls. The parser extracts the text for every<option>
in the menu. I want it to only extract the control as it's displayed - i.e. the<option selected>
Is there a configuration option that supports this? I can't find one on the docs.
Example:
Currently this outputs as:
Desired output
Best attempt
I can try to preprocess the HTML in a DOM parser to remove the other options from the menu prior to handing it to
html-to-text
The text was updated successfully, but these errors were encountered: