forked from mnater/Hyphenator
-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.html
121 lines (110 loc) · 9.71 KB
/
index.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
<!DOCTYPE html>
<html lang="en">
<head>
<meta http-equiv="content-type" content="text/html; charset=UTF-8">
<title>Hyphenator.js</title>
<style type="text/css">
body {
max-width: 40em;
margin: 0 auto;
padding: 1em;
font: 16px "Helvetica Neue", Helvetica;
line-height: 1.6em;
color: #444;
}
p {
text-align: justify;
-webkit-hyphens: auto;
}
h1 {
text-align: center;
}
ul li {
font-size: 0.9em;
line-height: 1.4em;
}
a {
text-decoration: none;
color: #667788;
}
em {
font-weight: bolder;
}
.footnotes {
font-size: 0.9em;
line-height: 1.4em;
}
</style>
<script type="text/javascript">
/*
* Hyphenator_Loader 5.2.0(devel) - client side hyphenation for webbrowsers
* Copyright (C) 2015 Mathias Nater, Zürich (mathiasnater at gmail dot com)
* https://github.com/mnater/Hyphenator
*
* Released under the MIT license
* http://mnater.github.io/Hyphenator/LICENSE.txt
*/
var Hyphenator_Loader=(function(window){'use strict';var languages,config,path,createElem=function(tagname){var r;if(window.document.createElementNS){r=window.document.createElementNS('http://www.w3.org/1999/xhtml',tagname);}else if(window.document.createElement){r=window.document.createElement(tagname);}return r;},loadNrunHyphenator=function(config){var head,script,done=false;head=window.document.getElementsByTagName('head').item(0);script=createElem('script');script.src=path;script.type='text/javascript';script.onreadystatechange=function(){if(!done&&(!script.readyState||script.readyState==="loaded"||script.readyState==="complete")){done=true;Hyphenator.config(config);Hyphenator.run();script.onreadystatechange=null;script.onload=null;if(head&&script.parentNode){head.removeChild(script);}}};script.onload=script.onreadystatechange;head.appendChild(script);},checkLangSupport=function(){var shadowContainer,shadow,lang,fakeBdy=createElem('body');shadowContainer=createElem('div');shadowContainer.style.visibility='hidden';fakeBdy.appendChild(shadowContainer);window.document.documentElement.appendChild(fakeBdy);for(lang in languages){if(languages.hasOwnProperty(lang)){shadow=createElem('div');shadow.style.MozHyphens='auto';shadow.style['-webkit-hyphens']='auto';shadow.style['-ms-hyphens']='auto';shadow.style.hyphens='auto';shadow.style.width='5em';shadow.style.lineHeight='12px';shadow.style.border='none';shadow.style.padding='0';shadow.style.wordWrap='normal';shadow.style['-webkit-locale']="'"+lang+"'";shadow.lang=lang;shadow.appendChild(window.document.createTextNode(languages[lang]));shadowContainer.appendChild(shadow);if(shadow.offsetHeight===12){loadNrunHyphenator(config);break;}}}fakeBdy.parentNode.removeChild(fakeBdy);};return{init:function(langs,p,configs){languages=langs;path=p;config=configs||{};checkLangSupport();}};}(window));Hyphenator_Loader.init({"en":"hyphenationalgorithm"},"./Hyphenator.js",{useCSS3hyphenation:true});
</script>
</head>
<body>
<h1>Hyphenator.js</h1>
<h2>Overview</h2>
<p class="hyphenate">Hyphenator.js is a free open source Javascript library that automatically hyphenates text on websites. It comes in handy as a <em>polyfill</em> for legacy browsers that don't support CSS 3 hyphation at all or for modern browsers that do hyphenation, but do not provide hyphenation dictionaries for a particular language.</p>
<p class="hyphenate">Hyphenator.js …</p>
<ul>
<li>can be <a href="https://github.com/mnater/Hyphenator/blob/wiki/en_HowToUseHyphenator.md#using-hyphenator-on-your-website">included by the creator of the website</a>.</li>
<li>can be used <a href="https://github.com/mnater/Hyphenator/blob/wiki/en_HowToUseHyphenator.md#using-hyphenator-as-a-bookmarklet">as bookmarklet on any website</a>.</li>
<li>is <a href="http://en.wikipedia.org/wiki/Unobtrusive_JavaScript">unobtrusive</a>.</li>
<li>steps behind CSS 3 hyphenation if supported (<a href="https://github.com/mnater/Hyphenator/blob/wiki/en_HowToUseHyphenator.md#hyphenator_loaderjs">how to use Hyphenator_Loader</a>).</li>
<li>runs on the client in order that the HTML source of the website may be served clean and svelte and that it can respond to text resizings by the user.</li>
<li>is highly configurable and has a well <a href="https://github.com/mnater/Hyphenator/blob/wiki/en_PublicAPI.md#public-api">documented API</a>.</li>
<li>relies on Franklin M. Liangs hyphenation algorithm (<a href="http://www.tug.org/docs/liang/liang-thesis.pdf">PDF</a>) commonly known from LaTeX and OpenOffice.
<li>supports a <a href="https://github.com/mnater/Hyphenator/blob/wiki/en_AddNewLanguage.md#what-we-have-now">large set of different languages</a>.</li>
<li>provides services for <a href="http://mnater.github.io/Hyphenator/mergeAndPack.html">customizing, merging and packing script and patterns</a>.</li>
<li>also wraps URLs and Email-adresses.</li>
<li>is free software licensed under <a href="http://mnater.github.io/Hyphenator/LICENSE.txt">MIT License</a> (Version 5.0.0 and above).</li>
</ul>
<h2>Quick links</h2>
<ul>
<li><a href="https://github.com/mnater/Hyphenator">Code</a></li>
<li><a href="https://github.com/mnater/Hyphenator/releases/latest">Download</a></li>
<li><a href="https://github.com/mnater/Hyphenator/blob/wiki/en_TableOfContents.md#table-of-contents">Documentation</a></li>
</ul>
<h2>Quick guide</h2>
<ol>
<li><a href="https://github.com/mnater/Hyphenator/releases/latest">Download</a> the recent version of Hyphenator.js</li>
<li>Use <a href="http://mnater.github.io/Hyphenator/mergeAndPack.html">mergeAndPack.html</a> to configure and minify Hyphenator.js and hyphenation patterns.</li>
<li>Prepare your .html documents (i.e. add <code>hyphenate</code>-classes, set <code>lang</code> and add Hyphenator.js)</li>
<li>Test it!</li>
</ol>
<p class="hyphenate">Get <a href="https://github.com/mnater/Hyphenator/blob/wiki/en_HowToUseHyphenator.md#using-hyphenator-on-your-website">detailed instructions</a>.</p>
<h2>The bad parts</h2>
<p class="hyphenate">As with most things, there's a downside, too. Consider the following drawbacks before using Hyphenator.js:</p>
<ul>
<li>Hyphenator.js and the hyphenation patterns are quite large. A good compression and caching is vital.</li>
<li>Automatic hyphenation can not be perfect: it may lead to misleading hyphenation like leg-ends (depends on the pattern quality)</li>
<li>There's no support for special (aka non-standard) hyphenation (e.g. omaatje->oma-tje)</li>
<li>There's no way for Javascript to influence the algorithm for laying out text in the browser. Thus we can't control how many hyphens occur on subsequent lines nor can we know which words have actually to be hyphenated. Hyphenator.js just hyphenates all of them.</li>
</ul>
<h2>Philosophy</h2>
<h3>There is text and there is beautiful text</h3>
<p class="hyphenate">This beauty becomes manifest in content and representation. I'm firmly convinced that all written text (well, most of it) deserves fine typography, that we deserve it. While hyphenation is just one of many tesserae that forms the appearance of text, it may be an important one.</p>
<h3>There is code and there is sound code</h3>
<p class="hyphenate">In code there is readability, maintainability, performance and genius – and some constraints of technology. As a hobbyist programmer I often feel like a hobbit surrounded by wizards who campaign for these values. But being an agile hobbit gives me the freedom to find my own way through the woods (thankfully free from evil in this area). I'm constantly in search of the most performant path to circumvent the constraints of technology while maintaining readability and maintainability of my code. Sometimes this path is illuminated by a wizard<sup><a href="#fn1">1</a></sup>.</p>
<h2>Issues and Requests</h2>
<p class="hyphenate">Each release is tested in various browsers with an <a href="./testsuite/">automated testsuite</a>. Nevertheless, there will always be bugs. Please don't hesitate to <a href="https://github.com/mnater/Hyphenator/issues">submit them</a>.</p>
<p class="hyphenate">If you have a special use case and Hyphenator.js doesn't provide a solution, feel free to <a href="https://github.com/mnater/Hyphenator/issues">submit a feature request</a>.</p>
<p class="hyphenate">And please, be patient. Hyphenator.js is a hobby of mine and sometimes other things have precedence…</p>
<hr>
<div class="footnotes">
<p id="fn1">(1) Some of my coding wizards are:</p>
<ul>
<li>Franklin Mark Liang for his beautiful <a href="http://www.tug.org/docs/liang/">hyphenation algorithm</a></li>
<li><a href="http://www.crockford.com">Douglas Crockford</a> for making Javascript a programming language</li>
<li>Vyacheslav Egorov for his <a href="http://mrale.ph/">deep insights to V8</a></li>
<li>Bram Stein for his <a href="http://stateofwebtype.com">initiative on web typography</a></li>
</ul>
</div>
</body>
</html>