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/doc/index.html

4 lines
79 KiB
HTML

<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<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><script type="text/javascript" src="manual-racket.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="index.html" 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="index.html#%28part._.Installation%29" class="tocviewlink" data-pltdoc="x">Installation</a></td></tr><tr><td align="right">2&nbsp;</td><td><a href="index.html#%28part._.Importing_the_module%29" class="tocviewlink" data-pltdoc="x">Importing the module</a></td></tr><tr><td align="right">3&nbsp;</td><td><a href="index.html#%28part._.Interface%29" class="tocviewlink" data-pltdoc="x">Interface</a></td></tr><tr><td align="right">4&nbsp;</td><td><a href="index.html#%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%29" class="tocsubseclink" data-pltdoc="x">Installation</a></td></tr><tr><td><span class="tocsublinknumber">2<tt>&nbsp;</tt></span><a href="#%28part._.Importing_the_module%29" class="tocsubseclink" data-pltdoc="x">Importing the module</a></td></tr><tr><td><span class="tocsublinknumber">3<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="RktValLink">hyphenate</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="RktValLink">unhyphenate</span></span></a></td></tr><tr><td><span class="tocsublinknumber">4<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.1.13</span></div><h2><a name="(part._.Hyphenate)"></a><a name="(mod-path._hyphenate)"></a><a name="(mod-path._(submod._hyphenate._safe))"></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><table cellspacing="0" cellpadding="0" class="defmodule"><tr><td align="left"><span class="hspace">&nbsp;</span><span class="RktPn">(</span><span class="RktSym"><a href="http://docs.racket-lang.org/reference/require.html#%28form._%28%28lib._racket%2Fprivate%2Fbase..rkt%29._require%29%29" class="RktStxLink" data-pltdoc="x">require</a></span><span class="stt"> </span><a href="index.html" 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><tr><td align="left" colspan="2"><span class="hspace">&nbsp;</span><span class="RktPn">(</span><span class="RktSym"><a href="http://docs.racket-lang.org/reference/require.html#%28form._%28%28lib._racket%2Fprivate%2Fbase..rkt%29._require%29%29" class="RktStxLink" data-pltdoc="x">require</a></span><span class="stt"> </span><span class="RktPn">(</span><span class="RktSym"><a href="http://docs.racket-lang.org/reference/require.html#%28form._%28%28lib._racket%2Fprivate%2Fbase..rkt%29._submod%29%29" class="RktStxLink" data-pltdoc="x">submod</a></span><span class="stt"> </span><span class="RktSym"><a href="index.html#%28def._%28%28lib._hyphenate%2Fmain..rkt%29._hyphenate%29%29" class="RktValLink" data-pltdoc="x">hyphenate</a></span><span class="stt"> </span><span class="RktSym">safe</span><span class="RktPn">)</span><span class="RktPn">)</span></td></tr></table></p><p>A simple hyphenation engine that uses the Knuth&#8211;Liang hyphenation algorithm originally developed for TeX. 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 well. But putting them into the text manually is a drag. Thus a module was born.</p><h3>1<tt>&nbsp;</tt><a name="(part._.Installation)"></a>Installation</h3><p><div class="SIntrapara">At the command line:
</div><div class="SIntrapara"><table cellspacing="0" cellpadding="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 like so:
</div><div class="SIntrapara"><table cellspacing="0" cellpadding="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._.Importing_the_module)"></a>Importing the module</h3><p>The module operates in two modes: fast and safe. Fast mode is the default, which you get by importing the module in the usual way: <span class="RktPn">(</span><span class="RktSym"><a href="http://docs.racket-lang.org/reference/require.html#%28form._%28%28lib._racket%2Fprivate%2Fbase..rkt%29._require%29%29" class="RktStxLink" data-pltdoc="x">require</a></span><span class="RktMeta"></span><span class="hspace">&nbsp;</span><span class="RktMeta"></span><span class="RktSym"><a href="index.html#%28def._%28%28lib._hyphenate%2Fmain..rkt%29._hyphenate%29%29" class="RktValLink" data-pltdoc="x">hyphenate</a></span><span class="RktPn">)</span><span class="RktMeta"></span>.</p><p>Safe mode enables the function contracts documented below. Use safe mode by importing the module as <span class="RktPn">(</span><span class="RktSym"><a href="http://docs.racket-lang.org/reference/require.html#%28form._%28%28lib._racket%2Fprivate%2Fbase..rkt%29._require%29%29" class="RktStxLink" data-pltdoc="x">require</a></span><span class="RktMeta"></span><span class="hspace">&nbsp;</span><span class="RktMeta"></span><span class="RktPn">(</span><span class="RktSym"><a href="http://docs.racket-lang.org/reference/require.html#%28form._%28%28lib._racket%2Fprivate%2Fbase..rkt%29._submod%29%29" class="RktStxLink" data-pltdoc="x">submod</a></span><span class="RktMeta"></span><span class="hspace">&nbsp;</span><span class="RktMeta"></span><span class="RktSym"><a href="index.html#%28def._%28%28lib._hyphenate%2Fmain..rkt%29._hyphenate%29%29" class="RktValLink" data-pltdoc="x">hyphenate</a></span><span class="RktMeta"></span><span class="hspace">&nbsp;</span><span class="RktMeta"></span><span class="RktSym">safe</span><span class="RktPn">)</span><span class="RktPn">)</span><span class="RktMeta"></span>.</p><h3>3<tt>&nbsp;</tt><a name="(part._.Interface)"></a>Interface</h3><p><div class="SIntrapara"><blockquote class="SVInsetFlow"><table cellspacing="0" cellpadding="0" class="boxed RBoxed"><tr><td><blockquote class="SubFlow"><div class="RBackgroundLabel SIEHidden"><div class="RBackgroundLabelInner"><p>procedure</p></div></div><table cellspacing="0" cellpadding="0" class="prototype RForeground"><tr><td><span class="RktPn">(</span><a name="(def._((lib._hyphenate/main..rkt)._hyphenate))"></a><span title="Provided from: hyphenate, (submod hyphenate safe) | Package: hyphenate"><span class="RktSym"><a href="index.html#%28def._%28%28lib._hyphenate%2Fmain..rkt%29._hyphenate%29%29" class="RktValDef RktValLink" data-pltdoc="x">hyphenate</a></span></span></td><td><span class="hspace">&nbsp;</span></td><td><span class="RktVar">xexpr</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></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-left-length</span><span class="hspace">&nbsp;</span><span class="RktVar">left-length</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-right-length</span><span class="hspace">&nbsp;</span><span class="RktVar">right-length</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">#:omit-word</span><span class="hspace">&nbsp;</span><span class="RktVar">word-test</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">#:omit-string</span><span class="hspace">&nbsp;</span><span class="RktVar">string-test</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">#:omit-txexpr</span><span class="hspace">&nbsp;</span><span class="RktVar">txexpr-test</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"><a href="http://docs.racket-lang.org/xml/index.html#%28def._%28%28lib._xml%2Fprivate%2Fxexpr-core..rkt%29._xexpr%2Fc%29%29" class="RktValLink" data-pltdoc="x">xexpr/c</a></span></td></tr></table></blockquote></td></tr><tr><td><span class="hspace">&nbsp;&nbsp;</span><span class="RktVar">xexpr</span><span class="hspace">&nbsp;</span>:<span class="hspace">&nbsp;</span><span class="RktSym"><a href="http://docs.racket-lang.org/xml/index.html#%28def._%28%28lib._xml%2Fprivate%2Fxexpr-core..rkt%29._xexpr%2Fc%29%29" class="RktValLink" data-pltdoc="x">xexpr/c</a></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"><a href="http://docs.racket-lang.org/reference/data-structure-contracts.html#%28def._%28%28lib._racket%2Fcontract%2Fbase..rkt%29._or%2Fc%29%29" class="RktValLink" data-pltdoc="x">or/c</a></span><span class="hspace">&nbsp;</span><span class="RktSym"><a href="http://docs.racket-lang.org/reference/characters.html#%28def._%28%28quote._~23~25kernel%29._char~3f%29%29" class="RktValLink" data-pltdoc="x">char?</a></span><span class="hspace">&nbsp;</span><span class="RktSym"><a href="http://docs.racket-lang.org/reference/strings.html#%28def._%28%28quote._~23~25kernel%29._string~3f%29%29" class="RktValLink" data-pltdoc="x">string?</a></span><span class="RktPn">)</span><span class="hspace">&nbsp;</span>=<span class="hspace">&nbsp;</span><span class="RktPn">(</span><span class="RktSym"><a href="http://docs.racket-lang.org/reference/characters.html#%28def._%28%28quote._~23~25kernel%29._integer-~3echar%29%29" class="RktValLink" data-pltdoc="x">integer-&gt;char</a></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><span class="RktSym"><a href="http://docs.racket-lang.org/reference/data-structure-contracts.html#%28def._%28%28lib._racket%2Fcontract%2Fprivate%2Fmisc..rkt%29._listof%29%29" class="RktValLink" data-pltdoc="x">listof</a></span><span class="hspace">&nbsp;</span><span class="RktSym"><a href="http://docs.racket-lang.org/reference/strings.html#%28def._%28%28quote._~23~25kernel%29._string~3f%29%29" class="RktValLink" data-pltdoc="x">string?</a></span><span class="RktPn">)</span><span class="hspace">&nbsp;</span>=<span class="hspace">&nbsp;</span><span class="RktSym"><a href="http://docs.racket-lang.org/reference/pairs.html#%28def._%28%28lib._racket%2Flist..rkt%29._empty%29%29" class="RktValLink" data-pltdoc="x">empty</a></span></td></tr><tr><td><span class="hspace">&nbsp;&nbsp;</span><span class="RktVar">length</span><span class="hspace">&nbsp;</span>:<span class="hspace">&nbsp;</span><span class="RktPn">(</span><span class="RktSym"><a href="http://docs.racket-lang.org/reference/data-structure-contracts.html#%28def._%28%28lib._racket%2Fcontract%2Fbase..rkt%29._or%2Fc%29%29" class="RktValLink" data-pltdoc="x">or/c</a></span><span class="hspace">&nbsp;</span><span class="RktSym"><a href="http://docs.racket-lang.org/reference/number-types.html#%28def._%28%28quote._~23~25kernel%29._integer~3f%29%29" class="RktValLink" data-pltdoc="x">integer?</a></span><span class="hspace">&nbsp;</span><span class="RktSym"><a href="http://docs.racket-lang.org/reference/booleans.html#%28def._%28%28lib._racket%2Fbool..rkt%29._false~3f%29%29" class="RktValLink" data-pltdoc="x">false?</a></span><span class="RktPn">)</span><span class="hspace">&nbsp;</span>=<span class="hspace">&nbsp;</span><span class="RktVal">5</span></td></tr><tr><td><span class="hspace">&nbsp;&nbsp;</span><span class="RktVar">left-length</span><span class="hspace">&nbsp;</span>:<span class="hspace">&nbsp;</span><span class="RktPn">(</span><span class="RktSym"><a href="http://docs.racket-lang.org/reference/data-structure-contracts.html#%28def._%28%28lib._racket%2Fcontract%2Fbase..rkt%29._or%2Fc%29%29" class="RktValLink" data-pltdoc="x">or/c</a></span><span class="hspace">&nbsp;</span><span class="RktPn">(</span><span class="RktSym"><a href="http://docs.racket-lang.org/reference/data-structure-contracts.html#%28def._%28%28lib._racket%2Fcontract%2Fprivate%2Fmisc..rkt%29._and%2Fc%29%29" class="RktValLink" data-pltdoc="x">and/c</a></span><span class="hspace">&nbsp;</span><span class="RktSym"><a href="http://docs.racket-lang.org/reference/number-types.html#%28def._%28%28quote._~23~25kernel%29._integer~3f%29%29" class="RktValLink" data-pltdoc="x">integer?</a></span><span class="hspace">&nbsp;</span><span class="RktSym"><a href="http://docs.racket-lang.org/reference/number-types.html#%28def._%28%28quote._~23~25kernel%29._positive~3f%29%29" class="RktValLink" data-pltdoc="x">positive?</a></span><span class="RktPn">)</span><span class="hspace">&nbsp;</span><span class="RktVal">#f</span><span class="RktPn">)</span><span class="hspace">&nbsp;</span>=<span class="hspace">&nbsp;</span><span class="RktVal">2</span></td></tr><tr><td><span class="hspace">&nbsp;&nbsp;</span><span class="RktVar">right-length</span><span class="hspace">&nbsp;</span>:<span class="hspace">&nbsp;</span><span class="RktPn">(</span><span class="RktSym"><a href="http://docs.racket-lang.org/reference/data-structure-contracts.html#%28def._%28%28lib._racket%2Fcontract%2Fbase..rkt%29._or%2Fc%29%29" class="RktValLink" data-pltdoc="x">or/c</a></span><span class="hspace">&nbsp;</span><span class="RktPn">(</span><span class="RktSym"><a href="http://docs.racket-lang.org/reference/data-structure-contracts.html#%28def._%28%28lib._racket%2Fcontract%2Fprivate%2Fmisc..rkt%29._and%2Fc%29%29" class="RktValLink" data-pltdoc="x">and/c</a></span><span class="hspace">&nbsp;</span><span class="RktSym"><a href="http://docs.racket-lang.org/reference/number-types.html#%28def._%28%28quote._~23~25kernel%29._integer~3f%29%29" class="RktValLink" data-pltdoc="x">integer?</a></span><span class="hspace">&nbsp;</span><span class="RktSym"><a href="http://docs.racket-lang.org/reference/number-types.html#%28def._%28%28quote._~23~25kernel%29._positive~3f%29%29" class="RktValLink" data-pltdoc="x">positive?</a></span><span class="RktPn">)</span><span class="hspace">&nbsp;</span><span class="RktVal">#f</span><span class="RktPn">)</span><span class="hspace">&nbsp;</span>=<span class="hspace">&nbsp;</span><span class="RktVal">2</span></td></tr><tr><td><span class="hspace">&nbsp;&nbsp;</span><span class="RktVar">word-test</span><span class="hspace">&nbsp;</span>:<span class="hspace">&nbsp;</span><span class="RktPn">(</span><span class="RktSym"><a href="http://docs.racket-lang.org/reference/strings.html#%28def._%28%28quote._~23~25kernel%29._string~3f%29%29" class="RktValLink" data-pltdoc="x">string?</a></span><span class="hspace">&nbsp;</span><span class="RktPn">. </span><span class="RktSym"><a href="http://docs.racket-lang.org/reference/function-contracts.html#%28form._%28%28lib._racket%2Fcontract%2Fbase..rkt%29._-~3e%29%29" class="RktStxLink" data-pltdoc="x"><span class="nobreak">-&gt;</span></a></span><span class="RktPn"> .</span><span class="hspace">&nbsp;</span><span class="RktSym"><a href="http://docs.racket-lang.org/reference/data-structure-contracts.html#%28def._%28%28lib._racket%2Fcontract%2Fprivate%2Fmisc..rkt%29._any%2Fc%29%29" class="RktValLink" data-pltdoc="x">any/c</a></span><span class="RktPn">)</span><span class="hspace">&nbsp;</span>=<span class="hspace">&nbsp;</span><span class="RktPn">(</span><span class="RktSym"><a href="http://docs.racket-lang.org/reference/lambda.html#%28form._%28%28lib._racket%2Fprivate%2Fbase..rkt%29._~ce~bb%29%29" class="RktStxLink" data-pltdoc="x">&#955;</a></span><span class="RktPn">(</span><span class="RktSym">x</span><span class="RktPn">)</span><span class="hspace">&nbsp;</span><span class="RktVal">#f</span><span class="RktPn">)</span></td></tr><tr><td><span class="hspace">&nbsp;&nbsp;</span><span class="RktVar">string-test</span><span class="hspace">&nbsp;</span>:<span class="hspace">&nbsp;</span><span class="RktPn">(</span><span class="RktSym"><a href="http://docs.racket-lang.org/reference/strings.html#%28def._%28%28quote._~23~25kernel%29._string~3f%29%29" class="RktValLink" data-pltdoc="x">string?</a></span><span class="hspace">&nbsp;</span><span class="RktPn">. </span><span class="RktSym"><a href="http://docs.racket-lang.org/reference/function-contracts.html#%28form._%28%28lib._racket%2Fcontract%2Fbase..rkt%29._-~3e%29%29" class="RktStxLink" data-pltdoc="x"><span class="nobreak">-&gt;</span></a></span><span class="RktPn"> .</span><span class="hspace">&nbsp;</span><span class="RktSym"><a href="http://docs.racket-lang.org/reference/data-structure-contracts.html#%28def._%28%28lib._racket%2Fcontract%2Fprivate%2Fmisc..rkt%29._any%2Fc%29%29" class="RktValLink" data-pltdoc="x">any/c</a></span><span class="RktPn">)</span><span class="hspace">&nbsp;</span>=<span class="hspace">&nbsp;</span><span class="RktPn">(</span><span class="RktSym"><a href="http://docs.racket-lang.org/reference/lambda.html#%28form._%28%28lib._racket%2Fprivate%2Fbase..rkt%29._~ce~bb%29%29" class="RktStxLink" data-pltdoc="x">&#955;</a></span><span class="RktPn">(</span><span class="RktSym">x</span><span class="RktPn">)</span><span class="hspace">&nbsp;</span><span class="RktVal">#f</span><span class="RktPn">)</span></td></tr><tr><td><span class="hspace">&nbsp;&nbsp;</span><span class="RktVar">txexpr-test</span><span class="hspace">&nbsp;</span>:<span class="hspace">&nbsp;</span><span class="RktPn">(</span><span class="RktSym"><a href="http://docs.racket-lang.org/txexpr/index.html#%28def._%28%28lib._txexpr%2Fmain..rkt%29._txexpr~3f%29%29" class="RktValLink" data-pltdoc="x">txexpr?</a></span><span class="hspace">&nbsp;</span><span class="RktPn">. </span><span class="RktSym"><a href="http://docs.racket-lang.org/reference/function-contracts.html#%28form._%28%28lib._racket%2Fcontract%2Fbase..rkt%29._-~3e%29%29" class="RktStxLink" data-pltdoc="x"><span class="nobreak">-&gt;</span></a></span><span class="RktPn"> .</span><span class="hspace">&nbsp;</span><span class="RktSym"><a href="http://docs.racket-lang.org/reference/data-structure-contracts.html#%28def._%28%28lib._racket%2Fcontract%2Fprivate%2Fmisc..rkt%29._any%2Fc%29%29" class="RktValLink" data-pltdoc="x">any/c</a></span><span class="RktPn">)</span><span class="hspace">&nbsp;</span>=<span class="hspace">&nbsp;</span><span class="RktPn">(</span><span class="RktSym"><a href="http://docs.racket-lang.org/reference/lambda.html#%28form._%28%28lib._racket%2Fprivate%2Fbase..rkt%29._~ce~bb%29%29" class="RktStxLink" data-pltdoc="x">&#955;</a></span><span class="RktPn">(</span><span class="RktSym">x</span><span class="RktPn">)</span><span class="hspace">&nbsp;</span><span class="RktVal">#f</span><span class="RktPn">)</span></td></tr></table></blockquote></div><div class="SIntrapara">Hyphenate <span class="RktVar">xexpr</span> by calculating hyphenation points and inserting <span class="RktVar">joiner</span> at those points. By default, <span class="RktVar">joiner</span> is the soft hyphen (Unicode 00AD = decimal 173). Words shorter than <span class="RktPn">#:min-length</span>&#160;<span class="RktVar">length</span> will not be hyphenated. To hyphenate words of any length, use <span class="RktPn">#:min-length</span>&#160;<span class="RktVal">#f</span>.</div></p><blockquote class="refpara"><blockquote class="refcolumn"><blockquote class="refcontent"><p>The REPL displays a soft hyphen as <span class="RktSym">\u00AD</span><span class="RktMeta"></span>. But in ordinary use, you&rsquo;ll only see a soft hyphen when it appears at the end of a line or page as part of a hyphenated word. Otherwise it&rsquo;s not displayed. In most of the examples here, I use a standard hyphen for clarity (by adding <span class="RktVal">#\-</span><span class="RktMeta"></span> as an argument).</p></blockquote></blockquote></blockquote><p><table cellspacing="0" cellpadding="0" class="RktBlk"><tr><td><p>Examples:</p></td></tr><tr><td><blockquote class="SCodeFlow"><table cellspacing="0" cellpadding="0" class="RktBlk"><tr><td><span class="stt">&gt; </span><span class="RktPn">(</span><span class="RktSym"><a href="index.html#%28def._%28%28lib._hyphenate%2Fmain..rkt%29._hyphenate%29%29" class="RktValLink" data-pltdoc="x">hyphenate</a></span><span class="hspace">&nbsp;</span><span class="RktVal">"ergo polymorphism"</span><span class="RktPn">)</span></td></tr><tr><td><p><span class="RktRes">"ergo poly\u00ADmor\u00ADphism"</span></p></td></tr><tr><td><span class="stt">&gt; </span><span class="RktPn">(</span><span class="RktSym"><a href="index.html#%28def._%28%28lib._hyphenate%2Fmain..rkt%29._hyphenate%29%29" class="RktValLink" data-pltdoc="x">hyphenate</a></span><span class="hspace">&nbsp;</span><span class="RktVal">"ergo polymorphism"</span><span class="hspace">&nbsp;</span><span class="RktVal">#\-</span><span class="RktPn">)</span></td></tr><tr><td><p><span class="RktRes">"ergo poly-mor-phism"</span></p></td></tr><tr><td><span class="stt">&gt; </span><span class="RktPn">(</span><span class="RktSym"><a href="index.html#%28def._%28%28lib._hyphenate%2Fmain..rkt%29._hyphenate%29%29" class="RktValLink" data-pltdoc="x">hyphenate</a></span><span class="hspace">&nbsp;</span><span class="RktVal">"ergo polymorphism"</span><span class="hspace">&nbsp;</span><span class="RktPn">#:min-length</span><span class="hspace">&nbsp;</span><span class="RktVal">13</span><span class="RktPn">)</span></td></tr><tr><td><p><span class="RktRes">"ergo polymorphism"</span></p></td></tr><tr><td><span class="stt">&gt; </span><span class="RktPn">(</span><span class="RktSym"><a href="index.html#%28def._%28%28lib._hyphenate%2Fmain..rkt%29._hyphenate%29%29" class="RktValLink" data-pltdoc="x">hyphenate</a></span><span class="hspace">&nbsp;</span><span class="RktVal">"ergo polymorphism"</span><span class="hspace">&nbsp;</span><span class="RktPn">#:min-length</span><span class="hspace">&nbsp;</span><span class="RktVal">#f</span><span class="RktPn">)</span></td></tr><tr><td><p><span class="RktRes">"er\u00ADgo poly\u00ADmor\u00ADphism"</span></p></td></tr></table></blockquote></td></tr></table></p><p>The <span class="RktPn">#:min-left-length</span> and <span class="RktPn">#:min-right-length</span> keyword arguments set the minimum distance between a potential hyphen and the left or right ends of the word. The default is 2 characters. Larger values will reduce hyphens, but also prevent small words from breaking. These values will override a smaller <span class="RktPn">#:min-length</span> value.</p><p><table cellspacing="0" cellpadding="0" class="RktBlk"><tr><td><p>Examples:</p></td></tr><tr><td><blockquote class="SCodeFlow"><table cellspacing="0" cellpadding="0" class="RktBlk"><tr><td><span class="stt">&gt; </span><span class="RktPn">(</span><span class="RktSym"><a href="index.html#%28def._%28%28lib._hyphenate%2Fmain..rkt%29._hyphenate%29%29" class="RktValLink" data-pltdoc="x">hyphenate</a></span><span class="hspace">&nbsp;</span><span class="RktVal">"ergo polymorphism"</span><span class="hspace">&nbsp;</span><span class="RktVal">#\-</span><span class="RktPn">)</span></td></tr><tr><td><p><span class="RktRes">"ergo poly-mor-phism"</span></p></td></tr><tr><td><span class="stt">&gt; </span><span class="RktPn">(</span><span class="RktSym"><a href="index.html#%28def._%28%28lib._hyphenate%2Fmain..rkt%29._hyphenate%29%29" class="RktValLink" data-pltdoc="x">hyphenate</a></span><span class="hspace">&nbsp;</span><span class="RktVal">"ergo polymorphism"</span><span class="hspace">&nbsp;</span><span class="RktVal">#\-</span><span class="hspace">&nbsp;</span><span class="RktPn">#:min-left-length</span><span class="hspace">&nbsp;</span><span class="RktVal">#f</span><span class="RktPn">)</span></td></tr><tr><td><p><span class="RktRes">"ergo poly-mor-phism"</span></p></td></tr><tr><td><span class="stt">&gt; </span><span class="RktPn">(</span><span class="RktSym"><a href="index.html#%28def._%28%28lib._hyphenate%2Fmain..rkt%29._hyphenate%29%29" class="RktValLink" data-pltdoc="x">hyphenate</a></span><span class="hspace">&nbsp;</span><span class="RktVal">"ergo polymorphism"</span><span class="hspace">&nbsp;</span><span class="RktVal">#\-</span><span class="hspace">&nbsp;</span><span class="RktPn">#:min-length</span><span class="hspace">&nbsp;</span><span class="RktVal">2</span><span class="hspace">&nbsp;</span><span class="RktPn">#:min-left-length</span><span class="hspace">&nbsp;</span><span class="RktVal">5</span><span class="RktPn">)</span></td></tr><tr><td><p><span class="RktRes">"ergo polymor-phism"</span></p></td></tr><tr><td><span class="stt">&gt; </span><span class="RktPn">(</span><span class="RktSym"><a href="index.html#%28def._%28%28lib._hyphenate%2Fmain..rkt%29._hyphenate%29%29" class="RktValLink" data-pltdoc="x">hyphenate</a></span><span class="hspace">&nbsp;</span><span class="RktVal">"ergo polymorphism"</span><span class="hspace">&nbsp;</span><span class="RktVal">#\-</span><span class="hspace">&nbsp;</span><span class="RktPn">#:min-right-length</span><span class="hspace">&nbsp;</span><span class="RktVal">6</span><span class="RktPn">)</span></td></tr><tr><td><p><span class="RktRes">"ergo poly-morphism"</span></p></td></tr><tr><td><span class="RktCmt">;</span><span class="RktCmt">&nbsp;</span><span class="RktCmt">Next words won</span><span class="RktCmt">'</span><span class="RktCmt">t be hyphenated becase of large #:min-left-length</span></td></tr><tr><td><span class="stt">&gt; </span><span class="RktPn">(</span><span class="RktSym"><a href="index.html#%28def._%28%28lib._hyphenate%2Fmain..rkt%29._hyphenate%29%29" class="RktValLink" data-pltdoc="x">hyphenate</a></span><span class="hspace">&nbsp;</span><span class="RktVal">"ergo polymorphism"</span><span class="hspace">&nbsp;</span><span class="RktVal">#\-</span><span class="hspace">&nbsp;</span><span class="RktPn">#:min-length</span><span class="hspace">&nbsp;</span><span class="RktVal">#f</span><span class="hspace">&nbsp;</span><span class="RktPn">#:min-left-length</span><span class="hspace">&nbsp;</span><span class="RktVal">15</span><span class="RktPn">)</span></td></tr><tr><td><p><span class="RktRes">"ergo polymorphism"</span></p></td></tr></table></blockquote></td></tr></table></p><p>Because the hyphenation is based on an algorithm rather than a dictionary, it makes good guesses with unusual words:</p><p><table cellspacing="0" cellpadding="0" class="RktBlk"><tr><td><p>Examples:</p></td></tr><tr><td><blockquote class="SCodeFlow"><table cellspacing="0" cellpadding="0" class="RktBlk"><tr><td><span class="stt">&gt; </span><span class="RktPn">(</span><span class="RktSym"><a href="index.html#%28def._%28%28lib._hyphenate%2Fmain..rkt%29._hyphenate%29%29" class="RktValLink" data-pltdoc="x">hyphenate</a></span><span class="hspace">&nbsp;</span><span class="RktVal">"scraunched strengths"</span><span class="hspace">&nbsp;</span><span class="RktVal">#\-</span><span class="RktPn">)</span></td></tr><tr><td><p><span class="RktRes">"scraunched strengths"</span></p></td></tr><tr><td><span class="stt">&gt; </span><span class="RktPn">(</span><span class="RktSym"><a href="index.html#%28def._%28%28lib._hyphenate%2Fmain..rkt%29._hyphenate%29%29" class="RktValLink" data-pltdoc="x">hyphenate</a></span><span class="hspace">&nbsp;</span><span class="RktVal">"RacketCon"</span><span class="hspace">&nbsp;</span><span class="RktVal">#\-</span><span class="RktPn">)</span></td></tr><tr><td><p><span class="RktRes">"Rack-et-Con"</span></p></td></tr><tr><td><span class="stt">&gt; </span><span class="RktPn">(</span><span class="RktSym"><a href="index.html#%28def._%28%28lib._hyphenate%2Fmain..rkt%29._hyphenate%29%29" class="RktValLink" data-pltdoc="x">hyphenate</a></span><span class="hspace">&nbsp;</span><span class="RktVal">"supercalifragilisticexpialidocious"</span><span class="hspace">&nbsp;</span><span class="RktVal">#\-</span><span class="RktPn">)</span></td></tr><tr><td><p><span class="RktRes">"su-per-cal-ifrag-ilis-tic-ex-pi-ali-do-cious"</span></p></td></tr></table></blockquote></td></tr></table></p><p>Using the <span class="RktPn">#:exceptions</span> keyword, you can pass hyphenation exceptions as a list of words with hyphenation points marked with regular hyphens (<span class="RktVal">"-"</span>). If an exception word contains no hyphens, that word will never be hyphenated.</p><p><table cellspacing="0" cellpadding="0" class="RktBlk"><tr><td><p>Examples:</p></td></tr><tr><td><blockquote class="SCodeFlow"><table cellspacing="0" cellpadding="0" class="RktBlk"><tr><td><span class="stt">&gt; </span><span class="RktPn">(</span><span class="RktSym"><a href="index.html#%28def._%28%28lib._hyphenate%2Fmain..rkt%29._hyphenate%29%29" class="RktValLink" data-pltdoc="x">hyphenate</a></span><span class="hspace">&nbsp;</span><span class="RktVal">"polymorphism"</span><span class="hspace">&nbsp;</span><span class="RktVal">#\-</span><span class="RktPn">)</span></td></tr><tr><td><p><span class="RktRes">"poly-mor-phism"</span></p></td></tr><tr><td><span class="stt">&gt; </span><span class="RktPn">(</span><span class="RktSym"><a href="index.html#%28def._%28%28lib._hyphenate%2Fmain..rkt%29._hyphenate%29%29" class="RktValLink" data-pltdoc="x">hyphenate</a></span><span class="hspace">&nbsp;</span><span class="RktVal">"polymorphism"</span><span class="hspace">&nbsp;</span><span class="RktVal">#\-</span><span class="hspace">&nbsp;</span><span class="RktPn">#:exceptions</span><span class="hspace">&nbsp;</span><span class="RktVal">'</span><span class="RktVal">(</span><span class="RktVal">"polymo-rphism"</span><span class="RktVal">)</span><span class="RktPn">)</span></td></tr><tr><td><p><span class="RktRes">"polymo-rphism"</span></p></td></tr><tr><td><span class="stt">&gt; </span><span class="RktPn">(</span><span class="RktSym"><a href="index.html#%28def._%28%28lib._hyphenate%2Fmain..rkt%29._hyphenate%29%29" class="RktValLink" data-pltdoc="x">hyphenate</a></span><span class="hspace">&nbsp;</span><span class="RktVal">"polymorphism"</span><span class="hspace">&nbsp;</span><span class="RktVal">#\-</span><span class="hspace">&nbsp;</span><span class="RktPn">#:exceptions</span><span class="hspace">&nbsp;</span><span class="RktVal">'</span><span class="RktVal">(</span><span class="RktVal">"polymorphism"</span><span class="RktVal">)</span><span class="RktPn">)</span></td></tr><tr><td><p><span class="RktRes">"polymorphism"</span></p></td></tr></table></blockquote></td></tr></table></p><p>Knuth &amp; Liang were sufficiently confident about their algorithm that they originally released it with only 14 exceptions: <span style="font-style: italic">associate[s], declination, obligatory, philanthropic, present[s], project[s], reciprocity, recognizance, reformation, retribution</span>, and <span style="font-style: italic">table</span>. Admirable bravado, but it&rsquo;s not hard to discover others that need adjustment.</p><p><table cellspacing="0" cellpadding="0" class="RktBlk"><tr><td><p>Examples:</p></td></tr><tr><td><blockquote class="SCodeFlow"><table cellspacing="0" cellpadding="0" class="RktBlk"><tr><td><span class="stt">&gt; </span><span class="RktPn">(</span><span class="RktSym"><a href="index.html#%28def._%28%28lib._hyphenate%2Fmain..rkt%29._hyphenate%29%29" class="RktValLink" data-pltdoc="x">hyphenate</a></span><span class="hspace">&nbsp;</span><span class="RktVal">"wrong: columns signage lawyers"</span><span class="hspace">&nbsp;</span><span class="RktVal">#\-</span><span class="RktPn">)</span></td></tr><tr><td><p><span class="RktRes">"wrong: columns sig-nage lawyers"</span></p></td></tr><tr><td><table cellspacing="0" cellpadding="0" class="RktBlk"><tr><td><span class="stt">&gt; </span><span class="RktPn">(</span><span class="RktSym"><a href="index.html#%28def._%28%28lib._hyphenate%2Fmain..rkt%29._hyphenate%29%29" class="RktValLink" data-pltdoc="x">hyphenate</a></span><span class="hspace">&nbsp;</span><span class="RktVal">"right: columns signage lawyers"</span><span class="hspace">&nbsp;</span><span class="RktVal">#\-</span></td></tr><tr><td><span class="hspace">&nbsp;&nbsp;</span><span class="RktPn">#:exceptions</span><span class="hspace">&nbsp;</span><span class="RktVal">'</span><span class="RktVal">(</span><span class="RktVal">"col-umns"</span><span class="hspace">&nbsp;</span><span class="RktVal">"sign-age"</span><span class="hspace">&nbsp;</span><span class="RktVal">"law-yers"</span><span class="RktVal">)</span><span class="RktPn">)</span></td></tr></table></td></tr><tr><td><p><span class="RktRes">"right: col-umns sign-age law-yers"</span></p></td></tr></table></blockquote></td></tr></table></p><p>The Knuth&#8211;Liang algorithm is designed to omit legitimate hyphenation points (i.e., generate false negatives) more often than it creates erroneous hyphenation points (i.e., false positives). This is good policy. Perfect hyphenation &#8212; that is, hyphenation that represents an exact linguistic syllabification of each word &#8212;&#160;is superfluous for typesetting. Hyphenation simply seeks to mark possible line-break and page-break locations for whatever layout engine is drawing the text. The ultimate goal is to permit more even text flow. Like horseshoes and hand grenades, close is good enough. And a word wrongly hyphenated is more likely to be noticed by a reader than a word inefficiently hyphenated.</p><p>For this reason, certain words can&rsquo;t be hyphenated algorithmically, because the correct hyphenation depends on meaning, not merely on spelling. For instance:</p><p><table cellspacing="0" cellpadding="0" class="RktBlk"><tr><td><p>Example:</p></td></tr><tr><td><blockquote class="SCodeFlow"><table cellspacing="0" cellpadding="0" class="RktBlk"><tr><td><span class="stt">&gt; </span><span class="RktPn">(</span><span class="RktSym"><a href="index.html#%28def._%28%28lib._hyphenate%2Fmain..rkt%29._hyphenate%29%29" class="RktValLink" data-pltdoc="x">hyphenate</a></span><span class="hspace">&nbsp;</span><span class="RktVal">"adder"</span><span class="RktPn">)</span></td></tr><tr><td><p><span class="RktRes">"adder"</span></p></td></tr></table></blockquote></td></tr></table></p><p>This is the right result. If you used <span style="font-style: italic">adder</span> to mean the machine, it would be hyphenated <span style="font-style: italic">add-er</span>; if you meant the snake, it would be <span style="font-style: italic">ad-der</span>. Better to avoid hyphenation than to hyphenate incorrectly.</p><p>You can send HTML-style X-expressions through <span class="RktSym"><a href="index.html#%28def._%28%28lib._hyphenate%2Fmain..rkt%29._hyphenate%29%29" class="RktValLink" data-pltdoc="x">hyphenate</a></span>. It will recursively hyphenate the text strings, while leaving the tags and attributes alone, as well as non-hyphenatable material (like character entities and CDATA).</p><p><table cellspacing="0" cellpadding="0" class="RktBlk"><tr><td><p>Examples:</p></td></tr><tr><td><blockquote class="SCodeFlow"><table cellspacing="0" cellpadding="0" class="RktBlk"><tr><td><span class="stt">&gt; </span><span class="RktPn">(</span><span class="RktSym"><a href="index.html#%28def._%28%28lib._hyphenate%2Fmain..rkt%29._hyphenate%29%29" class="RktValLink" data-pltdoc="x">hyphenate</a></span><span class="hspace">&nbsp;</span><span class="RktVal">'</span><span class="RktVal">(</span><span class="RktVal">p</span><span class="hspace">&nbsp;</span><span class="RktVal">"strangely"</span><span class="hspace">&nbsp;</span><span class="RktVal">(</span><span class="RktVal">em</span><span class="hspace">&nbsp;</span><span class="RktVal">"formatted"</span><span class="hspace">&nbsp;</span><span class="RktVal">(</span><span class="RktVal">strong</span><span class="hspace">&nbsp;</span><span class="RktVal">"snowmen"</span><span class="RktVal">)</span><span class="RktVal">)</span><span class="RktVal">)</span><span class="hspace">&nbsp;</span><span class="RktVal">#\-</span><span class="RktPn">)</span></td></tr><tr><td><p><span class="RktRes">'(p "strange-ly" (em "for-mat-ted" (strong "snow-men")))</span></p></td></tr><tr><td><span class="stt">&gt; </span><span class="RktPn">(</span><span class="RktSym"><a href="index.html#%28def._%28%28lib._hyphenate%2Fmain..rkt%29._hyphenate%29%29" class="RktValLink" data-pltdoc="x">hyphenate</a></span><span class="hspace">&nbsp;</span><span class="RktVal">'</span><span class="RktVal">(</span><span class="RktVal">headline</span><span class="hspace">&nbsp;</span><span class="RktVal">[</span><span class="RktVal">[</span><span class="RktVal">class</span><span class="hspace">&nbsp;</span><span class="RktVal">"headline"</span><span class="RktVal">]</span><span class="RktVal">]</span><span class="hspace">&nbsp;</span><span class="RktVal">"headline"</span><span class="RktVal">)</span><span class="hspace">&nbsp;</span><span class="RktVal">#\-</span><span class="RktPn">)</span></td></tr><tr><td><p><span class="RktRes">'(headline ((class "headline")) "head-line")</span></p></td></tr><tr><td><span class="stt">&gt; </span><span class="RktPn">(</span><span class="RktSym"><a href="index.html#%28def._%28%28lib._hyphenate%2Fmain..rkt%29._hyphenate%29%29" class="RktValLink" data-pltdoc="x">hyphenate</a></span><span class="hspace">&nbsp;</span><span class="RktVal">'</span><span class="RktVal">(</span><span class="RktVal">div</span><span class="hspace">&nbsp;</span><span class="RktVal">"The (span epsilon) entity:"</span><span class="hspace">&nbsp;</span><span class="RktVal">epsilon</span><span class="RktVal">)</span><span class="hspace">&nbsp;</span><span class="RktVal">#\-</span><span class="RktPn">)</span></td></tr><tr><td><p><span class="RktRes">'(div "The (span ep-silon) en-ti-ty:" epsilon)</span></p></td></tr></table></blockquote></td></tr></table></p><p>Don&rsquo;t send raw HTML or XML through <span class="RktSym"><a href="index.html#%28def._%28%28lib._hyphenate%2Fmain..rkt%29._hyphenate%29%29" class="RktValLink" data-pltdoc="x">hyphenate</a></span>. It can&rsquo;t distinguish tags and attributes from textual content, so everything will be hyphenated, thus goofing up your file. But you can easily convert your HTML or XML to an X-expression, hyphenate it, and then convert back.</p><p><table cellspacing="0" cellpadding="0" class="RktBlk"><tr><td><p>Examples:</p></td></tr><tr><td><blockquote class="SCodeFlow"><table cellspacing="0" cellpadding="0" class="RktBlk"><tr><td><span class="stt">&gt; </span><span class="RktPn">(</span><span class="RktSym"><a href="http://docs.racket-lang.org/reference/define.html#%28form._%28%28lib._racket%2Fprivate%2Fbase..rkt%29._define%29%29" class="RktStxLink" data-pltdoc="x">define</a></span><span class="hspace">&nbsp;</span><span class="RktSym">html</span><span class="hspace">&nbsp;</span><span class="RktVal">"&lt;body style=\"background: yellow\"&gt;Hello&lt;/body&gt;"</span><span class="RktPn">)</span></td></tr><tr><td><table cellspacing="0" cellpadding="0"><tr><td></td></tr></table></td></tr><tr><td><span class="stt">&gt; </span><span class="RktPn">(</span><span class="RktSym"><a href="index.html#%28def._%28%28lib._hyphenate%2Fmain..rkt%29._hyphenate%29%29" class="RktValLink" data-pltdoc="x">hyphenate</a></span><span class="hspace">&nbsp;</span><span class="RktSym">html</span><span class="hspace">&nbsp;</span><span class="RktVal">#\-</span><span class="RktPn">)</span></td></tr><tr><td><p><span class="RktRes">"&lt;body style=\"back-ground: yel-low\"&gt;Hel-lo&lt;/body&gt;"</span></p></td></tr><tr><td><span class="stt">&gt; </span><span class="RktPn">(</span><span class="RktSym"><a href="http://docs.racket-lang.org/xml/index.html#%28def._%28%28lib._xml%2Fmain..rkt%29._xexpr-~3estring%29%29" class="RktValLink" data-pltdoc="x">xexpr-&gt;string</a></span><span class="hspace">&nbsp;</span><span class="RktPn">(</span><span class="RktSym"><a href="index.html#%28def._%28%28lib._hyphenate%2Fmain..rkt%29._hyphenate%29%29" class="RktValLink" data-pltdoc="x">hyphenate</a></span><span class="hspace">&nbsp;</span><span class="RktPn">(</span><span class="RktSym"><a href="http://docs.racket-lang.org/xml/index.html#%28def._%28%28lib._xml%2Fmain..rkt%29._string-~3exexpr%29%29" class="RktValLink" data-pltdoc="x">string-&gt;xexpr</a></span><span class="hspace">&nbsp;</span><span class="RktSym">html</span><span class="RktPn">)</span><span class="hspace">&nbsp;</span><span class="RktVal">#\-</span><span class="RktPn">)</span><span class="RktPn">)</span></td></tr><tr><td><p><span class="RktRes">"&lt;body style=\"background: yellow\"&gt;Hel-lo&lt;/body&gt;"</span></p></td></tr></table></blockquote></td></tr></table></p><p>If you&rsquo;re working with HTML, be careful not to include any <span class="RktSym">&lt;script&gt;</span><span class="RktMeta"></span> or <span class="RktSym">&lt;style&gt;</span><span class="RktMeta"></span> blocks, which contain non-hyphenatable data. You can protect that data by using the <span class="RktPn">#:omit-txexpr</span> keyword to specify a <span class="RktVar">txexpr-test</span>. The test will be applied to all tagged X-expressions (see <span class="RktSym"><a href="http://docs.racket-lang.org/txexpr/index.html#%28def._%28%28lib._txexpr%2Fmain..rkt%29._txexpr~3f%29%29" class="RktValLink" data-pltdoc="x">txexpr?</a></span>). When <span class="RktVar">txexpr-test</span> evaluates to true, the item will be skipped.</p><p><table cellspacing="0" cellpadding="0" class="RktBlk"><tr><td><p>Examples:</p></td></tr><tr><td><blockquote class="SCodeFlow"><table cellspacing="0" cellpadding="0" class="RktBlk"><tr><td><span class="stt">&gt; </span><span class="RktPn">(</span><span class="RktSym"><a href="index.html#%28def._%28%28lib._hyphenate%2Fmain..rkt%29._hyphenate%29%29" class="RktValLink" data-pltdoc="x">hyphenate</a></span><span class="hspace">&nbsp;</span><span class="RktVal">'</span><span class="RktVal">(</span><span class="RktVal">body</span><span class="hspace">&nbsp;</span><span class="RktVal">"processing"</span><span class="hspace">&nbsp;</span><span class="RktVal">(</span><span class="RktVal">script</span><span class="hspace">&nbsp;</span><span class="RktVal">"no processing"</span><span class="RktVal">)</span><span class="RktVal">)</span><span class="hspace">&nbsp;</span><span class="RktVal">#\-</span><span class="RktPn">)</span></td></tr><tr><td><p><span class="RktRes">'(body "pro-cess-ing" (script "no pro-cess-ing"))</span></p></td></tr><tr><td><table cellspacing="0" cellpadding="0" class="RktBlk"><tr><td><span class="stt">&gt; </span><span class="RktPn">(</span><span class="RktSym"><a href="index.html#%28def._%28%28lib._hyphenate%2Fmain..rkt%29._hyphenate%29%29" class="RktValLink" data-pltdoc="x">hyphenate</a></span><span class="hspace">&nbsp;</span><span class="RktVal">'</span><span class="RktVal">(</span><span class="RktVal">body</span><span class="hspace">&nbsp;</span><span class="RktVal">"processing"</span><span class="hspace">&nbsp;</span><span class="RktVal">(</span><span class="RktVal">script</span><span class="hspace">&nbsp;</span><span class="RktVal">"no processing"</span><span class="RktVal">)</span><span class="RktVal">)</span><span class="hspace">&nbsp;</span><span class="RktVal">#\-</span></td></tr><tr><td><span class="hspace">&nbsp;&nbsp;</span><span class="RktPn">#:omit-txexpr</span><span class="hspace">&nbsp;</span><span class="RktPn">(</span><span class="RktSym"><a href="http://docs.racket-lang.org/reference/lambda.html#%28form._%28%28lib._racket%2Fprivate%2Fbase..rkt%29._~ce~bb%29%29" class="RktStxLink" data-pltdoc="x">&#955;</a></span><span class="RktPn">(</span><span class="RktSym">tx</span><span class="RktPn">)</span><span class="hspace">&nbsp;</span><span class="RktPn">(</span><span class="RktSym"><a href="http://docs.racket-lang.org/reference/pairs.html#%28def._%28%28lib._racket%2Fprivate%2Fbase..rkt%29._member%29%29" class="RktValLink" data-pltdoc="x">member</a></span><span class="hspace">&nbsp;</span><span class="RktPn">(</span><span class="RktSym"><a href="http://docs.racket-lang.org/txexpr/index.html#%28def._%28%28lib._txexpr%2Fmain..rkt%29._get-tag%29%29" class="RktValLink" data-pltdoc="x">get-tag</a></span><span class="hspace">&nbsp;</span><span class="RktSym">tx</span><span class="RktPn">)</span><span class="hspace">&nbsp;</span><span class="RktVal">'</span><span class="RktVal">(</span><span class="RktVal">script</span><span class="RktVal">)</span><span class="RktPn">)</span><span class="RktPn">)</span><span class="RktPn">)</span></td></tr></table></td></tr><tr><td><p><span class="RktRes">'(body "pro-cess-ing" (script "no processing"))</span></p></td></tr></table></blockquote></td></tr></table></p><p>You can also use <span class="RktPn">#:omit-txexpr</span> to omit tagged X-expressions with particular attributes. This can be used to selectively suppress hyphenation at the markup level.</p><p><table cellspacing="0" cellpadding="0" class="RktBlk"><tr><td><p>Examples:</p></td></tr><tr><td><blockquote class="SCodeFlow"><table cellspacing="0" cellpadding="0" class="RktBlk"><tr><td><span class="stt">&gt; </span><span class="RktPn">(</span><span class="RktSym"><a href="index.html#%28def._%28%28lib._hyphenate%2Fmain..rkt%29._hyphenate%29%29" class="RktValLink" data-pltdoc="x">hyphenate</a></span><span class="hspace">&nbsp;</span><span class="RktVal">'</span><span class="RktVal">(</span><span class="RktVal">p</span><span class="hspace">&nbsp;</span><span class="RktVal">(</span><span class="RktVal">span</span><span class="hspace">&nbsp;</span><span class="RktVal">"processing"</span><span class="RktVal">)</span><span class="hspace">&nbsp;</span><span class="RktVal">(</span><span class="RktVal">span</span><span class="hspace">&nbsp;</span><span class="RktVal">[</span><span class="RktVal">[</span><span class="RktVal">klh</span><span class="hspace">&nbsp;</span><span class="RktVal">"no"</span><span class="RktVal">]</span><span class="RktVal">]</span><span class="hspace">&nbsp;</span><span class="RktVal">"processing"</span><span class="RktVal">)</span><span class="RktVal">)</span><span class="hspace">&nbsp;</span><span class="RktVal">#\-</span><span class="RktPn">)</span></td></tr><tr><td><p><span class="RktRes">'(p (span "pro-cess-ing") (span ((klh "no")) "pro-cess-ing"))</span></p></td></tr><tr><td><table cellspacing="0" cellpadding="0" class="RktBlk"><tr><td><span class="stt">&gt; </span><span class="RktPn">(</span><span class="RktSym"><a href="index.html#%28def._%28%28lib._hyphenate%2Fmain..rkt%29._hyphenate%29%29" class="RktValLink" data-pltdoc="x">hyphenate</a></span><span class="hspace">&nbsp;</span><span class="RktVal">'</span><span class="RktVal">(</span><span class="RktVal">p</span><span class="hspace">&nbsp;</span><span class="RktVal">(</span><span class="RktVal">span</span><span class="hspace">&nbsp;</span><span class="RktVal">"processing"</span><span class="RktVal">)</span><span class="hspace">&nbsp;</span><span class="RktVal">(</span><span class="RktVal">span</span><span class="hspace">&nbsp;</span><span class="RktVal">[</span><span class="RktVal">[</span><span class="RktVal">klh</span><span class="hspace">&nbsp;</span><span class="RktVal">"no"</span><span class="RktVal">]</span><span class="RktVal">]</span><span class="hspace">&nbsp;</span><span class="RktVal">"processing"</span><span class="RktVal">)</span><span class="RktVal">)</span><span class="hspace">&nbsp;</span><span class="RktVal">#\-</span></td></tr><tr><td><span class="hspace">&nbsp;&nbsp;</span><span class="RktPn">#:omit-txexpr</span><span class="hspace">&nbsp;</span><span class="RktPn">(</span><span class="RktSym"><a href="http://docs.racket-lang.org/reference/lambda.html#%28form._%28%28lib._racket%2Fprivate%2Fbase..rkt%29._~ce~bb%29%29" class="RktStxLink" data-pltdoc="x">&#955;</a></span><span class="RktPn">(</span><span class="RktSym">tx</span><span class="RktPn">)</span><span class="hspace">&nbsp;</span><span class="RktPn">(</span><span class="RktSym"><a href="http://docs.racket-lang.org/reference/if.html#%28form._%28%28lib._racket%2Fprivate%2Fletstx-scheme..rkt%29._and%29%29" class="RktStxLink" data-pltdoc="x">and</a></span><span class="hspace">&nbsp;</span><span class="RktPn">(</span><span class="RktSym"><a href="http://docs.racket-lang.org/txexpr/index.html#%28def._%28%28lib._txexpr%2Fmain..rkt%29._attrs-have-key~3f%29%29" class="RktValLink" data-pltdoc="x">attrs-have-key?</a></span><span class="hspace">&nbsp;</span><span class="RktSym">tx</span><span class="hspace">&nbsp;</span><span class="RktVal">'</span><span class="RktVal">klh</span><span class="RktPn">)</span></td></tr><tr><td><span class="hspace">&nbsp;&nbsp;</span><span class="RktPn">(</span><span class="RktSym"><a href="http://docs.racket-lang.org/reference/booleans.html#%28def._%28%28quote._~23~25kernel%29._equal~3f%29%29" class="RktValLink" data-pltdoc="x">equal?</a></span><span class="hspace">&nbsp;</span><span class="RktPn">(</span><span class="RktSym"><a href="http://docs.racket-lang.org/txexpr/index.html#%28def._%28%28lib._txexpr%2Fmain..rkt%29._attr-ref%29%29" class="RktValLink" data-pltdoc="x">attr-ref</a></span><span class="hspace">&nbsp;</span><span class="RktSym">tx</span><span class="hspace">&nbsp;</span><span class="RktVal">'</span><span class="RktVal">klh</span><span class="RktPn">)</span><span class="hspace">&nbsp;</span><span class="RktVal">"no"</span><span class="RktPn">)</span><span class="RktPn">)</span><span class="RktPn">)</span><span class="RktPn">)</span></td></tr></table></td></tr><tr><td><p><span class="RktRes">'(p (span "pro-cess-ing") (span ((klh "no")) "processing"))</span></p></td></tr></table></blockquote></td></tr></table></p><p>Similarly, you can use the <span class="RktPn">#:omit-word</span> argument to avoid words that match <span class="RktVar">word-test</span>. Convenient if you want to prevent hyphenation of certain sets of words, like proper names:</p><p><table cellspacing="0" cellpadding="0" class="RktBlk"><tr><td><p>Examples:</p></td></tr><tr><td><blockquote class="SCodeFlow"><table cellspacing="0" cellpadding="0" class="RktBlk"><tr><td><span class="stt">&gt; </span><span class="RktPn">(</span><span class="RktSym"><a href="index.html#%28def._%28%28lib._hyphenate%2Fmain..rkt%29._hyphenate%29%29" class="RktValLink" data-pltdoc="x">hyphenate</a></span><span class="hspace">&nbsp;</span><span class="RktVal">"Brennan Huff likes fancy sauce"</span><span class="hspace">&nbsp;</span><span class="RktVal">#\-</span><span class="RktPn">)</span></td></tr><tr><td><p><span class="RktRes">"Bren-nan Huff likes fan-cy sauce"</span></p></td></tr><tr><td><table cellspacing="0" cellpadding="0" class="RktBlk"><tr><td><span class="stt">&gt; </span><span class="RktPn">(</span><span class="RktSym"><a href="http://docs.racket-lang.org/reference/define.html#%28form._%28%28lib._racket%2Fprivate%2Fbase..rkt%29._define%29%29" class="RktStxLink" data-pltdoc="x">define</a></span><span class="hspace">&nbsp;</span><span class="RktSym">capitalized?</span><span class="hspace">&nbsp;</span><span class="RktPn">(</span><span class="RktSym"><a href="http://docs.racket-lang.org/reference/lambda.html#%28form._%28%28lib._racket%2Fprivate%2Fbase..rkt%29._~ce~bb%29%29" class="RktStxLink" data-pltdoc="x">&#955;</a></span><span class="RktPn">(</span><span class="RktSym">word</span><span class="RktPn">)</span><span class="hspace">&nbsp;</span><span class="RktPn">(</span><span class="RktSym"><a href="http://docs.racket-lang.org/reference/let.html#%28form._%28%28lib._racket%2Fprivate%2Fletstx-scheme..rkt%29._let%29%29" class="RktStxLink" data-pltdoc="x">let</a></span><span class="hspace">&nbsp;</span><span class="RktPn">(</span><span class="RktPn">[</span><span class="RktSym">letter</span><span class="hspace">&nbsp;</span><span class="RktPn">(</span><span class="RktSym"><a href="http://docs.racket-lang.org/reference/strings.html#%28def._%28%28quote._~23~25kernel%29._substring%29%29" class="RktValLink" data-pltdoc="x">substring</a></span><span class="hspace">&nbsp;</span><span class="RktSym">word</span><span class="hspace">&nbsp;</span><span class="RktVal">0</span><span class="hspace">&nbsp;</span><span class="RktVal">1</span><span class="RktPn">)</span><span class="RktPn">]</span><span class="RktPn">)</span></td></tr><tr><td><span class="hspace">&nbsp;&nbsp;</span><span class="RktPn">(</span><span class="RktSym"><a href="http://docs.racket-lang.org/reference/booleans.html#%28def._%28%28quote._~23~25kernel%29._equal~3f%29%29" class="RktValLink" data-pltdoc="x">equal?</a></span><span class="hspace">&nbsp;</span><span class="RktSym">letter</span><span class="hspace">&nbsp;</span><span class="RktPn">(</span><span class="RktSym"><a href="http://docs.racket-lang.org/reference/strings.html#%28def._%28%28quote._~23~25kernel%29._string-upcase%29%29" class="RktValLink" data-pltdoc="x">string-upcase</a></span><span class="hspace">&nbsp;</span><span class="RktSym">letter</span><span class="RktPn">)</span><span class="RktPn">)</span><span class="RktPn">)</span><span class="RktPn">)</span><span class="RktPn">)</span></td></tr></table></td></tr><tr><td><table cellspacing="0" cellpadding="0"><tr><td></td></tr></table></td></tr><tr><td><span class="stt">&gt; </span><span class="RktPn">(</span><span class="RktSym"><a href="index.html#%28def._%28%28lib._hyphenate%2Fmain..rkt%29._hyphenate%29%29" class="RktValLink" data-pltdoc="x">hyphenate</a></span><span class="hspace">&nbsp;</span><span class="RktVal">"Brennan Huff likes fancy sauce"</span><span class="hspace">&nbsp;</span><span class="RktPn">#:omit-word</span><span class="hspace">&nbsp;</span><span class="RktSym">capitalized?</span><span class="hspace">&nbsp;</span><span class="RktVal">#\-</span><span class="RktPn">)</span></td></tr><tr><td><p><span class="RktRes">"Brennan Huff likes fan-cy sauce"</span></p></td></tr></table></blockquote></td></tr></table></p><p>Sometimes you need <span class="RktPn">#:omit-word</span> to prevent unintended consequences. For instance, if you&rsquo;re using ligatures in CSS, certain groups of characters (fi, fl, ffi, et al.) will be replaced by a single glyph. That looks snazzy, but adding soft hyphens between any of these pairs will defeat the ligature substitution, creating inconsistent results. With <span class="RktPn">#:omit-word</span>, you can skip these words:</p><blockquote class="refpara"><blockquote class="refcolumn"><blockquote class="refcontent"><p>&ldquo;Wouldn&rsquo;t it be better to exclude certain pairs of letters rather than whole words?&rdquo; Yes. But for now, that&rsquo;s not supported.</p></blockquote></blockquote></blockquote><p><table cellspacing="0" cellpadding="0" class="RktBlk"><tr><td><p>Examples:</p></td></tr><tr><td><blockquote class="SCodeFlow"><table cellspacing="0" cellpadding="0" class="RktBlk"><tr><td><span class="stt">&gt; </span><span class="RktPn">(</span><span class="RktSym"><a href="index.html#%28def._%28%28lib._hyphenate%2Fmain..rkt%29._hyphenate%29%29" class="RktValLink" data-pltdoc="x">hyphenate</a></span><span class="hspace">&nbsp;</span><span class="RktVal">"Hufflepuff golfing final on Tuesday"</span><span class="hspace">&nbsp;</span><span class="RktVal">#\-</span><span class="RktPn">)</span></td></tr><tr><td><p><span class="RktRes">"Huf-flepuff golf-ing fi-nal on Tues-day"</span></p></td></tr><tr><td><table cellspacing="0" cellpadding="0" class="RktBlk"><tr><td><span class="stt">&gt; </span><span class="RktPn">(</span><span class="RktSym"><a href="http://docs.racket-lang.org/reference/define.html#%28form._%28%28lib._racket%2Fprivate%2Fbase..rkt%29._define%29%29" class="RktStxLink" data-pltdoc="x">define</a></span><span class="hspace">&nbsp;</span><span class="RktPn">(</span><span class="RktSym">ligs?</span><span class="hspace">&nbsp;</span><span class="RktSym">word</span><span class="RktPn">)</span></td></tr><tr><td><span class="hspace">&nbsp;&nbsp;</span><span class="hspace">&nbsp;&nbsp;</span><span class="RktPn">(</span><span class="RktSym"><a href="http://docs.racket-lang.org/reference/pairs.html#%28def._%28%28lib._racket%2Fprivate%2Fmap..rkt%29._ormap%29%29" class="RktValLink" data-pltdoc="x">ormap</a></span><span class="hspace">&nbsp;</span><span class="RktPn">(</span><span class="RktSym"><a href="http://docs.racket-lang.org/reference/lambda.html#%28form._%28%28lib._racket%2Fprivate%2Fbase..rkt%29._~ce~bb%29%29" class="RktStxLink" data-pltdoc="x">&#955;</a></span><span class="RktPn">(</span><span class="RktSym">lig</span><span class="RktPn">)</span><span class="hspace">&nbsp;</span><span class="RktPn">(</span><span class="RktSym"><a href="http://docs.racket-lang.org/reference/regexp.html#%28def._%28%28quote._~23~25kernel%29._regexp-match%29%29" class="RktValLink" data-pltdoc="x">regexp-match</a></span><span class="hspace">&nbsp;</span><span class="RktSym">lig</span><span class="hspace">&nbsp;</span><span class="RktSym">word</span><span class="RktPn">)</span><span class="RktPn">)</span></td></tr><tr><td><span class="hspace">&nbsp;&nbsp;</span><span class="hspace">&nbsp;&nbsp;</span><span class="RktVal">'</span><span class="RktVal">(</span><span class="RktVal">"ff"</span><span class="hspace">&nbsp;</span><span class="RktVal">"fi"</span><span class="hspace">&nbsp;</span><span class="RktVal">"fl"</span><span class="hspace">&nbsp;</span><span class="RktVal">"ffi"</span><span class="hspace">&nbsp;</span><span class="RktVal">"ffl"</span><span class="RktVal">)</span><span class="RktPn">)</span><span class="RktPn">)</span></td></tr></table></td></tr><tr><td><table cellspacing="0" cellpadding="0"><tr><td></td></tr></table></td></tr><tr><td><span class="stt">&gt; </span><span class="RktPn">(</span><span class="RktSym"><a href="index.html#%28def._%28%28lib._hyphenate%2Fmain..rkt%29._hyphenate%29%29" class="RktValLink" data-pltdoc="x">hyphenate</a></span><span class="hspace">&nbsp;</span><span class="RktVal">"Hufflepuff golfing final on Tuesday"</span><span class="hspace">&nbsp;</span><span class="RktPn">#:omit-word</span><span class="hspace">&nbsp;</span><span class="RktSym">ligs?</span><span class="hspace">&nbsp;</span><span class="RktVal">#\-</span><span class="RktPn">)</span></td></tr><tr><td><p><span class="RktRes">"Hufflepuff golfing final on Tues-day"</span></p></td></tr></table></blockquote></td></tr></table></p><p><div class="SIntrapara"><blockquote class="SVInsetFlow"><table cellspacing="0" cellpadding="0" class="boxed RBoxed"><tr><td><blockquote class="SubFlow"><div class="RBackgroundLabel SIEHidden"><div class="RBackgroundLabelInner"><p>procedure</p></div></div><table cellspacing="0" cellpadding="0" class="prototype RForeground"><tr><td><span class="RktPn">(</span><a name="(def._((lib._hyphenate/main..rkt)._unhyphenate))"></a><span title="Provided from: hyphenate, (submod hyphenate safe) | Package: hyphenate"><span class="RktSym"><a href="index.html#%28def._%28%28lib._hyphenate%2Fmain..rkt%29._unhyphenate%29%29" class="RktValDef RktValLink" data-pltdoc="x">unhyphenate</a></span></span></td><td><span class="hspace">&nbsp;</span></td><td><span class="RktVar">xexpr</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">#:omit-word</span><span class="hspace">&nbsp;</span><span class="RktVar">word-test</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">#:omit-string</span><span class="hspace">&nbsp;</span><span class="RktVar">string-test</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">#:omit-txexpr</span><span class="hspace">&nbsp;</span><span class="RktVar">txexpr-test</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"><a href="http://docs.racket-lang.org/xml/index.html#%28def._%28%28lib._xml%2Fprivate%2Fxexpr-core..rkt%29._xexpr%2Fc%29%29" class="RktValLink" data-pltdoc="x">xexpr/c</a></span></td></tr></table></blockquote></td></tr><tr><td><span class="hspace">&nbsp;&nbsp;</span><span class="RktVar">xexpr</span><span class="hspace">&nbsp;</span>:<span class="hspace">&nbsp;</span><span class="RktSym"><a href="http://docs.racket-lang.org/xml/index.html#%28def._%28%28lib._xml%2Fprivate%2Fxexpr-core..rkt%29._xexpr%2Fc%29%29" class="RktValLink" data-pltdoc="x">xexpr/c</a></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"><a href="http://docs.racket-lang.org/reference/data-structure-contracts.html#%28def._%28%28lib._racket%2Fcontract%2Fbase..rkt%29._or%2Fc%29%29" class="RktValLink" data-pltdoc="x">or/c</a></span><span class="hspace">&nbsp;</span><span class="RktSym"><a href="http://docs.racket-lang.org/reference/characters.html#%28def._%28%28quote._~23~25kernel%29._char~3f%29%29" class="RktValLink" data-pltdoc="x">char?</a></span><span class="hspace">&nbsp;</span><span class="RktSym"><a href="http://docs.racket-lang.org/reference/strings.html#%28def._%28%28quote._~23~25kernel%29._string~3f%29%29" class="RktValLink" data-pltdoc="x">string?</a></span><span class="RktPn">)</span><span class="hspace">&nbsp;</span>=<span class="hspace">&nbsp;</span><span class="RktPn">(</span><span class="RktSym"><a href="http://docs.racket-lang.org/reference/characters.html#%28def._%28%28quote._~23~25kernel%29._integer-~3echar%29%29" class="RktValLink" data-pltdoc="x">integer-&gt;char</a></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">word-test</span><span class="hspace">&nbsp;</span>:<span class="hspace">&nbsp;</span><span class="RktPn">(</span><span class="RktSym"><a href="http://docs.racket-lang.org/reference/strings.html#%28def._%28%28quote._~23~25kernel%29._string~3f%29%29" class="RktValLink" data-pltdoc="x">string?</a></span><span class="hspace">&nbsp;</span><span class="RktPn">. </span><span class="RktSym"><a href="http://docs.racket-lang.org/reference/function-contracts.html#%28form._%28%28lib._racket%2Fcontract%2Fbase..rkt%29._-~3e%29%29" class="RktStxLink" data-pltdoc="x"><span class="nobreak">-&gt;</span></a></span><span class="RktPn"> .</span><span class="hspace">&nbsp;</span><span class="RktSym"><a href="http://docs.racket-lang.org/reference/data-structure-contracts.html#%28def._%28%28lib._racket%2Fcontract%2Fprivate%2Fmisc..rkt%29._any%2Fc%29%29" class="RktValLink" data-pltdoc="x">any/c</a></span><span class="RktPn">)</span><span class="hspace">&nbsp;</span>=<span class="hspace">&nbsp;</span><span class="RktPn">(</span><span class="RktSym"><a href="http://docs.racket-lang.org/reference/lambda.html#%28form._%28%28lib._racket%2Fprivate%2Fbase..rkt%29._~ce~bb%29%29" class="RktStxLink" data-pltdoc="x">&#955;</a></span><span class="RktPn">(</span><span class="RktSym">x</span><span class="RktPn">)</span><span class="hspace">&nbsp;</span><span class="RktVal">#f</span><span class="RktPn">)</span></td></tr><tr><td><span class="hspace">&nbsp;&nbsp;</span><span class="RktVar">string-test</span><span class="hspace">&nbsp;</span>:<span class="hspace">&nbsp;</span><span class="RktPn">(</span><span class="RktSym"><a href="http://docs.racket-lang.org/reference/strings.html#%28def._%28%28quote._~23~25kernel%29._string~3f%29%29" class="RktValLink" data-pltdoc="x">string?</a></span><span class="hspace">&nbsp;</span><span class="RktPn">. </span><span class="RktSym"><a href="http://docs.racket-lang.org/reference/function-contracts.html#%28form._%28%28lib._racket%2Fcontract%2Fbase..rkt%29._-~3e%29%29" class="RktStxLink" data-pltdoc="x"><span class="nobreak">-&gt;</span></a></span><span class="RktPn"> .</span><span class="hspace">&nbsp;</span><span class="RktSym"><a href="http://docs.racket-lang.org/reference/data-structure-contracts.html#%28def._%28%28lib._racket%2Fcontract%2Fprivate%2Fmisc..rkt%29._any%2Fc%29%29" class="RktValLink" data-pltdoc="x">any/c</a></span><span class="RktPn">)</span><span class="hspace">&nbsp;</span>=<span class="hspace">&nbsp;</span><span class="RktPn">(</span><span class="RktSym"><a href="http://docs.racket-lang.org/reference/lambda.html#%28form._%28%28lib._racket%2Fprivate%2Fbase..rkt%29._~ce~bb%29%29" class="RktStxLink" data-pltdoc="x">&#955;</a></span><span class="RktPn">(</span><span class="RktSym">x</span><span class="RktPn">)</span><span class="hspace">&nbsp;</span><span class="RktVal">#f</span><span class="RktPn">)</span></td></tr><tr><td><span class="hspace">&nbsp;&nbsp;</span><span class="RktVar">txexpr-test</span><span class="hspace">&nbsp;</span>:<span class="hspace">&nbsp;</span><span class="RktPn">(</span><span class="RktSym"><a href="http://docs.racket-lang.org/txexpr/index.html#%28def._%28%28lib._txexpr%2Fmain..rkt%29._txexpr~3f%29%29" class="RktValLink" data-pltdoc="x">txexpr?</a></span><span class="hspace">&nbsp;</span><span class="RktPn">. </span><span class="RktSym"><a href="http://docs.racket-lang.org/reference/function-contracts.html#%28form._%28%28lib._racket%2Fcontract%2Fbase..rkt%29._-~3e%29%29" class="RktStxLink" data-pltdoc="x"><span class="nobreak">-&gt;</span></a></span><span class="RktPn"> .</span><span class="hspace">&nbsp;</span><span class="RktSym"><a href="http://docs.racket-lang.org/reference/data-structure-contracts.html#%28def._%28%28lib._racket%2Fcontract%2Fprivate%2Fmisc..rkt%29._any%2Fc%29%29" class="RktValLink" data-pltdoc="x">any/c</a></span><span class="RktPn">)</span><span class="hspace">&nbsp;</span>=<span class="hspace">&nbsp;</span><span class="RktPn">(</span><span class="RktSym"><a href="http://docs.racket-lang.org/reference/lambda.html#%28form._%28%28lib._racket%2Fprivate%2Fbase..rkt%29._~ce~bb%29%29" class="RktStxLink" data-pltdoc="x">&#955;</a></span><span class="RktPn">(</span><span class="RktSym">x</span><span class="RktPn">)</span><span class="hspace">&nbsp;</span><span class="RktVal">#f</span><span class="RktPn">)</span></td></tr></table></blockquote></div><div class="SIntrapara">Remove <span class="RktVar">joiner</span> from <span class="RktVar">xexpr</span>. Like <span class="RktSym"><a href="index.html#%28def._%28%28lib._hyphenate%2Fmain..rkt%29._hyphenate%29%29" class="RktValLink" data-pltdoc="x">hyphenate</a></span>, it works on nested X-expressions, and offers the same <span class="RktPn">#:omit-</span> options.</div></p><p><table cellspacing="0" cellpadding="0" class="RktBlk"><tr><td><p>Examples:</p></td></tr><tr><td><blockquote class="SCodeFlow"><table cellspacing="0" cellpadding="0" class="RktBlk"><tr><td><span class="stt">&gt; </span><span class="RktPn">(</span><span class="RktSym"><a href="index.html#%28def._%28%28lib._hyphenate%2Fmain..rkt%29._hyphenate%29%29" class="RktValLink" data-pltdoc="x">hyphenate</a></span><span class="hspace">&nbsp;</span><span class="RktVal">'</span><span class="RktVal">(</span><span class="RktVal">p</span><span class="hspace">&nbsp;</span><span class="RktVal">"strangely"</span><span class="hspace">&nbsp;</span><span class="RktVal">(</span><span class="RktVal">em</span><span class="hspace">&nbsp;</span><span class="RktVal">"formatted"</span><span class="hspace">&nbsp;</span><span class="RktVal">(</span><span class="RktVal">strong</span><span class="hspace">&nbsp;</span><span class="RktVal">"snowmen"</span><span class="RktVal">)</span><span class="RktVal">)</span><span class="RktVal">)</span><span class="hspace">&nbsp;</span><span class="RktVal">#\-</span><span class="RktPn">)</span></td></tr><tr><td><p><span class="RktRes">'(p "strange-ly" (em "for-mat-ted" (strong "snow-men")))</span></p></td></tr><tr><td><span class="stt">&gt; </span><span class="RktPn">(</span><span class="RktSym"><a href="index.html#%28def._%28%28lib._hyphenate%2Fmain..rkt%29._unhyphenate%29%29" class="RktValLink" data-pltdoc="x">unhyphenate</a></span><span class="hspace">&nbsp;</span><span class="RktVal">'</span><span class="RktVal">(</span><span class="RktVal">p</span><span class="hspace">&nbsp;</span><span class="RktVal">"strange-ly"</span><span class="hspace">&nbsp;</span><span class="RktVal">(</span><span class="RktVal">em</span><span class="hspace">&nbsp;</span><span class="RktVal">"for-mat-ted"</span><span class="hspace">&nbsp;</span><span class="RktVal">(</span><span class="RktVal">strong</span><span class="hspace">&nbsp;</span><span class="RktVal">"snow-men"</span><span class="RktVal">)</span><span class="RktVal">)</span><span class="RktVal">)</span><span class="hspace">&nbsp;</span><span class="RktVal">#\-</span><span class="RktPn">)</span></td></tr><tr><td><p><span class="RktRes">'(p "strangely" (em "formatted" (strong "snowmen")))</span></p></td></tr></table></blockquote></td></tr></table></p><p>A side effect of using <span class="RktSym"><a href="index.html#%28def._%28%28lib._hyphenate%2Fmain..rkt%29._hyphenate%29%29" class="RktValLink" data-pltdoc="x">hyphenate</a></span> is that soft hyphens (or whatever the <span class="RktVar">joiner</span> is) will be embedded in the output text. If you need to support copying of text, for instance in a GUI application, you&rsquo;ll probably want to strip out the hyphenation before the copied text is moved to the clipboard.</p><p><table cellspacing="0" cellpadding="0" class="RktBlk"><tr><td><p>Examples:</p></td></tr><tr><td><blockquote class="SCodeFlow"><table cellspacing="0" cellpadding="0" class="RktBlk"><tr><td><span class="stt">&gt; </span><span class="RktPn">(</span><span class="RktSym"><a href="index.html#%28def._%28%28lib._hyphenate%2Fmain..rkt%29._hyphenate%29%29" class="RktValLink" data-pltdoc="x">hyphenate</a></span><span class="hspace">&nbsp;</span><span class="RktVal">"ribbon-cutting ceremony"</span><span class="RktPn">)</span></td></tr><tr><td><p><span class="RktRes">"rib\u00ADbon-cut\u00ADting cer\u00ADe\u00ADmo\u00ADny"</span></p></td></tr><tr><td><span class="stt">&gt; </span><span class="RktPn">(</span><span class="RktSym"><a href="index.html#%28def._%28%28lib._hyphenate%2Fmain..rkt%29._unhyphenate%29%29" class="RktValLink" data-pltdoc="x">unhyphenate</a></span><span class="hspace">&nbsp;</span><span class="RktPn">(</span><span class="RktSym"><a href="index.html#%28def._%28%28lib._hyphenate%2Fmain..rkt%29._hyphenate%29%29" class="RktValLink" data-pltdoc="x">hyphenate</a></span><span class="hspace">&nbsp;</span><span class="RktVal">"ribbon-cutting ceremony"</span><span class="RktPn">)</span><span class="RktPn">)</span></td></tr><tr><td><p><span class="RktRes">"ribbon-cutting ceremony"</span></p></td></tr></table></blockquote></td></tr></table></p><p>Use this function cautiously &#8212; if <span class="RktVar">joiner</span> appeared in the original input to <span class="RktSym"><a href="index.html#%28def._%28%28lib._hyphenate%2Fmain..rkt%29._hyphenate%29%29" class="RktValLink" data-pltdoc="x">hyphenate</a></span>, the output from <span class="RktSym"><a href="index.html#%28def._%28%28lib._hyphenate%2Fmain..rkt%29._unhyphenate%29%29" class="RktValLink" data-pltdoc="x">unhyphenate</a></span> won&rsquo;t be the same string.</p><p><table cellspacing="0" cellpadding="0" class="RktBlk"><tr><td><p>Examples:</p></td></tr><tr><td><blockquote class="SCodeFlow"><table cellspacing="0" cellpadding="0" class="RktBlk"><tr><td><span class="stt">&gt; </span><span class="RktPn">(</span><span class="RktSym"><a href="index.html#%28def._%28%28lib._hyphenate%2Fmain..rkt%29._hyphenate%29%29" class="RktValLink" data-pltdoc="x">hyphenate</a></span><span class="hspace">&nbsp;</span><span class="RktVal">"ribbon-cutting ceremony"</span><span class="hspace">&nbsp;</span><span class="RktVal">#\-</span><span class="RktPn">)</span></td></tr><tr><td><p><span class="RktRes">"rib-bon-cut-ting cer-e-mo-ny"</span></p></td></tr><tr><td><span class="stt">&gt; </span><span class="RktPn">(</span><span class="RktSym"><a href="index.html#%28def._%28%28lib._hyphenate%2Fmain..rkt%29._unhyphenate%29%29" class="RktValLink" data-pltdoc="x">unhyphenate</a></span><span class="hspace">&nbsp;</span><span class="RktPn">(</span><span class="RktSym"><a href="index.html#%28def._%28%28lib._hyphenate%2Fmain..rkt%29._hyphenate%29%29" class="RktValLink" data-pltdoc="x">hyphenate</a></span><span class="hspace">&nbsp;</span><span class="RktVal">"ribbon-cutting ceremony"</span><span class="hspace">&nbsp;</span><span class="RktVal">#\-</span><span class="RktPn">)</span><span class="hspace">&nbsp;</span><span class="RktVal">#\-</span><span class="RktPn">)</span></td></tr><tr><td><p><span class="RktRes">"ribboncutting ceremony"</span></p></td></tr></table></blockquote></td></tr></table></p><p>Keep in mind that soft hyphens could appear in your input string. Certain word processors allow users to <a href="http://practicaltypography.com/optional-hyphens.html">insert soft hyphens</a> in their text.</p><p><table cellspacing="0" cellpadding="0" class="RktBlk"><tr><td><p>Examples:</p></td></tr><tr><td><blockquote class="SCodeFlow"><table cellspacing="0" cellpadding="0" class="RktBlk"><tr><td><span class="stt">&gt; </span><span class="RktPn">(</span><span class="RktSym"><a href="index.html#%28def._%28%28lib._hyphenate%2Fmain..rkt%29._hyphenate%29%29" class="RktValLink" data-pltdoc="x">hyphenate</a></span><span class="hspace">&nbsp;</span><span class="RktVal">"True\u00ADType typefaces"</span><span class="RktPn">)</span></td></tr><tr><td><p><span class="RktRes">"True\u00ADType type\u00ADfaces"</span></p></td></tr><tr><td><span class="stt">&gt; </span><span class="RktPn">(</span><span class="RktSym"><a href="index.html#%28def._%28%28lib._hyphenate%2Fmain..rkt%29._unhyphenate%29%29" class="RktValLink" data-pltdoc="x">unhyphenate</a></span><span class="hspace">&nbsp;</span><span class="RktPn">(</span><span class="RktSym"><a href="index.html#%28def._%28%28lib._hyphenate%2Fmain..rkt%29._hyphenate%29%29" class="RktValLink" data-pltdoc="x">hyphenate</a></span><span class="hspace">&nbsp;</span><span class="RktVal">"True\u00ADType typefaces"</span><span class="RktPn">)</span><span class="RktPn">)</span></td></tr><tr><td><p><span class="RktRes">"TrueType typefaces"</span></p></td></tr><tr><td><span class="stt">&gt; </span><span class="RktPn">(</span><span class="RktSym"><a href="index.html#%28def._%28%28lib._hyphenate%2Fmain..rkt%29._hyphenate%29%29" class="RktValLink" data-pltdoc="x">hyphenate</a></span><span class="hspace">&nbsp;</span><span class="RktPn">(</span><span class="RktSym"><a href="index.html#%28def._%28%28lib._hyphenate%2Fmain..rkt%29._unhyphenate%29%29" class="RktValLink" data-pltdoc="x">unhyphenate</a></span><span class="hspace">&nbsp;</span><span class="RktVal">"True\u00ADType typefaces"</span><span class="RktPn">)</span><span class="hspace">&nbsp;</span><span class="RktVal">#\-</span><span class="RktPn">)</span></td></tr><tr><td><p><span class="RktRes">"True-Type type-faces"</span></p></td></tr></table></blockquote></td></tr></table></p><h3>4<tt>&nbsp;</tt><a name="(part._.License___source_code)"></a>License &amp; source code</h3><p>This module is licensed under the LGPL.</p><p>Source repository at <a href="http://github.com/mbutterick/hyphenate">http://github.com/mbutterick/hyphenate</a>. Suggestions &amp; corrections welcome.</p></div></div><div id="contextindicator">&nbsp;</div></body></html>