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

@rapidui/quiver-highlight

v0.0.0-beta.24

Published

Rapid UI Highlight Module

Downloads

56

Readme

QuiverHighlightComponent: rui-highlight

rui-highlight is an @angular component that uses native @angular to parse code to HTML elements. It is based on highlight.js library.

This implementation supports all the Common languages in highlight.js.

API Summary

Properties:

| Name | Type | Description | | --- | --- | 650--- | | lang | [any common language supported in highlight.js] | Language of the code content to be parsed as highlighted html. | content | string | Code content to be parsed as highlighted html. Used to load data dynamically. e.g. .ts content. | contentReady | function | Event emitted after the highlight content rendering is finished.

Note: This module uses the DomSanitizer service to ~sanitize~ the parsed html from the highlight.js lib to avoid XSS issues.

By default, --dev build will log the following message in the console to let you know:

WARNING: sanitizing HTML stripped some content (see http://g.co/ng/security#xss).

Installation

This component can be installed as npm package.

npm i -save @covalent/highlight

Setup

Import the [QuiverHighlightModule] in your NgModule:

import { QuiverHighlightModule } from '@covalent/highlight';

@NgModule({
  imports: [
    QuiverHighlightModule,
    ...
  ],
  ...
})
export class MyModule {}

Theming

The highlight module comes with its own default covalent theme which you can use by importing our theme scss file.

@import '~@covalent/highlight/highlight-theme';

@include covalent-highlight-theme();

Alternatively, you can use the highlight.js pre-built themes by loading them either by an import:

@import '~highlight.js/styles/vs.css';

Loading them in the .angular-cli.json:

"styles": [
  "/path/to/node_modules/highlight.js/styles/vs.css"
]

Or by loading them in the index.html file:

<link rel="stylesheet" href="/path/to/node_modules/highlight.js/styles/vs.css">

Usage

Simply wrap your code snippets in <rui-highlight>. To use HTML brackets < and > wrap the code with <![CDATA[ and ]]>; or replace with HTMLs character entities &lt; and &gt;.

Also, to display model binding, add spaces between curly braces like: { { } } and wrap them with <![CDATA[ and ]]>;

Example for HTML usage:

<rui-highlight lang="html">
  <![CDATA[
    <rui-highlight lang="html">
      <h1>hello world!</h1>
      <span>{ {property} }</span>
    </rui-highlight>
  ]]>
</rui-highlight>

Example for CSS usage:

<rui-highlight lang="css">    
  <![CDATA[   
    pre {
      display: block;
      overflow-x: auto;
      padding: 0;
      margin: 0;
      background: #002451;
      color: white;
      font-family: Menlo, Monaco, "Andale Mono", "lucida console", "Courier New", monospace;
      line-height: 1.45;
      tab-size: 2;
      -webkit-font-smoothing: auto;
      -webkit-text-size-adjust: none;
      position: relative;
      border-radius: 2px;
    }
  ]]>
</rui-highlight>

Example for Typescript:

<rui-highlight lang="typescript">
  <![CDATA[
    import { Injectable } from '@angular/core';
    import { Subject } from 'rxjs/Subject';
    import { Observable } from 'rxjs/Observable';

    @Injectable()
    export class Service {

      private _sources: {[key : string]: Subject<any>} = {};
      private _observables: {[key: string]: Observable<any>} = {};

      constructor(){

      }

      public register(name) : Observable<any> {
        this._sources[name] = new Subject<any>();
        this._observables[name] = this._sources[name].asObservable();
        return this._observables[name];
      }

      public emit(name: string): void {
        if(this._sources[name]){
          this._sources[name].next(null);
        }
      }
    }
  ]]>
</rui-highlight>