DominicBoettger / hyphenator

Automatically exported from code.google.com/p/hyphenator
0 stars 0 forks source link

multiple classes #206

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
Hi

Thanks for asking.
This is an interesting idea. But there could be some issues: e.g. when a 
wrapper element and a inner element both have such classes, the element will 
possibly be processed twice.
I’ll work on it and see how the code behaves…

For the time being:
With a tailored selectorfunction you can collect exactly those elements you 
want to be hyphenated.
See 
https://code.google.com/p/hyphenator/wiki/en_PublicAPI#property_selectorfunction
 for details.

Best regards,
Mathias

On 11 Dec 2014, at 11:32, Miguel Filgueiras <m…@t-online.de> wrote:

Hello Mathias,

Thanks for making available Hyphenator. I am trying to use it
and I have a problem that may affect other people as well:
I need to apply hyphenation in different parts of HTML pages
with different specific classes but as there is only one hyphenate
class name content authors will be forced to use it along all those
classes. I would prefer not to rely on the authors to do this
and a solution is for Hyphenator to accept a string with class names
separated by blanks instead of a single name as the value of classname.

I would be grateful if you can modify Hyphenator in this way.

Best regards,
Miguel Filgueiras

Original issue reported on code.google.com by mathiasn...@gmail.com on 12 Dec 2014 at 12:00

GoogleCodeExporter commented 9 years ago
[deleted comment]
GoogleCodeExporter commented 9 years ago
On 12 Dec 2014, at 11:49, Miguel Filgueiras <m…@t-online.de> wrote:

Hi,

Thanks for your answer. I should have noticed the selectorfunction
configuration, sorry. I include below a possible way of using it
for what I asked, in case you wish to add it to the documentation.

As to the issue you mention of embedded classes, I think this
can also happen in any case, even with only the hyphenator class.

Thanks again!
Miguel
---------------
       Hyphenator.config({selectorfunction: function () {
      var es=[],xs,l;
         // iterate on each class to be hyphenated
         ['myhclass1', 'myhclass2'].forEach(function(c,i,a){
        xs=document.getElementsByClassName(c);
        l=xs.length;
        for(i=0;i<l;i++) es.push(xs[i]);
         });
         return(es);
       }});
----------------

Original comment by mathiasn...@gmail.com on 7 Jan 2015 at 2:21

GoogleCodeExporter commented 9 years ago
The issue that embedded classes get processed multiple times exists indeed.
Needs a fix!

Original comment by mathiasn...@gmail.com on 7 Jan 2015 at 2:22

GoogleCodeExporter commented 9 years ago
[deleted comment]
GoogleCodeExporter commented 9 years ago
The issue with multiple classes is fixed in r1314:
Result of selectorfunction is 'flattened'

Next step: think about support for multiple classes:

Pro:
+ it's easier than writing a custom selectorfunction

Contra:
- needs more code (filesize!)
- could be solved with selectorfunction (-> provide an example)
- list of classes error prone: "class1, class2" != "class1 class2" (OR vs AND)

Original comment by mathiasn...@gmail.com on 18 Jan 2015 at 11:14