simonw / strip-tags

CLI tool for stripping tags from HTML
Apache License 2.0
209 stars 6 forks source link

Function as a Library #9

Closed benjamin-kirkbride closed 1 year ago

benjamin-kirkbride commented 1 year ago

I am working on a small modification to make this tool work as a library, instead of exclusively as a CLI tool.

I will submit a PR when I'm done, but if you are uninterested in this being included I understand :)

simonw commented 1 year ago

Weirdly enough I was just thinking about this today. I'm making some other changes which might break your refactor, but yes I think it's something this tool should offer.

simonw commented 1 year ago

After playing around with this a bit I'm going to make some small changes.

Right now the function signature is:

def strip_tags(selectors, input, minify=False):

I'm going to change that to:

def strip_tags(
    input: str, selectors: Optional[List[str]] = None, *, minify: bool = False
) -> str:
simonw commented 1 year ago

Now documented here: https://github.com/simonw/strip-tags/blob/696be170f8f0d0b6cbb277f81cdce07672285ca8/README.md#as-a-python-library