Comments (4)
Hi
Thank you for this question. I started developing Hyphenopoly (respectively its predecessor Hyphenator.js) because I wanted to replicate the layout of TeX documents in the Web and therefor needed hyphenation. But I never made it this far.
Now I'm happy to see how my lib may help to produce such beautiful documents.
I hope I can help with this issue...
Analysis of the issue:
The function returnes by Hyphenopoly.hyphenators["HTML"]
takes a second parameter selector
wich defaults to .hyphenate
. There are no settings for the selector .hyphenate
and thus the described error occurs.
But there are more problems:
- Since there are settings defined for the selector
p
Hyphenopoly will not collect the<p>
-elements inside the<section>
element, because it "thinks" these elements are already handled. - When we execute a hyphenator on the
<selection>
element the settings given for its child-elements (p
,li
etc.) are not respected in the current implementation. Thus we'll have to call the hyphenator for each element that has individual settings.
Solution:
In noHyphens.js try this:
// then run hyphenopoly
Object.keys(Hyphenopoly.setup.selectors).forEach(sel => {
content.querySelectorAll(sel).forEach(elem => {
Hyphenopoly.hyphenators["HTML"].then((hyn) => {
hyn(elem, sel);
});
});
});
Although not very beautiful it works for the example you sent.
Further thoughts:
The logic you intend to implement in noHyphens.js is already partially available in Hyphenopoly:
- Prevent hyphenation of words containing an uppercase character: https://mnater.github.io/Hyphenopoly/Setup.html#mixedcase
- Handling words containing a "-": https://mnater.github.io/Hyphenopoly/Setup.html#compound
- Black-/Whitelisting of words: https://mnater.github.io/Hyphenopoly/Setup.html#exceptions
from hyphenopoly.
Oh! Thanks a lot!
This is a clear explanation!
I’ve tried that code, and it seems to work.
One thing though, since Hyphenopoly doesn’t run on the content, it never really finishes and the HTML never get out of the visibility: hidden !important;
stays up. I found the full setup config (i’m a litte less bit lost in the docs thanks to your help :D), so i remove the hiding.
I’ll let @nicolastaffin check the code for the micro typography configuration and we’ll be back!
Can’t wait to show you books done with it :)
Thank you very much!
from hyphenopoly.
I totally forgot about the hiding. Your approach is correct. Please excuse the circumstances.
I'll close this issue for now - but feel free to reopen anytime.
If there are any adjustments needed in Hyphenopoly, just let me know.
from hyphenopoly.
No need to excuse yourself!
Thanks again for all the work you’ve done here. it’s amazing!
from hyphenopoly.
Related Issues (20)
- SIGBUS crash while hyphenating english after some Russian words HOT 3
- Is late instantion of a language possible? HOT 3
- tracking issue for next major version (5.0.0) HOT 1
- hyphenopoly vs client hyphenation HOT 2
- Hyphenopoly doesn't seem to work with Firefox 94 HOT 5
- Wrong hyphen characters on MacOs with chromium browsers HOT 5
- Example Code HOT 1
- en-us missing, also when not used HOT 2
- get "Module not found: Error:" HOT 2
- Callback when hyphenation is finished HOT 2
- Allow loader overwrite HOT 6
- Stop using fs module HOT 3
- Optionally abort fetch in loader HOT 1
- Add language? HOT 4
- It doesn't work with Italian (maybe?) HOT 2
- Beta versions should not be the latest official version with package managers HOT 1
- Remove added hyphenation HOT 7
- Provide Hyphenopoly module path to loader() / loaderSync()? HOT 1
- unify return type of (node module's) Hyphenopoly.config
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from hyphenopoly.