Skip to content

Style tags within SVG are treated as text #233

@craigchiang

Description

@craigchiang

Hi, I was testing the extractor with the below code, and it seems like it's extracting the style tag as text instead of treating it as css feature.

fn main() {
    let string = r##"
    <html lang="en">
        <svg class="wds-icon" viewBox="0 0 233 315.24" xmlns="http://www.w3.org/2000/svg">
            <defs>
                <style>.cls-1{fill:#cb0054;}</style>
            </defs>
            <g transform="translate(-83.5,-42.38)">
                <rect class="cls-1" x="153.84" y="204.81" width="13.71" height="13.71"/>
            </g>
        </svg>
    </html>"##;
    let text = html2text::config::with_decorator(TrivialDecorator::new())
        .string_from_read(string.as_bytes(), usize::MAX).unwrap();
    println!("Extracted text: {}", text); //Extracted text: .cls-1{fill:#cb0054;}
}

Is there anything I could do to disable this behavior?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions