bramstein / hypher

A fast and small JavaScript hyphenation engine

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

detect line-wraps in paragraph

dahannes opened this issue · comments

I am trying to wrap each line of a paragraph inside a span, which works fine on non-hyphenated paragraphs: I split the text on whitespaces and wrap each word inside a span. By comparing these span's top-offsets I know which word is on a new line.

This won't work with a hyphenated word since it spans two lines.

Is there a way to detect line-wraps in a hyphenated paragraph?
Or can you detect "active" hyphenation-marks?

(I need this to address each line via css)

I'm not sure that is possible. I think you're probably better of writing your own line breaking algorithm then. You can use the unicode tokenizer library as a starting point: https://github.com/bramstein/unicode-tokenizer