Skip to content

Parsing only <option selected> from a <select> list. #244

Open
@thegoatherder

Description

@thegoatherder

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:

<div>You have selected:</div>
<select>
   <option>A</option>
   <option>B</option>
   <option selected>C</option>
</select>

Currently this outputs as:

You have selected: A B C

Desired output

You have selected: C

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions