From de89c130c60c610a8f3f58c83238754fa2ac0c56 Mon Sep 17 00:00:00 2001
From: Mathias Nater
Date: Mon, 27 Apr 2015 16:53:21 +0200
Subject: [PATCH 01/86] Removes comments from bower.json
---
bower.json | 4 +---
1 file changed, 1 insertion(+), 3 deletions(-)
diff --git a/bower.json b/bower.json
index e6dcabd..5283527 100644
--- a/bower.json
+++ b/bower.json
@@ -1,5 +1,3 @@
-//use the following command to install Hyphenator.js:
-//bower install git://github.com/mnater/Hyphenator
{
"name": "Hyphenator",
"version": "5.0.0",
@@ -8,4 +6,4 @@
"favicon.ico",
"Hyphenator_observable.js"
]
-}
\ No newline at end of file
+}
From 15cfd3395b1f9aa50d4681188656ed3c55148686 Mon Sep 17 00:00:00 2001
From: Lars Moelleken
Date: Wed, 24 Jun 2015 11:10:21 +0200
Subject: [PATCH 02/86] Update README.md
---
README.md | 69 ++++++++++++++++++++++++++++++++++++++++++++++++++++++-
1 file changed, 68 insertions(+), 1 deletion(-)
diff --git a/README.md b/README.md
index d410107..4bc548a 100644
--- a/README.md
+++ b/README.md
@@ -2,4 +2,71 @@
This repository replaces https://code.google.com/p/hyphenator/
-Please see the projects page on http://mnater.github.io/Hyphenator/ for instructions and further reading.
\ No newline at end of file
+## Overview
+
+Hyphenator.js is a free open source Javascript library that automatically hyphenates text on websites. It comes in handy as a _polyfill_ 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.
+
+Hyphenator.js …
+
+* can be [included by the creator of the website](https://github.com/mnater/Hyphenator/blob/wiki/en_HowToUseHyphenator.md#using-hyphenator-on-your-website).
+* can be used [as bookmarklet on any website](https://github.com/mnater/Hyphenator/blob/wiki/en_HowToUseHyphenator.md#using-hyphenator-as-a-bookmarklet).
+* is [unobtrusive](http://en.wikipedia.org/wiki/Unobtrusive_JavaScript).
+* steps behind CSS 3 hyphenation if supported ([how to use Hyphenator_Loader](https://github.com/mnater/Hyphenator/blob/wiki/en_HowToUseHyphenator.md#hyphenator_loaderjs)).
+* 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.
+* is highly configurable and has a well [documented API](https://github.com/mnater/Hyphenator/blob/wiki/en_PublicAPI.md#public-api).
+* relies on Franklin M. Liangs hyphenation algorithm ([PDF](http://www.tug.org/docs/liang/liang-thesis.pdf)) commonly known from LaTeX and OpenOffice.
+* supports a [large set of different languages](https://github.com/mnater/Hyphenator/blob/wiki/en_AddNewLanguage.md#what-we-have-now).
+* provides services for [customizing, merging and packing script and patterns](http://mnater.github.io/Hyphenator/mergeAndPack.html).
+* also wraps URLs and Email-adresses.
+* is free software licensed under [MIT License](http://mnater.github.io/Hyphenator/LICENSE.txt) (Version 5.0.0 and above).
+
+## Quick links
+
+* [Code](https://github.com/mnater/Hyphenator)
+* [Download](https://github.com/mnater/Hyphenator/releases/latest)
+* [Documentation](https://github.com/mnater/Hyphenator/blob/wiki/en_TableOfContents.md#table-of-contents)
+
+## Quick guide
+
+1. [Download](https://github.com/mnater/Hyphenator/releases/latest) the recent version of Hyphenator.js
+2. Use [mergeAndPack.html](http://mnater.github.io/Hyphenator/mergeAndPack.html) to configure and minify Hyphenator.js and hyphenation patterns.
+3. Prepare your .html documents (i.e. add `hyphenate`-classes, set `lang` and add Hyphenator.js)
+4. Test it!
+
+Get [detailed instructions](https://github.com/mnater/Hyphenator/blob/wiki/en_HowToUseHyphenator.md#using-hyphenator-on-your-website).
+
+## The bad parts
+
+As with most things, there's a downside, too. Consider the following drawbacks before using Hyphenator.js:
+
+* Hyphenator.js and the hyphenation patterns are quite large. A good compression and caching is vital.
+* Automatic hyphenation can not be perfect: it may lead to misleading hyphenation like leg-ends (depends on the pattern quality)
+* There's no support for special (aka non-standard) hyphenation (e.g. omaatje->oma-tje)
+* 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.
+
+## Philosophy
+
+### There is text and there is beautiful text
+
+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.
+
+### There is code and there is sound code
+
+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[1](#fn1).
+
+## Issues and Requests
+
+Each release is tested in various browsers with an [automated testsuite](./testsuite/). Nevertheless, there will always be bugs. Please don't hesitate to [submit them](https://github.com/mnater/Hyphenator/issues).
+
+If you have a special use case and Hyphenator.js doesn't provide a solution, feel free to [submit a feature request](https://github.com/mnater/Hyphenator/issues).
+
+And please, be patient. Hyphenator.js is a hobby of mine and sometimes other things have precedence…
+
+* * *
+
+(1) Some of my coding wizards are:
+
+* Franklin Mark Liang for his beautiful [hyphenation algorithm](http://www.tug.org/docs/liang/)
+* [Douglas Crockford](http://www.crockford.com) for making Javascript a programming language
+* Vyacheslav Egorov for his [deep insights to V8](http://mrale.ph/)
+* Bram Stein for his [initiative on web typography](http://stateofwebtype.com)
From 9746af33c88a8fddeed841b8413c89fa359eb5bc Mon Sep 17 00:00:00 2001
From: Lars Moelleken
Date: Wed, 24 Jun 2015 11:14:25 +0200
Subject: [PATCH 03/86] Update README.md
---
README.md | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/README.md b/README.md
index 4bc548a..a61421a 100644
--- a/README.md
+++ b/README.md
@@ -1,6 +1,7 @@
# Hyphenator.js
-This repository replaces https://code.google.com/p/hyphenator/
+- This repository replaces https://code.google.com/p/hyphenator/
+- Demo: http://mnater.github.io/Hyphenator/
## Overview
From 36cd5db6eac9691b8530cb061ad8cde0d40f0e06 Mon Sep 17 00:00:00 2001
From: mnater
Date: Wed, 24 Jun 2015 12:29:48 +0200
Subject: [PATCH 04/86] fix link
---
mergeAndPack.html | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/mergeAndPack.html b/mergeAndPack.html
index 5bbe06f..9974707 100644
--- a/mergeAndPack.html
+++ b/mergeAndPack.html
@@ -930,7 +930,7 @@
mergeAndPack
- Since this page uses XMLHttpRequests to load the script and pattern files, it will not work if you call it with the file:// protocol. Instead put it on your server or go to http://code.google.com/p/hyphenator/.
+ Since this page uses XMLHttpRequests to load the script and pattern files, it will not work if you call it with the file:// protocol. Instead put it on your server or go to http://mnater.github.io/Hyphenator/mergeAndPack.html.
The script loads the versions of Hyphenator.js (and Hyphenator_Loader.js and the patterns) that resides in the same directory like this page.
From 8fb686ef8f3e8f1187d7771db7165bd987e5b4a7 Mon Sep 17 00:00:00 2001
From: mnater
Date: Wed, 24 Jun 2015 12:33:07 +0200
Subject: [PATCH 05/86] update version number
---
Hyphenator.js | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/Hyphenator.js b/Hyphenator.js
index d856e3a..b35c5ed 100644
--- a/Hyphenator.js
+++ b/Hyphenator.js
@@ -1,4 +1,4 @@
-/** @license Hyphenator 5.0.1(devel) - client side hyphenation for webbrowsers
+/** @license Hyphenator 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
*
@@ -19,7 +19,7 @@
* @global
* @namespace Hyphenator
* @author Mathias Nater,
- * @version 5.0.1(devel)
+ * @version 5.2.0(devel)
* @example
* <script src = "Hyphenator.js" type = "text/javascript"></script>
* <script type = "text/javascript">
@@ -2814,7 +2814,7 @@ var Hyphenator = (function (window) {
* minor release: new languages, improvements
* @access public
*/
- version: '5.0.0(devel)',
+ version: '5.2.0(devel)',
/**
* @member {boolean} Hyphenator.doHyphenation
From 310908a80efd42333e5c1971352a2ae9744d3189 Mon Sep 17 00:00:00 2001
From: mnater
Date: Wed, 24 Jun 2015 17:38:17 +0200
Subject: [PATCH 06/86] Load Hyphenator as soon as one lang isn't supported
---
Hyphenator_Loader.js | 101 +++++++++++++++++--------------------------
1 file changed, 40 insertions(+), 61 deletions(-)
diff --git a/Hyphenator_Loader.js b/Hyphenator_Loader.js
index 903af5d..1e50c82 100644
--- a/Hyphenator_Loader.js
+++ b/Hyphenator_Loader.js
@@ -43,6 +43,37 @@ var Hyphenator_Loader = (function (window) {
return r;
},
+ /**
+ * @name Hyphenator-loadNrunHyphenator
+ * @description Loads Hyphenator.js and runs it with the given configuration
+ * @type {function({object})}
+ * @param {object} config the configuration object for Hyphenator.js
+ * @private
+ */
+ 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.onload = script.onreadystatechange = function () {
+ if (!done && (!this.readyState || this.readyState === "loaded" || this.readyState === "complete")) {
+ done = true;
+
+ Hyphenator.config(config);
+ Hyphenator.run();
+
+ // Handle memory leak in IE
+ script.onload = script.onreadystatechange = null;
+ if (head && script.parentNode) {
+ head.removeChild(script);
+ }
+ }
+ };
+ head.appendChild(script);
+ },
+
/**
* @name Hyphenator-checkLangSupport
* @description
@@ -56,15 +87,8 @@ var Hyphenator_Loader = (function (window) {
checkLangSupport = function () {
var shadowContainer,
shadow,
- shadows = [],
lang,
- i,
- r = true,
- bdy = window.document.getElementsByTagName('body')[0],
- fakeBdy = false;
- if (!bdy) {
fakeBdy = createElem('body');
- }
shadowContainer = createElem('div');
shadowContainer.style.MozHyphens = 'auto';
shadowContainer.style['-webkit-hyphens'] = 'auto';
@@ -75,6 +99,9 @@ var Hyphenator_Loader = (function (window) {
shadowContainer.style.wordWrap = 'normal';
shadowContainer.style.visibility = 'hidden';
+ fakeBdy.appendChild(shadowContainer);
+ window.document.documentElement.appendChild(fakeBdy);
+
for (lang in languages) {
if (languages.hasOwnProperty(lang)) {
shadow = createElem('div');
@@ -83,62 +110,14 @@ var Hyphenator_Loader = (function (window) {
shadow.style['-webkit-locale'] = "'" + lang + "'";
shadow.appendChild(window.document.createTextNode(languages[lang]));
shadowContainer.appendChild(shadow);
- shadows.push(shadow);
- }
- }
- if (fakeBdy) {
- fakeBdy.appendChild(shadowContainer);
- window.document.documentElement.appendChild(fakeBdy);
- } else {
- bdy.appendChild(shadowContainer);
- }
- for (i = 0; i < shadows.length; i += 1) {
- r = (shadows[i].offsetHeight > 12) && r;
- }
- if (fakeBdy) {
- fakeBdy.parentNode.removeChild(fakeBdy);
- } else {
- bdy.removeChild(shadowContainer);
- }
- return r;
- },
-
- /**
- * @name Hyphenator-loadNrunHyphenator
- * @description Loads Hyphenator.js and runs it with the given configuration
- * @type {function({object})}
- * @param {object} config the configuration object for Hyphenator.js
- * @private
- */
- 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.onload = script.onreadystatechange = function () {
- if (!done && (!this.readyState || this.readyState === "loaded" || this.readyState === "complete")) {
- done = true;
-
- Hyphenator.config(config);
- Hyphenator.run();
-
- // Handle memory leak in IE
- script.onload = script.onreadystatechange = null;
- if (head && script.parentNode) {
- head.removeChild(script);
+ if (shadow.offsetHeight === 12) {
+ loadNrunHyphenator(config);
+ break;
}
}
- };
- head.appendChild(script);
- },
-
- runner = function () {
- var allLangsSupported = checkLangSupport();
- if (!allLangsSupported) {
- loadNrunHyphenator(config);
}
+
+ fakeBdy.parentNode.removeChild(fakeBdy);
};
return {
@@ -153,7 +132,7 @@ var Hyphenator_Loader = (function (window) {
languages = langs;
path = p;
config = configs || {};
- runner();
+ checkLangSupport();
}
};
}(window));
\ No newline at end of file
From f0f1b5be631cccd91797ca62ec2ac19c27f0ffda Mon Sep 17 00:00:00 2001
From: mnater
Date: Fri, 26 Jun 2015 13:07:08 +0200
Subject: [PATCH 07/86] Make vars private
---
Hyphenator.js | 22 +++++++++++-----------
1 file changed, 11 insertions(+), 11 deletions(-)
diff --git a/Hyphenator.js b/Hyphenator.js
index b35c5ed..1a79d10 100644
--- a/Hyphenator.js
+++ b/Hyphenator.js
@@ -1664,6 +1664,9 @@ var Hyphenator = (function (window) {
* @access private
*/
ValueStore = function (len) {
+ var startIndex = 1,
+ actualIndex = 2,
+ lastValueIndex = 2;
this.keys = (function () {
var i, r;
if (Object.prototype.hasOwnProperty.call(window, "Uint8Array")) { //IE<9 doesn't have window.hasOwnProperty (host object)
@@ -1676,23 +1679,20 @@ var Hyphenator = (function (window) {
}
return r;
}());
- this.startIndex = 1;
- this.actualIndex = 2;
- this.lastValueIndex = 2;
this.add = function (p) {
- this.keys[this.actualIndex] = p;
- this.lastValueIndex = this.actualIndex;
- this.actualIndex += 1;
+ this.keys[actualIndex] = p;
+ lastValueIndex = actualIndex;
+ actualIndex += 1;
};
this.add0 = function () {
//just do a step, since array is initialized with zeroes
- this.actualIndex += 1;
+ actualIndex += 1;
};
this.finalize = function () {
- var start = this.startIndex;
- this.keys[start] = this.lastValueIndex - start;
- this.startIndex = this.lastValueIndex + 1;
- this.actualIndex = this.lastValueIndex + 2;
+ var start = startIndex;
+ this.keys[start] = lastValueIndex - start;
+ startIndex = lastValueIndex + 1;
+ actualIndex = lastValueIndex + 2;
return start;
};
},
From 37427d1c6b3d49d47c8bd84f68fac125eff6c5e5 Mon Sep 17 00:00:00 2001
From: mnater
Date: Sat, 25 Jul 2015 23:54:48 +0200
Subject: [PATCH 08/86] Fixes #226
---
Hyphenator.js | 4 ++--
testsuite/index.html | 3 ++-
testsuite/test118.html | 2 +-
testsuite/test119.html | 53 ++++++++++++++++++++++++++++++++++++++++++
4 files changed, 58 insertions(+), 4 deletions(-)
create mode 100644 testsuite/test119.html
diff --git a/Hyphenator.js b/Hyphenator.js
index 1a79d10..e38e7e7 100644
--- a/Hyphenator.js
+++ b/Hyphenator.js
@@ -2182,7 +2182,7 @@ var Hyphenator = (function (window) {
*/
wwAsMappedCharCodeStore = (function () {
if (Object.prototype.hasOwnProperty.call(window, "Int32Array")) {
- return new window.Int32Array(32);
+ return new window.Int32Array(64);
}
return [];
}()),
@@ -2197,7 +2197,7 @@ var Hyphenator = (function (window) {
wwhpStore = (function () {
var r;
if (Object.prototype.hasOwnProperty.call(window, "Uint8Array")) {
- r = new window.Uint8Array(32);
+ r = new window.Uint8Array(64);
} else {
r = [];
}
diff --git a/testsuite/index.html b/testsuite/index.html
index 70213a5..929128a 100644
--- a/testsuite/index.html
+++ b/testsuite/index.html
@@ -192,7 +192,8 @@
Using charset=ISO-8859-1 instead of utf8. IE fails here! (if Latin-1 has to be used replace all non ascii-chars in the pattern files with unicode escapes.)
Das englische Wort “Hyphenation” lsst sich nicht unbedingt wrtlich mit «Silbentrennung» bersetzen.
-
Das eng|li|sche Wort “Hy|phen|ation” lsst sich nicht un|be|dingt wrt|lich mit Sil|ben|tren|nung ber|set|zen.
+
Das eng|li|sche Wort “Hy|phen|ation” lsst sich nicht un|be|dingt wrt|lich mit «Sil|ben|tren|nung» ber|set|zen.