source: imaps-frontend/node_modules/css-line-break/README.md

main
Last change on this file was 79a0317, checked in by stefan toskovski <stefantoska84@…>, 3 days ago

F4 Finalna Verzija

  • Property mode set to 100644
File size: 2.5 KB
Line 
1css-line-break
2==============
3
4![CI](https://github.com/niklasvh/css-line-break/workflows/CI/badge.svg?branch=master)
5[![NPM Downloads](https://img.shields.io/npm/dm/css-line-break.svg)](https://www.npmjs.org/package/css-line-break)
6[![NPM Version](https://img.shields.io/npm/v/css-line-break.svg)](https://www.npmjs.org/package/css-line-break)
7
8A JavaScript library for Line Breaking and identifying Word Boundaries,
9[implementing the Unicode Line Breaking Algorithm (UAX #14)](http://unicode.org/reports/tr14/)
10
11>> Line breaking, also known as word wrapping, is the process of breaking a section of text into
12lines such that it will fit in the available width of a page, window or other display area.
13The Unicode Line Breaking Algorithm performs part of this process. Given an input text,
14it produces a set of positions called "break opportunities" that are appropriate points to
15begin a new line. The selection of actual line break positions from the set of break opportunities
16is not covered by the Unicode Line Breaking Algorithm, but is in the domain of higher level
17software with knowledge of the available width and the display size of the text.
18
19In addition, the module implements CSS specific tailoring options to line breaking as
20defined in [CSS Text Module Level 3](https://www.w3.org/TR/css-text-3/#line-breaking).
21
22### Installing
23You can install the module via npm:
24
25 npm install css-line-break
26
27### Usage
28The `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.
29
30 LineBreaker(text, [options]);
31
32### Example
33[JSFiddle](https://jsfiddle.net/ofd3752k)
34```javascript
35import {LineBreaker} from 'css-line-break';
36
37const breaker = LineBreaker('Lorem ipsum lol.', {
38 lineBreak: 'strict',
39 wordBreak: 'normal'
40});
41
42const words = [];
43let bk;
44
45while (!(bk = breaker.next()).done) {
46 words.push(bk.value.slice());
47}
48
49assert.deepEqual(words, ['Lorem ', 'ipsum ', 'lol.']);
50```
51### Options
52The following parameters are available for the options:
53
54 - `lineBreak`: `normal` | `strict`
55 - `wordBreak`: `normal` | `break-all` | `break-word` | `keep-all`
56
57For more information how they affect the line breaking algorithms,
58check out [CSS Text Module Level 3](https://www.w3.org/TR/css-text-3/#line-breaking).
59
60### Testing
61You can run the test suite with:
62
63 npm test
64
65The library implements all the [LineBreakTest.txt tests](http://www.unicode.org/Public/10.0.0/ucd/auxiliary/LineBreakTest.txt)
66 and a number of CSS web-platform-tests.
Note: See TracBrowser for help on using the repository browser.