The Python document processor
Project description
Rinohtype is a document processor in the style of LaTeX. It renders structured documents to PDF based on a document template and a style sheet. An important goal of rinohtype is to be more user-friendly than LaTeX. This includes providing clear error messages and making it very easy to adjust the document style. See the documentation to learn how to customize the style of your document.
Rinohtype is currently in a beta phase and thus not recommended for production use, but you can use it to explore rinohtype’s features and bugs. I’d highly appreciate it if you could create a ticket for any bugs you may encounter. However, rinohtype is already very capable. Here is a list of its main features:
a powerful page layout system supporting columns, running headers/footers, floatable elements and footnotes
support for figures, and (large) tables
automatically generated table of contents and index
automatic numbering and cross-referencing of section headings, figures and tables
use one of the included document templates or create your own
an intuitive style sheet system inspired by CSS
modular design allowing for multiple frontends (such as reStructuredText, Markdown, DocBook, …)
handles OpenType, TrueType and Type1 fonts with support for advanced typographic features such as kerning, ligatures and small capitals
embeds PDF, PNG and JPEG images, preserving transparency and color profiles
easy to deploy; pure-Python with few dependencies
built on Unicode; ready for non-latin languages
Rinohtype’s primary input format is reStructuredText. The rinoh command line tool renders reStructuredText documents and the included Sphinx builder obsoletes the need for a large LaTeX installation to produce PDF output. Have a look at the rinohtype documentation for an example of the output.
Please, be warned that some older versions of PDF readers have trouble displaying the PDFs generated by rinohtype (issue 2):
pre-37.0 Firefox’s built-in PDF viewer (pdf.js)
pre-0.41 poppler-based applications such as Evince
Requirements
Rinohtype supports Python 3.3+. It might be back-ported to Python 2.7 at some point in the future if there are a lot of requests for it.
For parsing reStructuredText documents Rinohtype depends on docutils. For parsing PNG images rinohtype depends on PurePNG. pip takes care of these requirement when you install rinohtype. If you want to include images other than PDF, PNG or JPEG, you also need to install Pillow.
Getting Started
Installation is trivial:
pip install rinohtype
reStructuredText Renderer
The easiest way to get started with rinohtype is to render a reStructuredText document (such as demo.txt) using the rinoh command line tool:
rinoh demo.txt
When rinoh finishes, you will find demo.pdf alongside the input file.
By default rinoh renders the input document using the article template. Run rinoh --help to see how you can tell rinoh which document template and style sheet to use.
Sphinx Builder
Rinohtype can be used as a drop-in replacement for the LaTeX builder (the latex_documents configuration variable has to be set). You only need to add 'rinoh.frontend.sphinx' to the extensions list in conf.py. With this in place, you can select the rinoh builder when building the documentation:
sphinx-build -b rinoh . _build/rinoh
Contributing
See CONTRIBUTING.rst.
License
All of rinohtype’s source code is licensed under the Affero GPL 3.0, unless indicated otherwise in the source file (such as hyphenator.py).
The Affero GPL requires for software that builds on rinohtype to also be released as open source under the same license. For building closed-source applications, you can obtain a commercial license. The author of rinohtype is also available for consultancy projects involving rinohtype.
Release History
Release 0.3.0 (2016-11-23)
New Features:
support localization of standard document strings (en, fr, it, nl) (#53)
localized strings can be overridden in the document template configuration
make use of a fallback typeface when a glyph is not available (#55) (the ‘fallback’ style in the Sphinx stylesheet sets the fallback typeface)
template configuration (INI) files: specify which document parts to include, configure document part and page templates, customize localized strings, …
support specifying more complex selectors directly in a style sheet file
(figure and table) captions support hierarchical numbering (see CaptionStyle)
make the frontends independent of the current working directory
reStructuredText: support the table :widths: option (upcoming docutils 0.13)
Sphinx frontend: provide styles for Sphinx’s inline markup roles
rinoh (command line renderer):
support template configuration files
support file formats for which a frontend is installed (see –list-formats)
accept options to configure the frontend (see –list-options)
option to list the installed fonts (on the command line or in a PDF file)
show the current page number as part of the rendering progress indicator
Book template: support for setting a cover page
frontends: raise a more descriptive exception when a document tree node is not mapped
validate the default value passed to an Attribute
preliminary support for writing a style sheet to an INI file, listing default values for non-specified attributes (#23)
Changed:
rinoh: the output PDF is now placed in the current directory, not in the same directory as the input file
Sphinx builder configuration: replace the rinoh_document_template and rinoh_template_configuration options with rinoh_template
if no base is given for a style, style attribute lookup proceeds to look in the style of the same name in the base style sheet (#66)
DEFAULT_STYLE can be used as a base style to prevent style attribute lookup in the style of the same name in the base style sheet
rename FieldList to DefinitionList and use it to replace uses (docutils and Sphinx frontends) of the old DefinitionList (#54)
the new DefinitionList (FieldList) can be styled like the old DefinitionList by setting max_label_width to None, 0 or a 0-valued Dimension
figures are now non-floating by default (float placement needs more work)
hide the index chapter when there are no index entries (#51)
style sheets: use the default matcher if none is specified
Sphinx style sheet: copy the admonition style from the Sphinx LaTeX builder
Sphinx style sheet: keep the admonition title together with the body
Sphinx style sheet: color linked references as in the LaTeX output (#62)
Sphinx style sheet: disable hyphenation/ligatures for literal strong text
no more DocumentSection; a document now consists of parts (containing pages)
template configuration:
refer to document part templates by name so that they can be replaced
the list of document parts can be changed in the template configuration
document parts take the ‘end_at_page’ option (left, right, or any)
find (left/right) page templates via the document part name they belong to
fall back to <doc_part>_page when the right or left template is not found
each template configuration requires a name
DocumentTree: make the source_file argument optional
don’t abort when the document section hierarchy is missing levels (#67)
use the PDF backend by default (no need to specify it)
store the unit with Dimension instances (better printing)
rename the float module to image
Fixed:
improve compatibility with Windows: Windows path names and file encoding
crash if a StyledText is passed to HeadingStyle.number_separator
GroupedLabeledFlowables label width could be unnecessarily wide
fix and improve automatic table column sizing
Figures can now be referenced using the ‘reference’ format (“Figure 1.2”)
HorizontallyAlignedFlowable: make more robust
make document elements referenceable by secondary IDs
reStructuredText: only the first classifier for a definition term was shown
Sphinx frontend: support the ‘centered’ directive
Sphinx frontend: basic support for the ‘hlist’ directive
Sphinx frontend: handle :abbr: without explanation
Sphinx frontend: support nested inline nodes (guilabel & samp roles)
PDF backend: fix writing of Type 1 fonts from a parsed PDF file
PDF reader: handle multi-page PDFs (#71)
PDF reader: fix parsing of XRef streams
PDF reader: fix writing of parsed files
Release 0.2.1 (2016-08-18)
New Features:
optionally limit the width of large images and make use of this to simulate the Sphinx LaTeX builder behavior (#46)
reStructuredText/Sphinx: support for images with hyperlinks (#49)
record the styled page numbers in the PDF as page labels (#41)
unsupported Python versions: prevent installation where possible (sdist) or exit on import (wheel)
support Python 3.6
Bugfixes:
make StyleSheet objects picklable so the Sphinx builder’s rinoh_stylesheet option can actually be used
Fix #47: ClassNotFound exception in Literal_Block.lexer_getter()
Fix #45: Images that don’t fit are still placed on the page
don’t warn about duplicate style matches that resolve to the same style
Release 0.2.0 (2016-08-10)
Styling:
generate a style log (show matching styles) to help style sheet development
keep_with_next style attribute: prevent splitting two flowables across pages
stylesheets can be loaded from files in INI format
check the type of attributes passed to styles
source code highlighting using Pygments
table of contents entries can be styled more freely
allow hiding the section numbers of table of contents entries
allow for custom chapter titles
selectors can now also select based on document part/section
various small tweaks to selectors and matchers
various fixes relating to style sheets
Templates:
configurable standard document templates: article and book
a proper infrastructure for creating custom document templates
support for left/right page templates
make the Article template more configurable
pages now have background, content and header/footer layers
support for generating an index
make certain strings configurable (for localization, for example)
Frontends:
Sphinx: interpret the LaTeX configuration variables if the corresponding rinohtype variable is not set
Sphinx: roughly match the LaTeX output (document template and style sheet)
added a CommonMark frontend based on recommonmark
added basic ePUB and DocBook frontends
XML frontends: fix whitespace handling
frontends now return generators yielding flowables (more flexible)
Command-line Renderer (rinoh):
allow specifying a template and style sheet
automatically install typefaces used in the style sheet from PyPI
Fonts:
typefaces are discovered/loaded by entry point
more complete support for OpenType fonts
fix support for the 14 base Type 1 fonts
Images:
more versatile image sizing: absolute width/height & scaling
allow specifying the baseline for inline images
several fixes in the JPEG reader
Miscellaneous:
reorganize the Container class hierarchy
fixes in footnote handling
drop Python 3.2 support (3.3, 3.4 and 3.5 are supported)
Release 0.1.3 (2015-08-04)
recover from the slow rendering speed caused by a bugfix in 0.1.2 (thanks to optimized element matching in the style sheets)
other improvements and bugfixes related to style sheets
Release 0.1.2 (2015-07-31)
much improved Sphinx support (we can now render the Sphinx documentation)
more complete support for reStructuredText (docutils) elements
various fixes related to footnote placement
page break option when starting a new section
fixes in handling of document sections and parts
improvements to section/figure/table references
native support for PNG and JPEG images (drops PIL/Pillow requirement, but adds PurePNG 0.1.1 requirement)
new ‘sphinx’ stylesheet used by the Sphinx builder (~ Sphinx LaTeX style)
restores Python 3.2 compatibility
Release 0.1.1 (2015-04-12)
First preview release
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Hashes for rinohtype-0.3.0-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 8d2af798debf0bd703ba5d6694c093859adc7681faecbea99f5ffc09f826c23a |
|
MD5 | 5ad4e1b315a7223d178991b3d9bc9721 |
|
BLAKE2b-256 | 0ae77ce30dbf218a23d1524c6f3c81ee98d33205c83dd9f4518aef3bf3e94f02 |