Code Monkey home page Code Monkey logo

Comments (4)

mnater avatar mnater commented on August 15, 2024

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:

from hyphenopoly.

julientaq avatar julientaq commented on August 15, 2024

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.

mnater avatar mnater commented on August 15, 2024

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.

julientaq avatar julientaq commented on August 15, 2024

No need to excuse yourself!

Thanks again for all the work you’ve done here. it’s amazing!

from hyphenopoly.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.