title: Mechanical Ragger: Print typesetting for the web
url: https://oak.is/thinking/mechanical-ragger/
hash_url: c0e7ed5590b520f176aacfd76ae03188

<p>The web has never been a place for perfectionism. Typesetting in particular has been a long-neglected facet of web design because we’ve lacked the tools to give long texts the editorial care they need.</p>

<p>In print media, text ragging is an <a href="https://oakstudios.github.io/mechanical-ragger/examples">established practice</a> to help this, but up to now there have been no tools on the web to do this.</p>

<p>We built <a href="https://oakstudios.github.io/mechanical-ragger/">Mechanical Ragger</a> to give designers some peace of mind; it tidies line endings so that long paragraphs will feel natural to read, and users won’t have to strain to read them.</p>

<p>Historically, text ragging is a practice to adjust the uneven line ends of paragraphs. (In a left-aligned paragraph, this is the right side.) We can illustrate how this would enhance readability in a long flow of text:</p>

<p class="wide"><img src="/uploads/Ragging%20Animation.svg" alt="Comparison showing text ragging"></p>

<p class="caption">Text without ragging (left) compared to with ragging (right)</p>

<p>Without ragging, lines are left to break naturally with the content, where long words at the end of a line can cause irregularities in the shape of paragraphs. This often has the effect of drawing a reader’s attention away from the content. A well-ragged paragraph removes these and brings a sense of rhythm and harmony to the often irregular shapes of latin text, ensuring readers can get through the copy without distraction.</p>

<p>Mechanical Ragger brings this print concept to the web, improving the appearance of text blocks by removing these significant gaps and alternating line lengths to enhance the rhythm of the paragraph. To do this, it adds shapes to every other line in a paragraph, causing text to wrap around it:</p>

<p><img src="/uploads/Exclusion%20Example.svg" alt="Visual showing how Mechanical Ragger works"></p>

<p class="caption">How Mechanical Ragger works behind the scenes</p>

<h2 id="demo">Demo</h2>

<p><a href="https://oakstudios.github.io/mechanical-ragger"><img src="/uploads/mechanical-ragger-demo.png" alt="Mechanical Ragger demo website"></a></p>

<p class="caption">View a live demo at: <a href="https://oakstudios.github.io/mechanical-ragger">oakstudios.github.io/mechanical-ragger</a></p>

<h2 id="usage">Usage</h2>

<p>We built this tool as an extensible JavaScript library; it’s ready-to-use on the web, in React, and easily portable to any framework. Using the web component, the setup can be as simple as:</p>

<div class="language-js highlighter-rouge"><div class="highlight"><pre class="highlight"><code><span class="o">&lt;</span><span class="nx">mechanical</span><span class="o">-</span><span class="nx">ragger</span><span class="o">&gt;</span>
  <span class="nx">Lorem</span> <span class="nx">ipsum</span> <span class="nx">dolor</span> <span class="nx">sit</span> <span class="nx">amet</span> <span class="nx">consectetur</span> <span class="nx">adipisicing</span> <span class="nx">elit</span><span class="p">.</span>
<span class="o">&lt;</span><span class="sr">/mechanical-ragger</span><span class="err">&gt;
</span>
<span class="o">&lt;</span><span class="nx">script</span> <span class="nx">src</span><span class="o">=</span><span class="dl">"</span><span class="s2">https://unpkg.com/@oakstudios/mechanical-ragger@latest/web-component-auto-register.js</span><span class="dl">"</span><span class="o">&gt;&lt;</span><span class="sr">/script</span><span class="err">&gt;
</span></code></pre></div></div>

<h2 id="considerations">Considerations</h2>

<p>Typesetting is about more than just the shape of the text, though. There are a few related considerations to keep in mind when ragging:</p>

<ul>
  <li>Avoid repeating words or shapes at the end of each line in a paragraph.</li>
  <li>Avoid breaking too many words, which can make readability worse.</li>
</ul>

<p>Advanced typesetting is complex and contextual, requiring a human touch. While the mechanical ragger is a useful aid, we call it mechanical for a reason, and content must be written accordingly.</p>

<p>Mechanical Ragger is open-source, on <a href="https://github.com/oakstudios/mechanical-ragger">GitHub</a> and as an <a href="https://www.npmjs.com/@oakstudios/mechanical-ragger">NPM module</a>. Contributions to add new features and more platform support for the Mechanical Ragger are always welcome.</p>
