Вы не можете выбрать более 25 тем Темы должны начинаться с буквы или цифры, могут содержать дефисы(-) и должны содержать не более 35 символов.

3 лет назад
12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  1. css-line-break
  2. ==============
  3. [![Build Status](https://travis-ci.org/niklasvh/css-line-break.svg)](https://travis-ci.org/niklasvh/css-line-break)
  4. [![NPM Downloads](https://img.shields.io/npm/dm/css-line-break.svg)](https://www.npmjs.org/package/css-line-break)
  5. [![NPM Version](https://img.shields.io/npm/v/css-line-break.svg)](https://www.npmjs.org/package/css-line-break)
  6. A JavaScript library for Line Breaking and identifying Word Boundaries,
  7. [implementing the Unicode Line Breaking Algorithm (UAX #14)](http://unicode.org/reports/tr14/)
  8. >> Line breaking, also known as word wrapping, is the process of breaking a section of text into
  9. lines such that it will fit in the available width of a page, window or other display area.
  10. The Unicode Line Breaking Algorithm performs part of this process. Given an input text,
  11. it produces a set of positions called "break opportunities" that are appropriate points to
  12. begin a new line. The selection of actual line break positions from the set of break opportunities
  13. is not covered by the Unicode Line Breaking Algorithm, but is in the domain of higher level
  14. software with knowledge of the available width and the display size of the text.
  15. In addition, the module implements CSS specific tailoring options to line breaking as
  16. defined in [CSS Text Module Level 3](https://www.w3.org/TR/css-text-3/#line-breaking).
  17. ### Installing
  18. You can install the module via npm:
  19. npm install css-line-break
  20. ### Usage
  21. The `LineBreaker` creates an [iterator](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/Iterators_and_Generators) that returns `Break`s for a given text.
  22. LineBreaker(text, [options]);
  23. ### Example
  24. import {LineBreaker} from 'css-line-break';
  25. const breaker = LineBreaker('Lorem ipsum lol.', {
  26. lineBreak: 'strict',
  27. wordBreak: 'break-word'
  28. });
  29. const words = [];
  30. let bk;
  31. while (!(bk = breaker.next()).done) {
  32. words.push(bk.value.slice());
  33. }
  34. assert.deepEqual(words, ['Lorem ', 'ipsum ', 'lol.']);
  35. ### Options
  36. The following parameters are available for the options:
  37. - `lineBreak`: `normal` | `strict`
  38. - `wordBreak`: `normal` | `break-all` | `break-word` | `keep-all`
  39. For more information how they affect the line breaking algorithms,
  40. check out [CSS Text Module Level 3](https://www.w3.org/TR/css-text-3/#line-breaking).
  41. ### Testing
  42. You can run the test suite with:
  43. npm test
  44. The library implements all the [LineBreakTest.txt tests](http://www.unicode.org/Public/10.0.0/ucd/auxiliary/LineBreakTest.txt)
  45. and a number of CSS web-platform-tests.