Go to file
renovate 39d261c5f3
All checks were successful
ci/woodpecker/push/woodpecker Pipeline was successful
ci/woodpecker/cron/woodpecker Pipeline was successful
fix(deps): update rust crate itertools to 0.13.0 (#42)
This PR contains the following updates:

| Package | Type | Update | Change |
| [itertools](https://github.com/rust-itertools/itertools) | dependencies | minor | `0.12.1` -> `0.13.0` |

>  **Important**
> Release Notes retrieval for this PR were skipped because no github.com credentials were available.
> If you are self-hosted, please see [this instruction](https://github.com/renovatebot/renovate/blob/master/docs/usage/examples/self-hosting.md#githubcom-token-for-release-notes).


### Configuration

📅 **Schedule**: Branch creation - At any time (no schedule defined), Automerge - At any time (no schedule defined).

🚦 **Automerge**: Disabled by config. Please merge this manually once you are satisfied.

♻ **Rebasing**: Whenever PR becomes conflicted, or you tick the rebase/retry checkbox.

🔕 **Ignore**: Close this PR and you won't be reminded about this update again.


 - [ ] <!-- rebase-check -->If you want to rebase/retry this PR, check this box


This PR has been generated by [Renovate Bot](https://github.com/renovatebot/renovate).

Co-authored-by: Renovate Bot <renovate@kemitix.net>
Reviewed-on: #42
Co-authored-by: renovate <renovate@noreply.kemitix.net>
Co-committed-by: renovate <renovate@noreply.kemitix.net>
2024-05-17 08:42:26 +01:00
src fix(deps): update rust crate indicatif to 0.17.8 (#24) 2024-03-27 10:50:18 +00:00
test_html Add moz_readability initial code and accompanying unit tests 2020-08-31 19:30:09 +03:00
.gitignore feat: add HTML exports with inlining of images 2021-07-24 12:08:18 +03:00
.woodpecker.yml chore: enable building with latest version of rust (#14) 2024-03-10 10:25:18 +00:00
Cargo.lock fix(deps): update rust crate itertools to 0.13.0 (#42) 2024-05-17 08:42:26 +01:00
Cargo.toml fix(deps): update rust crate itertools to 0.13.0 (#42) 2024-05-17 08:42:26 +01:00
LICENSE Initial commit 2020-04-30 08:06:07 +03:00
paperoni-dark.png Add README 2020-10-22 16:03:57 +03:00
README.md bump version 2021-08-24 07:40:05 +03:00
renovate.json chore(deps): prevent renovate from creating pointless PRs 2024-04-27 14:30:46 +01:00

Salami not included

Paperoni is a CLI tool made in Rust for downloading web articles as EPUB or HTML files. There is provisional* support for exporting to PDF as well.

This project is in an alpha release so it might crash when you use it. Please open an issue on Github if it does crash.


Precompiled binaries

Check the releases page for precompiled binaries. Currently there are only builds for Debian and Arch.

Installing from crates.io

Paperoni is published on crates.io. If you have cargo installed, then run:

cargo install paperoni --version 0.6.1-alpha1

Paperoni is still in alpha so the version flag has to be passed.

Building from source

This project uses async/.await so it should be compiled using a minimum Rust version of 1.33. Preferrably use the latest version of Rust.

git clone https://github.com/hipstermojo/paperoni.git
cd paperoni
## You can build and install paperoni locally
cargo install --path .
## or use it from within the project
cargo run -- # pass your url here


    paperoni [OPTIONS] [urls]...

        --export <type>
            Specify the file type of the export. The type must be in lower case. [default: epub]  [possible values:
            html, epub]
    -f, --file <file>
            Input file containing links

    -h, --help
            Prints help information

            Inlines the article images when exporting to HTML using base64.
            This is used when you do not want a separate folder created for images during HTML export.
            NOTE: It uses base64 encoding on the images which results in larger HTML export sizes as each image
            increases in size by about 25%-33%.
            Add an inlined Table of Contents page at the start of the merged article. This does not affect the Table of Contents navigation
            Enables logging of events to a file located in .paperoni/logs with a default log level of debug. Use -v to
            specify the logging level
        --max-conn <max-conn>
            The maximum number of concurrent HTTP connections when downloading articles. Default is 8.
            NOTE: It is advised to use as few connections as needed i.e between 1 and 50. Using more connections can end
            up overloading your network card with too many concurrent requests.
            Removes the stylesheets used in the EPUB generation.
            The EPUB file will then be laid out based on your e-reader's default stylesheets.
            Images and code blocks may overflow when this flag is set and layout of generated
            PDFs will be affected. Use --no-header-css if you want to only disable the styling on headers.
            Removes the header CSS styling but preserves styling of images and codeblocks. To remove all the default
            CSS, use --no-css instead.
        --merge <output-name>
            Merge multiple articles into a single epub that will be given the name provided

    -o, --output-dir <output_directory>
            Directory to store output epub documents

    -V, --version
            Prints version information

            This takes upto 4 levels of verbosity in the following order.
            - Error (-v)
            - Warn (-vv)
            - Info (-vvv)
            - Debug (-vvvv)
            When this flag is passed, it disables the progress bars and logs to stderr.
            If you would like to send the logs to a file (and enable progress bars), pass the log-to-file flag.

            Urls of web articles

To download a single article pass in its URL

paperoni https://en.wikipedia.org/wiki/Pepperoni

Paperoni also supports passing multiple links as arguments.

paperoni https://en.wikipedia.org/wiki/Pepperoni https://en.wikipedia.org/wiki/Salami

Alternatively, if you are on a Unix-like OS, you can simply do something like this:

cat links.txt | xargs paperoni

These can also be read from a file using the -f/--file flag.

paperoni -f links.txt

Exporting articles

By default, Paperoni exports to EPUB files but you can change to HTML by passing the --export html flag.

paperoni https://en.wikipedia.org/wiki/Pepperoni --export html

HTML exports allow you to read the articles as plain HTML documents on your browser but can also be used to convert to PDF as explained here.

When exporting to HTML, Paperoni will download the article's images to a folder named similar to the article. Therefore the folder structure would look like this for the command ran above:

├── Pepperoni - Wikipedia
│   ├── 1a9f886e9b58db72e0003a2cd52681d8.png
│   ├── 216f8a4265a1ceb3f8cfba4c2f9057b1.jpeg
│   ...
└── Pepperoni - Wikipedia.html

If you would instead prefer to have the images inlined directly to the HTML export, pass the inline-images flag, i.e.:

paperoni https://en.wikipedia.org/wiki/Pepperoni --export html --inline-images

This is especially useful when exporting multiple links.

NOTE: The inlining of images for HTML exports uses base64 encoding which is known to increase the overall size of images by about 25% to 33%.

Disabling CSS

The no-css and no-header-css flags can be used to remove the default styling added by Paperoni. Refer to --help to see the usage of the flags.

Merging articles

By default, Paperoni generates an epub file for each link. You can also merge multiple links into a single epub using the merge flag and specifying the output file.

paperoni -f links.txt --merge out.epub

Logging events

Logging is disabled by default. This can be activated by either using the -v flag or --log-to-file flag. If the --log-to-file flag is passed the logs are sent to a file in the default Paperoni directory .paperoni/logs which is on your home directory. The -v flag configures the verbosity levels such that:

-v Logs only the error level
-vv Logs only the warn level
-vvv Logs only the info level
-vvvv Logs only the debug level

If only the -v flag is passed, the progress bars are disabled. If both -v and --log-to-file are passed then the progress bars will still be shown.

How it works

The URL passed to Paperoni is fetched and the returned HTML response is passed to the extractor. This extractor retrieves a possible article using a custom port of the Mozilla Readability algorithm. This article is then saved in an EPUB.

The port of the algorithm is still unstable as well so it is not fully compatible with all the websites that can be extracted using Readability.

How it (currently) doesn't work

This program is still in alpha so a number of things won't work:

  • Websites that only run with JavaScript cannot be extracted.
  • Website articles that cannot be extracted by Readability cannot be extracted by Paperoni either.
  • Code snippets on Medium articles that are lazy loaded will not appear in the EPUB.

There are also web pages it won't work on in general such as Twitter and Reddit threads.

PDF exports

PDF conversion can be done using a third party tool. There are 2 options to do so:


This requires that you install Calibre which comes with a ebook conversion. You can convert the epub to a pdf through the terminal with ebook-convert:

# Assuming the downloaded epub was called foo.epub
ebook-convert foo.epub foo.pdf

Alternatively, you can use the Calibre GUI to do the file conversion.


The recommended approach is to use Weasyprint, a free and open-source tool that converts HTML documents to PDF. It is available on Linux, MacOS and Windows. Using the CLI, it can be done as follows:

paperoni https://en.wikipedia.org/wiki/Pepperoni --export html
weasyprint "Pepperoni - Wikipedia.html" Pepperoni.pdf

Inlining images is not mandatory as Weasyprint will be able to find the files on its own.

Comparison of PDF conversion methods

Either of the conversion methods is sufficient for most use cases. The main differences are listed below:

Wrapping code blocks Yes No
CSS customization No Yes
Generated file size Slightly larger Slightly smaller

The difference in file size is due to the additional fonts added to the PDF file by ebook-convert.