Announcing CaSSius: a tool to create beautiful paginated PDF documents from HTML content using CSS regions. It is intended to be part of XML-first/XML-in workflows for scholarly communications but may have alternative uses.
CaSSius: heavyweight typesetting with lightweight technology.
#Usage and Quick Start Guide CaSSius takes standard HTML content in a pre-specified form and flows it between CSS regions (see “document structure” below). To begin using CaSSius follow these steps:
- Move or copy the “cassius” directory from this repository into the root of your website.
-
Insert the following code into the head tag of your HTML document:
<link rel="stylesheet" href="cassius/cassius.css"> <link rel="stylesheet" href="cassius/cassius-content.css"> <script type="text/javascript" src="cassius/jquery.js"></script> <script type="text/javascript" src="cassius/cassius.js"></script> <script src="cassius/regions/css-regions-polyfill.min.js"></script>
- Optionally, insert the javascript code for Adobe typekit (you will need to sign up for an account).
- Format your document according to the “document structure” guide below.
- Replace cassius/images/logo.png with your own logo.
- Load the page in a browser, wait until it has finished typesetting and then use the browser’s “print to PDF” option to create your document.
#Document Structure The following rules should be strictly adhered to in order to produce correct documents.
Every HTML file should contain a CaSSius metadata block. A CaSSius metadata block should be wrapped inside a script tag with type set to “text/cassius” and an id attribute of “cassius-metadata. A CaSSius metadata block may contain the following elements:
<script type="text/cassius" id="cassius-metadata">
<div id="cassius-metadata-block">
<div id="cassius-title">Article typeset by CaSSius: heavyweight typesetting with lightweight technology</div>
<div id="cassius-publication">CaSSius</div>
<div id="cassius-authors">Martin Paul Eve</div>
<div id="cassius-affiliations">Department of English and Humanities, School of Arts, Birkbeck, University of London, United Kingdom</div>
<div id="cassius-doi">10.16995/olh.001</div>
<div id="cassius-date">September 2015</div>
</div>
</script>
If the “cassius-title” metadata div is not present, CaSSius will use the HTML document’s “title” element in the “head” of the document.
The basic structure of a CaSSius document is as follows (also available in template.html):
<body>
<div id="cassius-content">
<h1 class="articletitle"></h1>
<div class="authors"></div>
<div class="affiliations"></div>
<div class="abstract">
<h2>Abstract</h2>
<p>Your abstract content here.</p>
<p>As many paragraphs as needed.</p>
<p class="oa-info">© 2015 Martin Paul Eve. This is an open-access article distributed under the terms of the Creative Commons Attribution License, which permits unrestricted use, distribution, and reproduction in any medium, provided the original author and source are credited.</p>
</div>
<div class="main">
<div class="section">
<h1>A section title</h1>
<p>A paragraph.</p>
</div>
<div class="section">
<h1>A section title</h1>
<p>A paragraph with a footnote.<a href="#fn1--fragment" id="xr1"><sup>1</sup></a></p>
</div>
<div class="notes">
<h1>Notes</h1>
<div class="footnote"><p><span class="generated"><a href="#xr1--fragment" id="fn1">1</a></span> Footnote content goes here.</p></div>
</div>
<div class="references">
<h1 class="ref-title">References</h1>
<div class="section ref-list">
<ul>
<li class="ref-content">Adorno, Theodor W., <i>Negative Dialectics</i>, trans. by E.B. Ashton (London: Routledge, 1973)</li>
</ul>
</div>
</div>
</div>
</div>
<article id="article"></article>
<script type="text/cassius" id="cassius-metadata">
<div id="cassius-metadata-block">
<div id="cassius-title">Article typeset by CaSSius: heavyweight typesetting with lightweight technology</div>
<div id="cassius-publication">CaSSius</div>
<div id="cassius-authors">Martin Paul Eve</div>
<div id="cassius-affiliations">Department of English and Humanities, School of Arts, Birkbeck, University of London, United Kingdom</div>
<div id="cassius-doi">10.16995/olh.001</div>
<div id="cassius-date">September 2015</div>
</div>
</script>
</body>
#Import from JATS/NLM An early-stage version of an import function from JATS is implemented in cassius-import/bin/cassius-import.py. This script requires python and java.
Usage:
cassius-import.py <in-file> <out-file> [options]
cassius-import.py (-h | --help)
cassius-import.py --version
A sample XML file to show this working (and the scope of implementation to date) can be found in the cassius-import directory.
#Performance and Settings If you are consistently typesetting documents that are over fifty pages long, you may see a performance increase if you change the value of initialPages to a higher setting in cassius.js. Setting this to a higher value will yield better performance on larger documents, but worse performance on smaller documents.
#Components and Licensing CaSSius is copyright Martin Paul Eve 2015. It is released under the terms specified in LICENSE.
CaSSius makes use of several other open-source/free-software projects, including:
- css-regions-polyfill. Copyright (c) 2014 François REMY with a BSD-style license.
- jQuery. Under the MIT license.
- The CaSSius logo is a derivative of a work by Lil Squid from the Noun Project, licensed under the Creative Commons Attribution License.
- Parts of the cassius-import library contain materials from the National Library of Medicine, specifically adaptations of their XSLT suite and entity resolution files, which are public domain.
- The cassius-import library links to the Saxon XSLT and XQuery Processor from Saxonica Limited http://www.saxonica.com/ which is dual-licensed under the GNU GPL and the Mozilla Public License http://www.mozilla.org/MPL/. This dual-licensing applies ONLY to the file saxon9.jar.