Coder Social home page Coder Social logo

linebreak's People

Contributors

blikblum avatar dependabot[bot] avatar devongovett avatar jagonzalr avatar liborm85 avatar martinburch avatar mclark-newvistas avatar tootallnate avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

linebreak's Issues

Not able to integrate this library for ReactJS. Guidelines / Fix needed.

in the source code "const data = base64.toByteArray(fs.readFileSync(__dirname + '/classes.trie', 'base64'));"

since browser doesn't have fs.readFileSync supports, some pre build transform is needed to load the classes.tire during build time. Anyone has some guidelines how I can do this in ReactJS? Thanks!

-- recommendations for author , instead of loading the file using fs, we might use
// const data = base64.toByteArray(fs.readFileSync(__dirname + '/classes.trie', 'base64'));

// convert the classes.tire as base64 string in JS files
const classData = "AA4IAAAAAAAAAhqg5VV7NJtZvz7fTC8zU5d.........";
const data = base64.toByteArray(classData);

Doesn't work on big endian hosts

Hi @devongovett
Linebreak works on big endian machines only if classes.trie is generated on big endian machine too. Otherwise there is an error

reak/src/linebreaker.js:122

switch (pairTable[this.curClass][this.nextClass]) {

^

TypeError: Cannot read property 'undefined' of undefined

Seen by @lcurcio at "IBM I" POWER system and by me on Debian MIPS

Can u release a more common version?

I mean your lib is really useful, but it's a pitty that it can be run only on nodejs.
So, can u make some change to make it can be run on browser?

Thank you so much.

Error: File 'classes.trie' not found in virtual file system

Currently i'm using webpack 3 with pdfkit 0.10.0, it appears pdfkit is using this lib and the error I got was

Uncaught Error: File 'classes.trie' not found in virtual file system
    readFileSync virtual-fs.js:22
    <anonymous> linebreaker.js:15
    <anonymous> linebreaker.js:161
    <anonymous> linebreaker.js:163
    js main.bundle.js:33462
    __webpack_require__ main.bundle.js:679
    fn main.bundle.js:89
    <anonymous> pdfkit.es5.js:1
    <anonymous> pdfkit.es5.js:5741
    js main.bundle.js:37199
    __webpack_require__ main.bundle.js:679
    fn main.bundle.js:89
    <anonymous> ImportPatientDialog.js:26
    <anonymous> ImportPatientDialog.js:1397
    js main.bundle.js:49567
    __webpack_require__ main.bundle.js:679
    fn main.bundle.js:89
    <anonymous> DataEntry.js:15
    <anonymous> DataEntry.js:307
    js main.bundle.js:49671
    __webpack_require__ main.bundle.js:679
    fn main.bundle.js:89
    <anonymous> SettingContent.js:24
    <anonymous> SettingContent.js:256
    js main.bundle.js:49415
    __webpack_require__ main.bundle.js:679
    fn main.bundle.js:89
    <anonymous> Settings.js:16
    <anonymous> Settings.js:313
    js main.bundle.js:49431
    __webpack_require__ main.bundle.js:679
    fn main.bundle.js:89
    <anonymous> AppNoSplit.js:42
    <anonymous> AppNoSplit.js:312
    js main.bundle.js:44352
    __webpack_require__ main.bundle.js:679
    fn main.bundle.js:89
    <anonymous> index.js:18
    <anonymous> index.js:147
    js main.bundle.js:50751
    __webpack_require__ main.bundle.js:679
    fn main.bundle.js:89
    0 main.bundle.js:51371
    __webpack_require__ main.bundle.js:679
    <anonymous> main.bundle.js:725
    <anonymous> main.bundle.js:728
virtual-fs.js:22

I don't really understand the meaning behind this, how do I fix this?

Not returning required flag for trailing CR LF

If a string ends with '\r\n' the final returned line break position doesn't have the 'required' flag set.

This line should include a check and return appropriately:

return new Break(this.string.length);

eg: perhaps this:

var required = (this.curClass === BK) || ((this.curClass === CR) && (this.nextClass !== LF));
return new Break(this.string.length, required)

Redundant 'if' statement

I was porting this to C# and getting "not all control paths return a value" errors. Pretty sure this 'if' statement is redundant due to the preceding "while" statement's condition.

if (this.pos >= this.string.length) {

Thanks for your work on this :)

Not working in webpack

ERROR in ./~/{my lib}/~/linebreak/src/linebreaker.js
Module not found: Error: Cannot resolve module 'fs' in {my lib}/node_modules/linebreak/src
 @ ./~/{my lib}/~/linebreak/src/linebreaker.js 7:7-20

Wrong text wrapping

Texts with dashes are wrapped incorrectly. Tested on uuid strings.

Example 1:

Source text:
67e404e5-d4fb-2732-be14-2f60cf8b3cc2

Actual result:
67e404e5-
d4fb-2732-
be14-2f60cf8b3cc2

Expected result:
67e404e5-
d4fb-
2732-
be14-
2f60cf8b3cc2

Example 2:

Source text:
9847b959-135a-7014-3ad5-5223f4d2eaf5

Actual result:
9847b959-135a-7014-3ad5-5223f4d2eaf5

Expected result:
9847b959-
135a-
7014-
3ad5-
5223f4d2eaf5

Please, could it be fixed?

library not working properly for emoji

There are mainly two issues:

  • not all emoji behave the same, for example, ๐Ÿค‘ has a different line break checking with ๐Ÿ˜€
  • 8 bytes emoji ๐Ÿ‘จ๐Ÿฟโ€๐Ÿฆฑ are treated as two characters.

Possible bug in line break trie data

I was just going through cleaning up my version of this code that I ported to C# and noticed a possible problem with the way the trie data is generated for the line break data.

See this line of code

if ((type != null) && (rangeType !== type)) {

Seems this code is trying to coalesce consecutive ranges with the same class into a single trie.setRange call. The problem is that it's checking for a change of class, but not that the ranges are consecutive and without gaps.

Shouldn't that line read something like this:

    if (((type != null) && (rangeType !== type)) || parseInt(rangeStart, 16) != parseInt(end, 16) + 1)

Also, it seems the UnicodeTrieBuilder already coalesces runs so this isn't even necessary. I reduced it to this:

  var re = /^([0-9A-F]+)(?:\.\.([0-9A-F]+))?\s*;\s*(.*?)\s*#/gm
  var m;
  while (m = re.exec(data))
  {
    var from = parseInt(m[1], 16);
    var to = m[2] === undefined ? from : parseInt(m[2], 16);
    var prop = m[3];

    lineBreakClassesTrie.setRange(from, to, LineBreakClass[prop], true);
  }

Unfortunately none of this resolves any of those 30 non-passing tests.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.