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

Can support css rules? #143

Open
eromoe opened this issue Sep 22, 2017 · 1 comment
Open

Can support css rules? #143

eromoe opened this issue Sep 22, 2017 · 1 comment

Comments

@eromoe
Copy link

eromoe commented Sep 22, 2017

Hi,

I mean some site has their rule such as make a block , in this case, need a \n in text.

For example:

<div>
    <p styles="display:inline">
        inline 1  (no \n)
    </p>
    <p styles="display:inline">
        inline 2 (no \n)
    </p>
    <p >
        <a styles="display:block"> block 1(need add \n after) </a>
        block 2(need add \n after)   
    </p>
</div>

But styles always not write with element, usually in css, it would be nice to load several .css files to precisely convert html to text.

@KillyMXI
Copy link
Member

KillyMXI commented Jun 9, 2021

Version 8 is now live.
It add a pretty good selectors support that allows to match on style attribute as well:

{
  selectors: [
    { selector: 'p[style*="display:inline"i]', format: 'inline' },
    { selector: 'a[style*="display:block"i]', format: 'block' }
    // might need a custom formatter in case a.href etc is needed
  ]
}

At this point it seems unlikely html-to-text will go as far as doing full cascade style sheets though.
HTML CSS is not really useful for text rendering in the most part - plain text medium is way too different.

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

No branches or pull requests

2 participants