-
-
Notifications
You must be signed in to change notification settings - Fork 46
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
6 changed files
with
95 additions
and
23 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,20 +1,26 @@ | ||
/* eslint-env node */ | ||
/* eslint no-console: 0 */ | ||
"use strict"; | ||
// For RunKit: | ||
const hyphenopoly = require("hyphenopoly"); | ||
|
||
// For local node: | ||
// const hyphenopoly = require("./hyphenopoly.module.js"); | ||
/* | ||
* For local node: | ||
* const hyphenopoly = require("./hyphenopoly.module.js"); | ||
*/ | ||
|
||
const hyphenator = hyphenopoly.config({ | ||
"sync": true, | ||
"require": ["de", "en-us"], | ||
"hyphen": "•", | ||
"exceptions": { | ||
"en-us": "en-han-ces" | ||
} | ||
}, | ||
"hyphen": "•", | ||
"require": ["de", "en-us"], | ||
"sync": true | ||
}); | ||
|
||
const hy1 = hyphenator.get("en-us")("hyphenation enhances justification."); | ||
const hy2 = hyphenator.get("de")("Silbentrennung verbessert den Blocksatz."); | ||
|
||
|
||
console.log(hy1); | ||
console.log(hy2); | ||
console.log(hy2); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Binary file not shown.
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
/* eslint-env node */ | ||
/* eslint global-require: 0, func-names: 0, no-shadow: 0 */ | ||
"use strict"; | ||
const t = require("tap"); | ||
|
||
let H9Y = null; | ||
t.beforeEach(function setup(done) { | ||
H9Y = require("../hyphenopoly.module"); | ||
done(); | ||
}); | ||
|
||
t.afterEach(function tearDown(done) { | ||
H9Y = null; | ||
delete require.cache[require.resolve("../hyphenopoly.module")]; | ||
done(); | ||
}); | ||
|
||
t.test("run config with one language", async function (t) { | ||
const deHyphenator = await H9Y.config({ | ||
"loader": "http", | ||
"paths": { | ||
"maindir": "http://mnater.github.io/Hyphenopoly/", | ||
"patterndir": "http://mnater.github.io/Hyphenopoly/patterns/" | ||
}, | ||
"require": ["de"] | ||
}); | ||
t.test("return a function", function (t) { | ||
t.equal(typeof deHyphenator, "function", typeof deHyphenator); | ||
t.end(); | ||
}); | ||
t.test("hyphenate one word", function (t) { | ||
t.equal(deHyphenator("Silbentrennung"), "Sil\u00ADben\u00ADtren\u00ADnung", deHyphenator("Silbentrennung")); | ||
t.end(); | ||
}); | ||
t.test("hyphenate two words", function (t) { | ||
t.equal(deHyphenator("Silbentrennung Algorithmus"), "Sil\u00ADben\u00ADtren\u00ADnung Al\u00ADgo\u00ADrith\u00ADmus", deHyphenator("Silbentrennung Algorithmus")); | ||
t.end(); | ||
}); | ||
t.end(); | ||
}); |