From 1f4a3300752c8bbf5a0138c7924b231161f1e4ac Mon Sep 17 00:00:00 2001 From: Niklas von Hertzen Date: Sun, 4 Jul 2021 17:23:28 +0800 Subject: [PATCH] docs: fix readme (#13) * docs: update readme ci badge and syntax highlighting (#fix 8) * fix: break-word (fix #10) --- README.md | 30 ++++++++++++++++-------------- src/LineBreak.ts | 2 +- 2 files changed, 17 insertions(+), 15 deletions(-) diff --git a/README.md b/README.md index c7a7b5b..ee628ef 100644 --- a/README.md +++ b/README.md @@ -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) @@ -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: diff --git a/src/LineBreak.ts b/src/LineBreak.ts index 9b23f06..192316c 100644 --- a/src/LineBreak.ts +++ b/src/LineBreak.ts @@ -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)); }