example.js 666 B

123456789101112131415161718192021222324252627
  1. // For RunKit:
  2. const hyphenopoly = require("hyphenopoly");
  3. // For local node:
  4. // const hyphenopoly = require("./hyphenopoly.module.js");
  5. const hyphenator = hyphenopoly.config({
  6. "exceptions": {
  7. "en-us": "en-han-ces"
  8. },
  9. "hyphen": "•",
  10. "require": ["de", "en-us"]
  11. });
  12. async function hyphenateEn(text) {
  13. const hyphenateText = await hyphenator.get("en-us");
  14. console.log(hyphenateText(text));
  15. }
  16. async function hyphenateDe(text) {
  17. const hyphenateText = await hyphenator.get("de");
  18. console.log(hyphenateText(text));
  19. }
  20. hyphenateEn("hyphenation enhances justification.");
  21. hyphenateDe("Silbentrennung verbessert den Blocksatz.");