GithubHelp home page GithubHelp logo

Comments (5)

tricinel avatar tricinel commented on July 21, 2024 1

Alright, cool, got it. Will investigate 👍 Thanks!

from highlight-words.

tricinel avatar tricinel commented on July 21, 2024

Hey @karlhorky,

To make this clear, let's use an example.

const text = 'My dog is a very good boy and is always eating his lunch.';
const chunks = highlightWords({
  text,
  query: 'is',
  clipBy: 3
});

By default, you'd get chunks like:

[
  {
    "text": "... My dog ",
    "match": false
  },
  {
    "text": "is",
    "match": true
  },
  {
    "text": " a very ... boy and ",
    "match": false
  },
  {
    "text": "is",
    "match": true
  },
  {
    "text": " always eating h",
    "match": false
  },
  {
    "text": "is",
    "match": true
  },
  {
    "text": " lunch",
    "match": false
  }
]

And this will clip whole words. If you introduce a new option to clip by characters, then you'll get something like:

[
  {
    "text": "... My ",
    "match": false
  },
  {
    "text": "is",
    "match": true
  },
  {
    "text": " a ve ...",
    "match": false
  },
  {
    "text": "is",
    "match": true
  },
  {
    "text": "... g h",
    "match": false
  },
  {
    "text": "is",
    "match": true
  },
  {
    "text": " lu ...",
    "match": false
  }
]

Just want to be sure I got this right and I will investigate the implications.

from highlight-words.

karlhorky avatar karlhorky commented on July 21, 2024

Ah, not quite - it would count the 3 characters from the edge closest to the match, just like your algorithm counts the number of words from the matching edge.

I've added an example to the original description above, with 7 characters instead of 3.

from highlight-words.

karlhorky avatar karlhorky commented on July 21, 2024

@tricinel any news on this?

from highlight-words.

tricinel avatar tricinel commented on July 21, 2024

Nothing, no. I doubt this will make it in to be honest, as I see less use cases for having cut-up characters rather than words. Also from an accessibility stand point, I can imagine a screen reader just reciting letters and it pains me 😢

from highlight-words.

Related Issues (10)

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.