Skip to main content

Despoilerizer

This script reads from stdin and prints out the contents of stdin to stdout, without the lines that are in between the :SPOILERS BEGIN: and the :SPOILERS END: tags.

It uses stdin and stdout so that it can be easily integrated in bash scripting, for instance:

$ <my_file.tex | python -m despoilerizer | pdflatex

You can also redefine the tags:

$ <my_file.tex | \
  python -m despoilerizer --begin="# spoiler" --end="# unspoiler" | \
  pdflatex

Installation

$ pip install despoilerizer

Examples

stdin

This is a simple file.
:SPOILERS BEGIN:
It contains spoilers.
:SPOILERS END:
And also other information.

stdout

This is a simple file.
And also other information.

stdin

\begin{document}
% :SPOILERS BEGIN:
important stuff...
% :SPOILERS END:
\end{document}

stdout

\begin{document}
\end{document}

Usage as importable package

import despoilerizer
from pathlib import Path as P

for path in [P('file1.tex'), P('file2.py'), P('file3.txt')]:
    out_path = P(path.stem + '_nospoilers' + path.suffix)
    with open(path, 'r') as fin:
        with open(out_path, 'w') as fout:
            despoilerizer.despoilerize_file(fin, fout)


contents = """
This is a very important string.
such spoilers
I really don't want anyone to know.
much wow
"""

with open(P('some_file.txt'), 'w') as f:
    f.write(
        despoilerizer.despoilerize(contents, begin='such spoilers', end='much wow')
    )

Motivation

I have a LaTeX file for a document I'm sharing with my friends. This document contains some information for a DnD campaign both for stuff the players have encountered and stuff that's being worked on.

Therefore, I want to have two different PDF documents: one with the spoilers and one without them.

Metadata

Release files for despoilerizer 1.0.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for despoilerizer 1.0.1
File Size Uploaded Provenance Actions
despoilerizer-1.0.1.tar.gz 16.1 kB Without provenance Details for despoilerizer-1.0.1.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for despoilerizer 1.0.1
File Interpreter ABI Platform Actions
despoilerizer-1.0.1-py3-none-any.whl Python 3 none any Details for despoilerizer-1.0.1-py3-none-any.whl

Total release size: 34.1 kB

Release files / despoilerizer-1.0.1.tar.gz

Download URL despoilerizer-1.0.1.tar.gz
Size 16.1 kB
Tags Source
SHA-256 checksum
How to use checksums
a2431b884894f60ce2ef817cfdbed889b304156357e96eac127f50c620b32fec
BLAKE2b-256 checksum
How to use checksums
3e7c9d55a4c2e443b88d9710470e9216f90913020ea87dd072515268194e2b88
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via poetry/1.0.5 CPython/3.8.2 Linux/5.6.11-arch1-1

Release files / despoilerizer-1.0.1-py3-none-any.whl

Download URL despoilerizer-1.0.1-py3-none-any.whl
Size 18.0 kB
Tags Python 3
SHA-256 checksum
How to use checksums
47af32465591e8cc22579822ea475a46304c8c91e30e310b01772d57e27bd9aa
BLAKE2b-256 checksum
How to use checksums
c7600dbe323587480de380bba81db0ffdaf88720c6335f05b0422b964ba36d51
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via poetry/1.0.5 CPython/3.8.2 Linux/5.6.11-arch1-1

Security for despoilerizer 1.0.1

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release

1.0.1 This release

2 release files No provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page