Skip to main content

Poetry formatter

Project description

Poetry PDF

Poetry formatter

Status

Source Shields
Project license release
Publishers pypi
Downloads pypi_downloads
Raised issues pulls

Usage

Plaintext is converted into html and pdfkit is used to export a PDF.

Exposed CLI:

poetry-pdf <source_path>
            [--output-dir=<output_dir>]
            [--author=<author>]
            [--stylesheet=<stylesheet>]...

Example invocation:

poetry-pdf "the_raven.txt" --output-path "." --author "Edgar Allan Poe"

Intermediate html:

<head>
  <meta charset="utf-8" />
  <link
    rel="stylesheet"
    type="text/css"
    href="/Users/joel/Workspace/poetry-pdf/poetry_pdf/styles/default.css"
  />
</head>
<body>
  <h1 id="title">
    The Raven
  </h1>
  <br />
  <p id="poem">
    Once upon a midnight dreary, while I pondered, weak and weary,<br />
    Over many a quaint and curious volume of forgotten lore—<br />
    While I nodded, nearly napping, suddenly there came a tapping,<br />
    As of some one gently rapping, rapping at my chamber door.<br />
    “’Tis some visitor,” I muttered, “tapping at my chamber door—<br />
    Only this and nothing more.”<br />
    <br />
    Ah, distinctly I remember it was in the bleak December;<br />
    And each separate dying ember wrought its ghost upon the floor.<br />
    Eagerly I wished the morrow;—vainly I had sought to borrow<br />
    From my books surcease of sorrow—sorrow for the lost Lenore—<br />
    For the rare and radiant maiden whom the angels name Lenore—<br />
    Nameless here for evermore.<br />
  </p>
  <br />
  <p id="author">
    Edgar Allan Poe
  </p>
</body>

Generated pdf:

the_raven.pdf

Custom stylesheets can be specified:

poetry-pdf "the_raven.txt" --stylesheet "./sheet1.css" --stylesheet "./sheet2.css"

If no stylesheets are provided the page styles will default to:

body {
  font-family: "Avenir Next", sans-serif;
  margin: 100px;
}

#title {
  font-size: 70px;
  font-weight: 500;
  text-align: center;
}

#poem, #author {
    font-style: italic;
    font-weight: 400;
    font-size: 20px;
    line-height: 35px;
  }

#author {
    text-align: right;
  }

Installing

To install the package from pypi:

pip install poetry_pdf

Alternatively, you can clone the repo and build the package locally.

Docs

Additional details are available in the full documentation.

To generate the documentation locally:

multi-job docs

Tests

Unit tests and behaviour tests are written with the pytest framework.

To run tests:

multi-job tests

Additionally, an html report will be saved to the local directory.

Buildbot

To run the buildbot server:

cd ci
docker-compose up -d

Contributing

Please read CONTRIBUTING.md for details on our code of conduct, and the process for submitting pull requests.

Versioning

SemVer is used for versioning. For a list of versions available, see the tags on this repository.

Bump2version is used to version and tag changes. For example:

bump2version patch

Releases are made on every major change.

Author

See also the list of contributors who participated in this project.

License

This project is licensed under the MIT License - see the LICENSE.md file for details

Acknowledgments

None yet!

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

poetry_pdf-1.1.0.tar.gz (147.2 kB view hashes)

Uploaded Source

Built Distribution

poetry_pdf-1.1.0-py3-none-any.whl (173.8 kB view hashes)

Uploaded Python 3

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page