Skip to content

Commit

Permalink
update version number
Browse files Browse the repository at this point in the history
  • Loading branch information
mnater committed Sep 1, 2018
2 parents 494b67e + 126ab45 commit 27ba4e7
Show file tree
Hide file tree
Showing 12 changed files with 161 additions and 35 deletions.
9 changes: 9 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,14 @@
# Version History

## Version 2.3.0 (Juli 26, 2018)
### Hyphenopoly_Loader.js and Hyphenopoly.js:
* Don't use template strings [#28](https://github.com/mnater/Hyphenopoly/issues/28)
* run feature test for wasm support only if necessary

### hyphenopoly.module.js:
* define node >=8.3.0 as requirement (for util.TextDecoder)
* small refactorings

## Version 2.2.0 (June 26, 2018)
* provide example.js for RunKit
* use tap instead of mocha
Expand Down
2 changes: 1 addition & 1 deletion Hyphenopoly.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/**
* @license Hyphenopoly 2.3.0 - client side hyphenation for webbrowsers
* @license Hyphenopoly 2.4.0 - client side hyphenation for webbrowsers
* ©2018 Mathias Nater, Zürich (mathiasnater at gmail dot com)
* https://github.com/mnater/Hyphenopoly
*
Expand Down
32 changes: 19 additions & 13 deletions Hyphenopoly_Loader.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/**
* @license Hyphenopoly_Loader 2.3.0 - client side hyphenation
* @license Hyphenopoly_Loader 2.4.0 - client side hyphenation
* ©2018 Mathias Nater, Zürich (mathiasnater at gmail dot com)
* https://github.com/mnater/Hyphenopoly
*
Expand Down Expand Up @@ -299,32 +299,33 @@
* or with xmlHttpRequest
* @param {string} path Where the script is stored
* @param {string} fne Filename of the script with extension
* @param {string} name Name of the ressource
* @param {Object} msg Message
* @returns {undefined}
*/
function binLoader(path, fne, msg) {
function binLoader(path, fne, name, msg) {
/**
* Get bin file using fetch
* @param {string} p Where the script is stored
* @param {string} f Filename of the script with extension
* @param {string} n Name of the ressource
* @param {Object} m Message
* @returns {undefined}
*/
function fetchBinary(p, f, m) {
function fetchBinary(p, f, n, m) {
if (!loadedBins[f]) {
loadedBins[f] = true;
window.fetch(p + f).then(
function resolve(response) {
if (response.ok) {
const name = f.slice(0, f.lastIndexOf("."));
if (name === "hyphenEngine") {
H.binaries[name] = response.arrayBuffer().then(
if (n === "hyphenEngine") {
H.binaries[n] = response.arrayBuffer().then(
function getModule(buf) {
return new WebAssembly.Module(buf);
}
);
} else {
H.binaries[name] = response.arrayBuffer();
H.binaries[n] = response.arrayBuffer();
}
H.events.dispatch(m[0], {"msg": m[1]});
}
Expand All @@ -337,17 +338,17 @@
* Get bin file using XHR
* @param {string} p Where the script is stored
* @param {string} f Filename of the script with extension
* @param {string} n Name of the ressource
* @param {Object} m Message
* @returns {undefined}
*/
function requestBinary(p, f, m) {
function requestBinary(p, f, n, m) {
if (!loadedBins[f]) {
loadedBins[f] = true;
const xhr = new XMLHttpRequest();
xhr.open("GET", p + f);
xhr.onload = function onload() {
const name = f.slice(0, f.lastIndexOf("."));
H.binaries[name] = xhr.response;
H.binaries[n] = xhr.response;
H.events.dispatch(m[0], {"msg": m[1]});
};
xhr.responseType = "arraybuffer";
Expand All @@ -356,9 +357,9 @@
}

if (H.clientFeat.wasm) {
fetchBinary(path, fne, msg);
fetchBinary(path, fne, name, msg);
} else {
requestBinary(path, fne, msg);
requestBinary(path, fne, name, msg);
}
}

Expand Down Expand Up @@ -415,6 +416,10 @@
* @returns {undefined}
*/
function loadRessources(lang) {
let filename = lang + ".hpb";
if (H.fallbacks && H.fallbacks[lang]) {
filename = H.fallbacks[lang] + ".hpb";
}
if (!H.binaries) {
H.binaries = empty();
}
Expand All @@ -424,12 +429,13 @@
binLoader(
H.paths.maindir,
"hyphenEngine.wasm",
"hyphenEngine",
["engineLoaded", "wasm"]
);
} else {
scriptLoader(H.paths.maindir, "hyphenEngine.asm.js");
}
binLoader(H.paths.patterndir, lang + ".hpb", ["hpbLoaded", lang]);
binLoader(H.paths.patterndir, filename, lang, ["hpbLoaded", lang]);
allocateMemory(lang);
}

Expand Down
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# Hyphenopoly.js
[![Build Status](https://travis-ci.org/mnater/Hyphenopoly.svg?branch=master)](https://travis-ci.org/mnater/Hyphenopoly) [![dependencies Status](https://david-dm.org/mnater/Hyphenopoly/status.svg)](https://david-dm.org/mnater/Hyphenopoly) [![devDependencies Status](https://david-dm.org/mnater/Hyphenopoly/dev-status.svg)](https://david-dm.org/mnater/Hyphenopoly?type=dev) [![Coverage Status](https://coveralls.io/repos/github/mnater/Hyphenopoly/badge.svg?branch=master)](https://coveralls.io/github/mnater/Hyphenopoly?branch=master) [![Try hyphenopoly on RunKit](https://badge.runkitcdn.com/hyphenopoly.svg)](https://npm.runkit.com/hyphenopoly) [![npms score](https://badges.npms.io/hyphenopoly.svg)](https://npms.io/search?q=hyphenopoly)
[![Build Status](https://travis-ci.org/mnater/Hyphenopoly.svg?branch=master)](https://travis-ci.org/mnater/Hyphenopoly) [![Coverage Status](https://coveralls.io/repos/github/mnater/Hyphenopoly/badge.svg?branch=master)](https://coveralls.io/github/mnater/Hyphenopoly?branch=master) [![dependencies Status](https://david-dm.org/mnater/Hyphenopoly/status.svg)](https://david-dm.org/mnater/Hyphenopoly) [![devDependencies Status](https://david-dm.org/mnater/Hyphenopoly/dev-status.svg)](https://david-dm.org/mnater/Hyphenopoly?type=dev) [![npms score](https://badges.npms.io/hyphenopoly.svg)](https://npms.io/search?q=hyphenopoly)

Hyphenopoly.js is a __JavaScript-polyfill for hyphenation in HTML__: it hyphenates text if the user agent does not support CSS-hyphenation at all or not for the required languages and it is a __Node.js-module__.

Expand Down Expand Up @@ -89,6 +89,7 @@ If the browser supports all required languages the script deletes the `Hyphenopo
Hyphenopoly by default hyphenates elements (and their children) with the classname `.hyphenate`. Don't forget to enable CSS-hyphenation for the classes eventually handled by Hyphenopoly.

# Usage (node)
[![Try hyphenopoly on RunKit](https://badge.runkitcdn.com/hyphenopoly.svg)](https://npm.runkit.com/hyphenopoly)

Install:
````
Expand Down
3 changes: 2 additions & 1 deletion hyphenEngine.asm.js
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
/**
* @license hyphenEngine.asm.js 2.3.0 - hyphenation for node and webbrowsers
* @license hyphenEngine.asm.js 2.4.0 - client side hyphenation for webbrowsers
* ©2018 Mathias Nater, Zürich (mathiasnater at gmail dot com)
* https://github.com/mnater/Hyphenopoly
*
* Released under the MIT license
* http://mnater.github.io/Hyphenopoly/LICENSE
*/

function asmHyphenEngine(std, ext, heap) {
"use asm";
var ui8 = new std.Uint8Array(heap);
Expand Down
6 changes: 3 additions & 3 deletions hyphenopoly.module.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/**
* @license Hyphenopoly.module.js 2.3.0 - hyphenation for node
* ©2018 Mathias Nater, Zürich (mathiasnater at gmail dot com)
* https://github.com/mnater/Hyphenopoly
* @license Hyphenopoly.module.js 2.4.0 - hyphenation for node
* ©2018 Mathias Nater, Zürich (mathiasnater at gmail dot com)
* https://github.com/mnater/Hyphenopoly
*
* Released under the MIT license
* http://mnater.github.io/Hyphenopoly/LICENSE
Expand Down
26 changes: 15 additions & 11 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "hyphenopoly",
"version": "2.3.0",
"description": "Hyphenation for node and polyfill for client-side hyphenation.",
"version": "2.4.0",
"description": "Hyphenation for node and Polyfill for client-side hyphenation.",
"keywords": [
"hyphenation",
"html",
Expand Down Expand Up @@ -40,9 +40,9 @@
},
"dependencies": {},
"devDependencies": {
"eslint": "^5.1.0",
"eslint": "^5.5.0",
"tap": "^12.0.1",
"uglify-es": "^3.3.9"
"terser": "^3.8.2"
},
"eslintConfig": {
"parserOptions": {
Expand All @@ -57,15 +57,19 @@
},
"extends": "eslint:all",
"rules": {
"require-jsdoc": ["error", {
"require-unicode-regexp": 0,
"require-jsdoc": [
"error",
{
"require": {
"FunctionDeclaration": true,
"MethodDefinition": true,
"ClassDeclaration": true,
"ArrowFunctionExpression": true,
"FunctionExpression": true
"FunctionDeclaration": true,
"MethodDefinition": true,
"ClassDeclaration": true,
"ArrowFunctionExpression": true,
"FunctionExpression": true
}
}],
}
],
"no-template-curly-in-string": 2,
"prefer-template": 0,
"wrap-iife": 1,
Expand Down
Binary file modified patterns/th.hpb
Binary file not shown.
104 changes: 104 additions & 0 deletions testsuite/test24.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,104 @@
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="content-type" content="text/html; charset=UTF-8">
<title>Test 024</title>
<script>
var Hyphenopoly = {
require: {
"en-au": "FORCEHYPHENOPOLY",
"en": "FORCEHYPHENOPOLY"
},
fallbacks: {
"en-au": "en-gb",
"en": "en-us"
},
paths: {
maindir: "../",
patterndir: "../patterns/"
},
setup: {
safeCopy: false
},
handleEvent: {
hyphenopolyEnd: function (e) {
assert();
}
}
};
function assert() {
var tests = 2;
var i = 1;
var test = "";
var ref = "";
var result = true;
var lang = "";
while (i <= tests) {
lang = document.getElementById("test" + i).lang;
if (Hyphenopoly.clientFeat.langs[lang] === "CSS") {
document.getElementById("result").innerHTML += "<p style=\"background-color: #d6ffd6\">" + i + " passed (CSS)</p>";
result = result && true;
} else {
test = document.getElementById("test" + i).innerHTML;
ref = document.getElementById("ref" + i).innerHTML;
if (test === ref) {
document.getElementById("result").innerHTML += "<p style=\"background-color: #d6ffd6\">" + i + " passed</p>";
result = result && true;
} else {
document.getElementById("result").innerHTML += "<p style=\"background-color: #ffd6d6\">" + i + " failed</p>";
result = false;
}
}
i += 1;
}
if (parent != window) {
parent.postMessage(JSON.stringify({
desc: document.getElementById("desc").innerHTML,
index: 24,
result: (result ? "passed" : "failed")
}), window.location.href);
}
}
</script>
<script src="../Hyphenopoly_Loader.js"></script>
<style type="text/css">
body {
width:50%;
margin-left:25%;
margin-right:25%;
}

.test {
background-color: #D8E2F9;
}
.ref {
background-color: #FEEFC0;
}

.hyphenate {
hyphens: auto;
-ms-hyphens: auto;
-moz-hyphens: auto;
-webkit-hyphens: auto;
}
</style>
</head>
<body>
<div id="navigate"><a href="index.html">&Larr;&nbsp;Index</a>&nbsp;|&nbsp;<a href="test23.html">&larr;&nbsp;Prev</a>&nbsp;|&nbsp;<a href="test25.html">Next&nbsp;&rarr;</a></div>

<h1>Test 024</h1>
<p id="desc">Hyphenate a text marked with lang 'en-au'. Hyphenopoly should use 'en-gb'-patterns.</p>
<div id="result"></div>
<hr>
<h2>1: en-au</h2>
<p id="test1" class="test hyphenate" lang="en-au">A hyphenation algorithm is a set of rules that decides at which points a word can be broken over two lines with a hyphen.</p>
<p id="ref1" class="ref" lang="en-au">A hy&shy;phen&shy;a&shy;tion al&shy;gorithm is a set of rules that de&shy;cides at which points a word can be broken over two lines with a hy&shy;phen.</p>
<h2>2: en</h2>
<p id="test2" class="test hyphenate" lang="en">A hyphenation algorithm is a set of rules that decides at which points a word can be broken over two lines with a hyphen.</p>
<p id="ref2" class="ref" lang="en">A hy&shy;phen&shy;ation al&shy;go&shy;rithm is a set of rules that de&shy;cides at which points a word can be bro&shy;ken over two lines with a hy&shy;phen.</p>

<hr>
<div><span class="test">Test</span> <span class="ref">Ref</span></div>

</body>
</html>
3 changes: 2 additions & 1 deletion testsuite/testdriver.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,8 @@
{exec: true, path: "test20.html"},
{exec: true, path: "test21.html"},
{exec: true, path: "test22.html"},
{exec: true, path: "test23.html"}
{exec: true, path: "test23.html"},
{exec: true, path: "test24.html"}
];
var testframe = document.getElementById("testframe");
var currentTest = 1;
Expand Down
2 changes: 1 addition & 1 deletion tools/makePatterns.sh
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ rm -R $path_out
mkdir $path_out

#for filename in ${path_in}*.chr.txt; do {
filename="hyph-de-1996.chr.txt"
filename="hyph-th.chr.txt"
base=$(basename "$filename" .chr.txt)
langcode=${base#$prefix}
node tex2hpb.js $path_in$base.lic.txt $path_in$base.chr.txt $path_in$base.pat.txt $path_in$base.hyp.txt $path_out$langcode
Expand Down
6 changes: 3 additions & 3 deletions tools/minify.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@

mkdir -p min

uglifyjs Hyphenopoly_Loader.js -o min/Hyphenopoly_Loader.js --comments -c -m --warn
uglifyjs Hyphenopoly.js -o min/Hyphenopoly.js --comments -c -m --warn
uglifyjs hyphenEngine.asm.js -o min/hyphenEngine.asm.js --comments -c -m --warn --verbose
terser Hyphenopoly_Loader.js -o min/Hyphenopoly_Loader.js --comments -c -m --warn
terser Hyphenopoly.js -o min/Hyphenopoly.js --comments -c -m --warn
terser hyphenEngine.asm.js -o min/hyphenEngine.asm.js --comments -c -m --warn --verbose

cp hyphenEngine.wasm min/hyphenEngine.wasm
cp -R patterns min/patterns
Expand Down

0 comments on commit 27ba4e7

Please sign in to comment.