GithubHelp home page GithubHelp logo

melchiorb / jquery-textgrep Goto Github PK

View Code? Open in Web Editor NEW
0.0 1.0 0.0 160 KB

Grep through text with jQuery and do fun stuff with the result.

Home Page: http://melchiorb.github.io/jquery-textGrep

License: MIT License

Racket 13.64% CoffeeScript 86.36%

jquery-textgrep's Introduction

textGrep for jQuery

The textGrep plugin allows you to find text inside elements. The occurences are wrapped in span, or other elements and returned. This lets you apply classes, styles and dom manipulations to pieces of text.

This plugin is meant to simplify applying styles to certain text patterns, for example for typographic purposes.

TextGrep does pretty much what Grep Styles do in Adobe® InDesign®.

Basic use

Add the class number to all numbers.

<p>Copyright 2013 ACME Corp.</p>
$('p').textGrep(/\d+/).addClass('number');
<p>Copyright <span class="number">2013</span> ACME Corp.</p>

Add the class capitals to all words written in captial letters.

<p>Copyright 2013 ACME Corp.</p>
$('p').textGrep(/[A-Z0-9]{2,}/).addClass('capitals');
<p>Copyright 2013 <span class="capitals">ACME</span> Corp.</p>

Presets

TextGrep provides presets for commonly used regular expressions.

<p>Copyright 2013 ACME Corp.</p>
$('p').textGrep('number').addClass('number');
<p>Copyright <span class="number">2013</span> ACME Corp.</p>

Presets can be added easily as well.

$.textGrep.presets.test = /test/g;
$('p').textGrep('test').addClass('test');

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.