npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

angular-highlightjs-searchtext

v0.0.4

Published

An angular JS directive for code syntax highlighting using HighlightJS with added line numbers and keyword searching functionality.

Downloads

8

Readme

angular-highlightjs-searchtext

An angular JS directive for code syntax highlighting using HighlightJS with added line numbers and keyword searching functionality.

##Demo https://amitgen414.github.io/angular-highlightjs-searchtext

Requirements

  • highlightjs v9.6.0
  • AngularJS v1.0.1+

Getting started

You will need to include angular JS , Highlight JS and one of the highlight js theme(which is available with hljs package) as depenedencies in your project to make the directive work.

<script src="//ajax.googleapis.com/ajax/libs/angularjs/1.5.8/angular.min.js"></script>
<link rel="stylesheet" href="/path/to/styles/xcode.css">
<script src="/path/to/highlight.pack.js"></script>

Include angular-highlightjs-searchtext module and stylesheet with above included scripts in your page. Please download or clone the repo to get the angular-highlightjs-searchtext.min.js and angular-highlightjs-searchtext.min.css from build folder of repo and add it in your script and style folder respectively

<script src="./path/to/script/angular-highlightjs-searchtext.min.js"></script>
<link rel="stylesheet" href="/path/to/styles/angular-highlightjs-searchtext.min.css">

Add angular-highlightjs-searchtext to your app.

angular.module('myApp', ['hljsSearch']);

Install with npm

$ npm install angular-highlightjs-searchtext

Options

Option | Type |Description --------------------| -------| ---------------------------------------- code | string | provide the code with \t and \n characters included for formatting. language | string | language of the code provided. searchtext | string | text to be searched in the code snippet. linenumber | boolean| whether line number is to be shown or not.

Directive usage

angular-highlightjs-searchtext is an element directive. you will just have to add the directive in you html view and pass the required parameters through scope. it supports two way data binding. Hence as soon a any of the parameter value changed, it will get reflected immediately.


    angular.module('myApp').controller('myAppController',['$scope', function($scope){
        $scope.code = 'code to be passed to directive for highlighting';
        $scope.language='language of the code';
        $scope.searchtext = 'text to be searched within the code';
        $scope.isLineNumber = true;
    
    }]);
 
<!--angular-highlightjs-searchtext setup -->
 <hljs-search code="code" language="language" searchtext="searchtext"  linenumber="isLineNumber"></hljs-search>
</div>

Customization

If you want to customize the app according to your needs, here is what should be done.

  1. Clone the respository in your local workspace.
  2. Install Ruby and Compass in your system as it is required for compiling your sass files.
  3. Install the npm dependencies.
  $ npm install
  1. Install bower dependencies.
  $ bower install
  1. Start the with the dev environment. it will build the project and launch it in the browser with real time code change update.
  $ npm run serve 
  1. After you are done with your changes , you can run build command
  $ npm run build 

you will have the script as well as a demo website ready.