-
Notifications
You must be signed in to change notification settings - Fork 24
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Reworked text reader in favour of if statements
- Loading branch information
Showing
8 changed files
with
239 additions
and
215 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 |
---|---|---|
@@ -0,0 +1,13 @@ | ||
import { createHyphenator } from "../src/create-hyphenator.js"; | ||
import { createRequire } from "module"; | ||
|
||
let text = | ||
"The Tortoise never stopped for a moment, walking slowly but steadily, right to the end of the course. The Hare ran fast and stopped to lie down for a rest. But he fell fast asleep. Eventually, he woke up and ran as fast as he could. But when he reached the end, he saw the Tortoise there already, sleeping comfortably after her effort."; | ||
// text = "hyphenation hyphenation"; | ||
|
||
const require = createRequire(import.meta.url); | ||
const enUS = require("../patterns/en-us.cjs"); | ||
|
||
const hy = createHyphenator(enUS, { hyphenChar: "-" }); | ||
|
||
console.log(hy(text)); |
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,34 @@ | ||
import { createTextReader } from "../src/textReader.js"; | ||
import { createHyphenationVerifier } from "../src/hyphenationVerifier.js"; | ||
|
||
let text = `Dans des temps très anciens, alors qu'il pouvait encore être utile de faire | ||
des voeux, vivait un roi dont toutes les filles étaient belles. La plus | ||
jeune était si belle que le soleil, qui en a cependant tant vu, s'étonnait | ||
chaque fois qu'il illuminait son visage. Non loin du château du roi, il y | ||
avait une grande et sombre forêt et, dans la forêt, sous un vieux tilleul, | ||
une fontaine. Un jour qu'il faisait très chaud, la royale enfant partit dans | ||
le bois, et s'assit au bord de la source fraîche. Et comme elle s'ennuyait, | ||
elle prit sa balle en or, la jeta en l'air et la rattrapa; <blockquote id="hi">c'était</blockquote> son jeu | ||
favo\u00ADri.`; | ||
|
||
// text = `Dans des temps très anciens`; | ||
// text = "Hyphenation hyphenatioN"; | ||
// text = "<beautiful class=\"beautiful\">"; | ||
// text = "beautiful"; | ||
|
||
var minWordLength = 5; | ||
var hyphenChar = "\u00AD"; | ||
|
||
const readText = createTextReader( | ||
createHyphenationVerifier(hyphenChar, true, minWordLength) | ||
); | ||
|
||
var a, | ||
all = []; | ||
|
||
while ((a = readText(text))) { | ||
console.log(a); | ||
all.push(a[0]); | ||
all.push(a[1]); | ||
} | ||
console.log(text === all.join("")); |
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 was deleted.
Oops, something went wrong.
Oops, something went wrong.