Downsize
Downsize copied to clipboard
Tag safe text truncation for HTML and XML!
Hi there 👋 I needed to remove the xregexp dependency because I am running downsize in the browser, this is an entirely nieve implementation but it seems to work reasonably...
this fixes an issue that completely took down the front page of a blog i host for weeks.
For example: ```js const html = `one two three`; const truncate = require('downsize'); console.log(truncate(html, {words: 2})); ``` Results in: ``` one two three ``` This fixes it: ```patch diff --git...
Not sure if this is an easy fix or not. If a word has smart quotes (either raw or entities) it will be split. Examples: ```js // With smart quotes...
``` javascript var d = require('downsize'); var html = 'a b c d'; console.log(d(html,{words:2, append: '...'})); ``` Outputs: ``` a ... ```
For the character based Asian languages, "word" and "character" are actually the same concept, and words are not separated. For example the English sentence "**The quick brown fox jumps over...
bring it up to speed.
Downsize is all about text truncation, we want to take some HTML or XML, and get a truncated version. An issue was recently [raised in Ghost](https://github.com/TryGhost/Ghost/issues/3846) suggesting that it doesn't...