You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
typesetting/hyphenate/scribblings/hyphenate.html

4 lines
38 KiB
HTML

<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
11 years ago
<html><head><meta http-equiv="content-type" content="text/html; charset=utf-8"/><title>Hyphenate</title><link rel="stylesheet" type="text/css" href="scribble.css" title="default"/><link rel="stylesheet" type="text/css" href="racket.css" title="default"/><link rel="stylesheet" type="text/css" href="manual-style.css" title="default"/><link rel="stylesheet" type="text/css" href="manual-racket.css" title="default"/><script type="text/javascript" src="scribble-common.js"></script><!--[if IE 6]><style type="text/css">.SIEHidden { overflow: hidden; }</style><![endif]--></head><body id="scribble-racket-lang-org"><div class="tocset"><div class="tocview"><div class="tocviewlist tocviewlisttopspace"><div class="tocviewtitle"><table cellspacing="0" cellpadding="0"><tr><td style="width: 1em;"><a href="javascript:void(0);" title="Expand/Collapse" class="tocviewtoggle" onclick="TocviewToggle(this,&quot;tocview_0&quot;);">&#9658;</a></td><td></td><td><a href="" class="tocviewselflink" data-pltdoc="x">Hyphenate</a></td></tr></table></div><div class="tocviewsublistonly" style="display: none;" id="tocview_0"><table cellspacing="0" cellpadding="0"><tr><td align="right">1&nbsp;</td><td><a href="#%28part._.Installation___updates%29" class="tocviewlink" data-pltdoc="x">Installation &amp; updates</a></td></tr><tr><td align="right">2&nbsp;</td><td><a href="#%28part._.Interface%29" class="tocviewlink" data-pltdoc="x">Interface</a></td></tr><tr><td align="right">3&nbsp;</td><td><a href="#%28part._.License___source_code%29" class="tocviewlink" data-pltdoc="x">License &amp; source code</a></td></tr></table></div></div></div><div class="tocsub"><table class="tocsublist" cellspacing="0"><tr><td><span class="tocsublinknumber"></span><a href="#%28part._.Hyphenate%29" class="tocsubseclink" data-pltdoc="x">Hyphenate</a></td></tr><tr><td><span class="tocsublinknumber">1<tt>&nbsp;</tt></span><a href="#%28part._.Installation___updates%29" class="tocsubseclink" data-pltdoc="x">Installation &amp; updates</a></td></tr><tr><td><span class="tocsublinknumber">2<tt>&nbsp;</tt></span><a href="#%28part._.Interface%29" class="tocsubseclink" data-pltdoc="x">Interface</a></td></tr><tr><td><a href="#%28def._%28%28lib._hyphenate%2Fmain..rkt%29._hyphenate%29%29" class="tocsubnonseclink" data-pltdoc="x"><span class="RktSym"><span class="badlink"><span class="RktValLink">hyphenate</span></span></span></a></td></tr><tr><td><a href="#%28def._%28%28lib._hyphenate%2Fmain..rkt%29._hyphenatef%29%29" class="tocsubnonseclink" data-pltdoc="x"><span class="RktSym"><span class="badlink"><span class="RktValLink">hyphenatef</span></span></span></a></td></tr><tr><td><a href="#%28def._%28%28lib._hyphenate%2Fmain..rkt%29._unhyphenate%29%29" class="tocsubnonseclink" data-pltdoc="x"><span class="RktSym"><span class="badlink"><span class="RktValLink">unhyphenate</span></span></span></a></td></tr><tr><td><span class="tocsublinknumber">3<tt>&nbsp;</tt></span><a href="#%28part._.License___source_code%29" class="tocsubseclink" data-pltdoc="x">License &amp; source code</a></td></tr></table></div></div><div class="maincolumn"><div class="main"><div class="versionbox"><span class="versionNoNav">6.0.0.1</span></div><h2><a name="(part._.Hyphenate)"></a>Hyphenate</h2><div class="SAuthorListBox"><span class="SAuthorList"><p class="author">Matthew Butterick &lt;<a href="mailto:mb@mbtype.com">mb@mbtype.com</a>&gt;</p></span></div><p>A simple hyphenation engine that uses the Knuth&#8211;Liang hyphenation algorithm originally developed for TeX. This implementation is a port of Ned Batchelder&rsquo;s <a href="http://nedbatchelder.com/code/modules/hyphenate.html">Python version</a>. I have added little to their work. Accordingly, I take little credit.</p><p>I originally put together this module to handle hyphenation for my web-based book <a href="http://practicaltypography.com">Butterick&rsquo;s Practical Typography</a> (which I made with Racket &amp; Scribble). Though support for CSS-based hyphenation in web browsers is <a href="http://caniuse.com/#search=hyphen">still iffy</a>, soft hyphens work reliably we
</div><div class="SIntrapara"><table cellspacing="0"><tr><td><p><span class="stt">raco pkg install hyphenate</span></p></td></tr></table></div></p><p><div class="SIntrapara">After that, you can update the package from the command line:
</div><div class="SIntrapara"><table cellspacing="0"><tr><td><p><span class="stt">raco pkg update hyphenate</span></p></td></tr></table></div></p><h3>2<tt>&nbsp;</tt><a name="(part._.Interface)"></a><a name="(mod-path._hyphenate)"></a>Interface</h3><p><table cellspacing="0" class="defmodule"><tr><td align="left"><span class="hspace">&nbsp;</span><span class="RktPn">(</span><span class="RktSym"><span class="badlink"><span class="RktValLink">require</span></span></span><span class="stt"> </span><a href="#%28mod-path._hyphenate%29" class="RktModLink" data-pltdoc="x"><span class="RktSym">hyphenate</span></a><span class="RktPn">)</span></td><td align="right"><span class="RpackageSpec"><span class="Smaller">&nbsp;package:</span> <span class="stt">hyphenate</span></span></td></tr></table></p><p><div class="SIntrapara"><blockquote class="SVInsetFlow"><table cellspacing="0" class="boxed RBoxed"><tr><td><blockquote class="SubFlow"><div class="RBackgroundLabel SIEHidden"><div class="RBackgroundLabelInner"><p>procedure</p></div></div><table cellspacing="0" class="prototype RForeground"><tr><td><span class="RktPn">(</span><a name="(def._((lib._hyphenate/main..rkt)._hyphenate))"></a><span title="Provided from: hyphenate | Package: hyphenate"><span class="RktSym"><span class="badlink"><span class="RktValLink">hyphenate</span></span></span></span></td><td><span class="hspace">&nbsp;</span></td><td><span class="RktVar">text</span></td><td><span class="hspace">&nbsp;</span></td><td><span class="hspace">&nbsp;</span></td><td><span class="hspace">&nbsp;</span></td><td><span class="hspace">&nbsp;</span></td></tr><tr><td><span class="hspace">&nbsp;</span></td><td><span class="hspace">&nbsp;</span>[</td><td><span class="RktVar">joiner</span></td><td><span class="hspace">&nbsp;</span></td><td><span class="hspace">&nbsp;</span></td><td><span class="hspace">&nbsp;</span></td><td><span class="hspace">&nbsp;</span></td></tr><tr><td><span class="hspace">&nbsp;</span></td><td><span class="hspace">&nbsp;</span></td><td><span class="RktPn">#:exceptions</span><span class="hspace">&nbsp;</span><span class="RktVar">exceptions</span></td><td><span class="hspace">&nbsp;</span></td><td><span class="hspace">&nbsp;</span></td><td><span class="hspace">&nbsp;</span></td><td><span class="hspace">&nbsp;</span></td></tr><tr><td><span class="hspace">&nbsp;</span></td><td><span class="hspace">&nbsp;</span></td><td><span class="RktPn">#:min-length</span><span class="hspace">&nbsp;</span><span class="RktVar">length</span>]<span class="RktPn">)</span></td><td><span class="hspace">&nbsp;</span></td><td>&rarr;</td><td><span class="hspace">&nbsp;</span></td><td><span class="RktSym"><span class="badlink"><span class="RktValLink">string?</span></span></span></td></tr></table></blockquote></td></tr><tr><td><span class="hspace">&nbsp;&nbsp;</span><span class="RktVar">text</span><span class="hspace">&nbsp;</span>:<span class="hspace">&nbsp;</span><span class="RktSym"><span class="badlink"><span class="RktValLink">string?</span></span></span></td></tr><tr><td><span class="hspace">&nbsp;&nbsp;</span><span class="RktVar">joiner</span><span class="hspace">&nbsp;</span>:<span class="hspace">&nbsp;</span><span class="RktPn">(</span><span class="RktSym"><span class="badlink"><span class="RktValLink">or/c</span></span></span><span class="hspace">&nbsp;</span><span class="RktSym"><span class="badlink"><span class="RktValLink">char?</span></span></span><span class="hspace">&nbsp;</span><span class="RktSym"><span class="badlink"><span class="RktValLink">string?</span></span></span><span class="RktPn">)</span><span class="hspace">&nbsp;</span>=<span class="hspace">&nbsp;</span><span class="RktPn">(</span><span class="RktSym"><span class="badlink"><span class="RktValLink">integer-&gt;char</span></span></span><span class="hspace">&nbsp;</span><span class="RktVal">173</span><span class="RktPn">)</span></td></tr><tr><td><span class="hspace">&nbsp;&nbsp;</span><span class="RktVar">exceptions</span><span class="hspace">&nbsp;</span>:<span class="hspace">&nbsp;</span><span class="RktPn">(</span>