mixmark-io / turndown

🛏 An HTML to Markdown converter written in JavaScript
https://mixmark-io.github.io/turndown
MIT License
8.62k stars 870 forks source link

filter supports selector #412

Open shtse8 opened 2 years ago

shtse8 commented 2 years ago

for now, we need to put a function to modify the rules.

service.remove( function (node, options) {
  return (
    options.linkStyle === 'inlined' &&
    node.nodeName === 'A' &&
    node.getAttribute('href')
  )
})

it's better to support selector in filter. so we can make it simplier

service.remove('a[href]')

which is equivalent to:

service.remove((node) => node.matches('a[href]'))