Can I use word wrap in a browser from JavaScript?

I have text in a div. It can be any Unicode text under the sun, including Chinese, Japanese, and Korean. Now I need to take this text and put it in JavaScript in some effective but correct order. Then I need to insert a ">" at the beginning of each line and put the resulting text in a text box.

Browsers have an implementation of the Unicode Word Wrap algorithm, as evidenced by Unicode text in CSS with CSS. (At least Firefox has such an algorithm, and I suspect that other browsers do too.) I need JavaScript to use the same word wrapping algorithm so that I can correctly wrap and then “quote” Unicode text ,

Can I use JavaScript to use the browser word wrapping algorithm, or know where the text was broken into lines in a div or any other element?

+3
source share
1 answer

What you really want is not to insert a ">" in the text at the beginning of each line. You really want each line in this block to have a ">" to the left of it.

You could do the last:

1) " > " , CSS line-height, . , "". , . /.

2) javascript line-height , . , , , "" ​​ offsetHeight, . , , a > . .

, , JavaScript, , , . , , Canvas, (Canvas , ). , , Bespin (https://bespin.mozillalabs.com/ - , Canvas) javascript- sandbag/image textwrapping, jQSlickWrap (http://jwf.us/projects/jQSlickWrap/).

+2

Source: https://habr.com/ru/post/1750216/


All Articles