Skip to content

Commit

Permalink
docs: fix readme (#13)
Browse files Browse the repository at this point in the history
* docs: update readme ci badge and syntax highlighting (#fix 8)

* fix: break-word (fix #10)
  • Loading branch information
niklasvh authored Jul 4, 2021
1 parent 096e091 commit 1f4a330
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 15 deletions.
30 changes: 16 additions & 14 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
css-line-break
==============

[![Build Status](https://travis-ci.org/niklasvh/css-line-break.svg)](https://travis-ci.org/niklasvh/css-line-break)
![CI](https://github.com/niklasvh/html2canvas/workflows/CI/badge.svg?branch=master)
[![NPM Downloads](https://img.shields.io/npm/dm/css-line-break.svg)](https://www.npmjs.org/package/css-line-break)
[![NPM Version](https://img.shields.io/npm/v/css-line-break.svg)](https://www.npmjs.org/package/css-line-break)

Expand Down Expand Up @@ -30,22 +30,24 @@ The `LineBreaker` creates an [iterator](https://developer.mozilla.org/en-US/docs
LineBreaker(text, [options]);

### Example
import {LineBreaker} from 'css-line-break';

const breaker = LineBreaker('Lorem ipsum lol.', {
lineBreak: 'strict',
wordBreak: 'break-word'
});
[JSFiddle](https://jsfiddle.net/ofd3752k)
```javascript
import {LineBreaker} from 'css-line-break';

const words = [];
let bk;
const breaker = LineBreaker('Lorem ipsum lol.', {
lineBreak: 'strict',
wordBreak: 'normal'
});

while (!(bk = breaker.next()).done) {
words.push(bk.value.slice());
}
const words = [];
let bk;

assert.deepEqual(words, ['Lorem ', 'ipsum ', 'lol.']);

while (!(bk = breaker.next()).done) {
words.push(bk.value.slice());
}

assert.deepEqual(words, ['Lorem ', 'ipsum ', 'lol.']);
```
### Options
The following parameters are available for the options:

Expand Down
2 changes: 1 addition & 1 deletion src/LineBreak.ts
Original file line number Diff line number Diff line change
Expand Up @@ -541,7 +541,7 @@ const cssFormattedClasses = (
}
let [indicies, classTypes, isLetterNumber] = codePointsToCharacterClasses(codePoints, options.lineBreak);

if (options.wordBreak === 'break-all' || options.wordBreak === 'break-word') {
if (options.wordBreak === 'break-all') {
classTypes = classTypes.map(type => ([NU, AL, SA].indexOf(type) !== -1 ? ID : type));
}

Expand Down

0 comments on commit 1f4a330

Please sign in to comment.