Coder Social home page Coder Social logo

Comments (7)

hipstermojo avatar hipstermojo commented on June 5, 2024

Hi @plata. Unfortunately, the way Paperoni is currently organized, it can't be exported even as a Rust library crate. But I have plans to make some parts available as libraries.
I also haven't worked with the parts of allowing for FFI bindings so that it can be called from C/C++ or any other language for that matter.
Which parts had you wanted to access as a library?

from paperoni.

plata avatar plata commented on June 5, 2024

My use case would be to call paperoni with the URL (or HTML + URL) and get back the "cleaned" HTML.

So something like: std::string paperoni(const std::string& url)

from paperoni.

hipstermojo avatar hipstermojo commented on June 5, 2024

Alright. Well that could be doable without needing to make FFI bindings.
You could instead call paperoni in a shell in C/C++ (I don't know the exact term used to refer to shelling out in C/C++) and then read the value returned from stdout back into a string in your C/C++. This assumes that you want to use paperoni in a context that permits shelling out.

NOTE: Getting content from stdout isn't actually supported yet so this is just a hypothetical solution.

Would that work for you?

from paperoni.

plata avatar plata commented on June 5, 2024

I fear it won't work. It shall also work on Android and my current knowledge is that starting a subprocess there is an issue. However, my Android knowledge is limited so this might be wrong.

from paperoni.

hipstermojo avatar hipstermojo commented on June 5, 2024

If it's going to be on Android then it certainly won't work with that approach.
If all you needed was to pass in some HTML and get back some HTML containing only the article, then you only need the readability portion of paperoni which is actually based on the Mozilla library. There's many existing ports to other languages, for example in Android you can use Kotlin libs like Readabilty4J and crux. I've not tried them but they seem to do just the same thing.

There's also this arc90 readability C++ port which isn't exactly the same as the Mozilla one but should be sufficient for your needs.

from paperoni.

plata avatar plata commented on June 5, 2024

I'm aware about the Kotlin implementations and yes, I could probably use that as a service on Android. However, I would prefer a solution which works for Linux/Windows as well.

Which C++ port are you referring to? rdrview? I've tried that, it's only an executable.

Don't get me wrong, I'm not asking you to solve my problems. Feel free to close the issue if paperoni as library doesn't fit into your plans.

from paperoni.

hipstermojo avatar hipstermojo commented on June 5, 2024

Making the readability portion of paperoni an independent library is definitely something I had planned for but having FFI bindings for C/C++ is definitely out of its scope. I hope you get a solution for your needs though.
If and when I do make it a library crate, I might reopen this issue but don't hold your breath for that.

from paperoni.

Related Issues (9)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.