Coder Social home page Coder Social logo

murhafsousli / ngx-highlightjs Goto Github PK

View Code? Open in Web Editor NEW
271.0 3.0 34.0 4.1 MB

Angular syntax highlighting module

Home Page: https://ngx-highlight.netlify.com/

License: MIT License

JavaScript 1.69% TypeScript 83.23% HTML 9.09% SCSS 5.99%
angular highlightjs syntax-highlighting prism code linenumbers gist

ngx-highlightjs's Introduction

Angular Highlight.js

Demo Stackblitz npm tests codecov Downloads Monthly Downloads npm bundle size (minified + gzip) License

Instant code highlighting directives


Table of Contents

Install with NPM

npm i ngx-highlightjs

Use provideHighlightOptions to provide highlight.js options in app.config.ts

import { provideHighlightOptions } from 'ngx-highlightjs';

export const appConfig: ApplicationConfig = {
  providers: [
    provideHighlightOptions({
      fullLibraryLoader: () => import('highlight.js')
    })
  ]
};

Note: This includes the entire Highlight.js library with all languages.

You can also opt to load only the core script and the necessary languages.

Importing Core Library and Languages

import { provideHighlightOptions } from 'ngx-highlightjs';

export const appConfig: ApplicationConfig = {
  providers: [
    provideHighlightOptions({
      coreLibraryLoader: () => import('highlight.js/lib/core'),
      lineNumbersLoader: () => import('ngx-highlightjs/line-numbers'), // Optional, add line numbers if needed
      languages: {
        typescript: () => import('highlight.js/lib/languages/typescript'),
        css: () => import('highlight.js/lib/languages/css'),
        xml: () => import('highlight.js/lib/languages/xml')
      },
      themePath: 'path-to-theme.css' // Optional, useful for dynamic theme changes
    })
  ]
};

HighlightOptions API

Name Description
fullLibraryLoader A function returning a promise to load the entire highlight.js script
coreLibraryLoader A function returning a promise to load the core highlight.js script
lineNumbersLoader A function returning a promise to load the lineNumbers script for adding line numbers
languages The languages to register with Highlight.js (Needed only if you opt to use coreLibraryLoader)
config Set Highlight.js configuration, see configure-options
lineNumbersOptions Set line numbers plugin options
themePath The path to the CSS file for the highlighting theme

Import highlighting theme

Dynamic Approach

Set the theme path in the global configuration to enable dynamic theme changes:

 providers: [
  {
    provide: HIGHLIGHT_OPTIONS,
    useValue: {
      // ...
      themePath: 'assets/styles/solarized-dark.css'
    }
  }
]

Alternatively, import the theme from the app's distribution folder or use a CDN link.

When switching between app themes, call the setTheme(path) method from the HighlightLoader service.

import { HighlightLoader } from 'ngx-highlightjs';

export class AppComponent {

  private hljsLoader: HighlightLoader = inject(HighlightLoader);

  onAppThemeChange(appTheme: 'dark' | 'light') {
    this.hljsLoader.setTheme(appTheme === 'dark' ? 'assets/styles/solarized-dark.css' : 'assets/styles/solarized-light.css');
  }
}

Traditional Approach

In angular.json:

"styles": [
  "styles.css",
  "../node_modules/highlight.js/styles/github.css",
]

Or directly in src/style.scss:

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

List of all available themes from highlight.js

Use highlight directive

To apply code highlighting, use the highlight directive. It requires setting the target language, with an optional feature to ignore illegal syntax.

import { Highlight } from 'ngx-highlightjs';

@Component({
  standalone: true,
  selector: 'app-root',
  template: `
    <pre><code [highlight]="code" language="html"></code></pre>
  `,
  imports: [Highlight]
})
export class AppComponent {
}

Options

Name Type Description
[highlight] string Code to highlight.
[language] string Parameter must be present and specify the language name or alias of the grammar to be used for highlighting.
[ignoreIllegals] boolean An optional parameter that when true forces highlighting to finish even in case of detecting illegal syntax for the language instead of throwing an exception.
(highlighted) HighlightResult Stream that emits the result object when element is highlighted

highlightAuto directive

The highlightAuto directive works the same way but automatically detects the language to apply highlighting.

import { HighlightAuto } from 'ngx-highlightjs';

@Component({
  selector: 'app-root',
  template: `
    <pre><code [highlightAuto]="code"></code></pre>
  `,
  standalone: true,
  imports: [HighlightAuto]
})
export class AppComponent {
}

Options

Name Type Description
[highlightAuto] string Accept code string to highlight, default null
[languages] string[] An array of language names and aliases restricting auto detection to only these languages, default: null
(highlighted) AutoHighlightResult Stream that emits the result object when element is highlighted

lineNumbers directive

The lineNumbers directive extends highlighted code with line numbers. It functions in conjunction with the highlight and highlightAuto directives.

import { HighlightAuto } from 'ngx-highlightjs';
import { HighlightLineNumbers } from 'ngx-highlightjs/line-numbers';

@Component({
  selector: 'app-root',
  template: `
    <pre><code [highlightAuto]="code" lineNumbers></code></pre>
  `,
  standalone: true,
  imports: [HighlightAuto, HighlightLineNumbers]
})
export class AppComponent {
}

Options

Name Type Description
[singleLine] boolean Enable plugin for code block with one line, default false.
[startFrom] number Start numbering from a custom value, default 1.

NOTE

During the project build process, you may encounter a warning stating WARNING in ... CommonJS or AMD dependencies can cause optimization bailouts.

To address this warning, include the following configuration in your angular.json file:

{
  "projects": {
    "project-name": {
      "architect": {
        "build": {
          "options": {
            "allowedCommonJsDependencies": [
              "highlight.js"
            ]
          }
        }
      }
    }
  }
}

Read more about CommonJS dependencies configuration

This package provides the following features:

  • Utilizes the gists API to highlight code snippets directly from GitHub gists.
  • Supports direct code highlighting from URLs.

Usage

To integrate this addon into your project, ensure the presence of HttpClient by importing it into your main.ts file.

import { provideHttpClient } from '@angular/common/http';

export const appConfig: ApplicationConfig = {
  providers: [
    provideHttpClient()
  ]
};

Highlight a gist file

  1. Use [gist] directive, passing the gist ID as its attribute, to retrieve the response through the (gistLoaded) output event.
  2. Upon the emission of (gistLoaded), gain access to the gist response.
  3. Use gistContent pipe to extract the file's content from the gist response based on the specified file name.

Example:

import { HighlightPlusModule } from 'ngx-highlightjs';

@Component({
  selector: 'app-root',
  template: `
    <pre [gist]="gistId" (gistLoaded)="gist = $event">
      <code [highlight]="gist | gistContent: 'main.js'"></code>
    </pre>
  `,
  standalone: true,
  imports: [HighlightPlusModule]
})
export class AppComponent {
}

Highlight all gist files

To loop over gist?.files, use keyvalue pipe to pass file name into gistContent pipe.

To highlight all files within a gist, iterate through gist.files and utilize the keyvalue pipe to pass the file name into the gistContent pipe.

Example:

import { HighlightPlusModule } from 'ngx-highlightjs';

@Component({
  selector: 'app-root',
  template: `
    <ng-container [gist]="gistId" (gistLoaded)="gist = $event">
      @for (file of gist?.files | keyvalue; track file.key) {
        <pre><code [highlight]="gist | gistContent: file.key"></code></pre>
      }
    </ng-container>
  `,
  standalone: true,
  imports: [HighlightPlusModule, CommonModule]
})
export class AppComponent {
}

Highlight code from URL directly

Use the pipe codeFromUrl with the async pipe to get the code text from a raw URL.

Example:

import { HighlightPlusModule } from 'ngx-highlightjs';

@Component({
  selector: 'app-root',
  template: `
   <pre>
     <code [highlight]="codeUrl | codeFromUrl | async"></code>
   </pre>
  `,
  standalone: true,
  imports: [HighlightPlusModule, CommonModule]
})
export class AppComponent {
}

Providing Gist API secret (Optional)

The package offers the provideHighlightOptions function, allowing you to set your clientId and clientSecret for the gist HTTP requests. You can provide these options in your app.config.ts file as demonstrated below:

import { provideHttpClient } from '@angular/common/http';
import { provideHighlightOptions } from 'ngx-highlightjs/plus'

export const appConfig: ApplicationConfig = {
  providers: [
    provideHttpClient(),
    provideGistOptions({
      clientId: 'CLIENT_ID',
      clientSecret: 'CLIENT_SECRET'
    })
  ]
};

If you identify any errors in the library, or have an idea for an improvement, please open an issue.

Murhaf Sousli

ngx-highlightjs's People

Contributors

armoucar avatar dependabot[bot] avatar jasomimo avatar manekinekko avatar murhafsousli avatar tomastrajan 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

ngx-highlightjs's Issues

Highlight TextArea

Bug Report or Feature Request (mark with an x)

- [ ] bug report -> please search issues before submitting
- [X] feature request
- [ ] question

OS and Version?

WINDOWS 10

Versions

@angular/cli (6.2.4)

Repro steps

<div highlight="textarea"> <textarea name="codes" [(ngModel)]="itemValue" placeholder="Codes..."></textarea> </div>

Desired functionality

Would love a way to somehow use ngx-highlightjs directly on a textArea, that way i have a "code editor" directly build in.
I already made a side by side view, using a textarea and a pre/code box, but the it feels odd that you type one place and reads it in another box.

Hope that you can help me with my request or maybe point me in the right direction.

Have a great weekend! ๐Ÿ‘

Highlight with two-way binding

Bug Report or Feature Request (mark with an x)

- [ ] bug report -> please search issues before submitting
- [ ] feature request
- [ x ] question

OS and Version?

Windows 10

Versions

Angular 6.0.0

Desired functionality

Is there any approach to two-way binding for the editors that works consistently? So far, I've implemented a content editable directive to get me part of the way, but having lots of trouble with carriage returns.

Has anyone had any luck doing the same?

Here's a stackblitz link to show how I have it working currently: https://stackblitz.com/edit/ngx-highlightjs-kjqjwf

EDIT: as it stands, I think I have this pretty close. I can write into the field and it'll update the content on the model. I still have some issues though.

On the directive, this function runs when I hit Enter after a space (seems intermittent): highlightTextContent(). When that runs, I find that the cursor jumps back to the top of the editable area (because the content has all totally changed). It's possible I could hook into this function (maybe) and reset the cursor after the redraw, but might need a bit of help getting the right properties exposed....

HighlightResult returns `relevance` instead of `r`

Bug Report or Feature Request (mark with an x)

- [x] bug report -> please search issues before submitting
- [ ] feature request
- [ ] question

The (highlighted) response interface has a field r, however, the js object has a field relevance

TypeError: language is not a function

Bug Report or Feature Request (mark with an x)

- [ x] bug report -> please search issues before submitting
- [ ] feature request
- [ ] question

OS and Version?

macOS Mojave

Repro steps

By installing the library with Option 1 method.
Languages imported in func are undefined

The log given by the failure

ERROR TypeError: language is not a function
    at Object.registerLanguage (highlight.js:752)
    at HighlightJS.push../node_modules/ngx-highlightjs/fesm5/ngx-highlightjs.js.HighlightJS.registerLanguage (ngx-highlightjs.js:193)
    at ngx-highlightjs.js:28
    at Array.map (<anonymous>)
    at new HighlightJS (ngx-highlightjs.js:23)
    at HighlightJS_Factory (ngx-highlightjs.js:234)

Desired functionality

It should load languages correctly
my code is the same as the demo:


/**
 * Import every language you wish to highlight here
 * NOTE: The name of each language must match the file name its imported from
 */
export function hljsLanguages() {
  return [
    {name: 'typescript', func: typescript},
    {name: 'scss', func: scss},
    {name: 'xml', func: xml}
  ];
}```


### Mention any other details that might be useful
<!-- Please include a link to the repo if this is related to an OSS project. -->

Stackblitz errors

Bug Report or Feature Request (mark with an x)

- [ ] bug report -> please search issues before submitting
- [ ] feature request
- [X] question

Mention any other details that might be useful

I noticed the Stackblitz demo seems to have broken links to the highlight.js/lib/ folder.

I was having trouble getting my own Stackblitz demo to work and tracked it back to this. Would you mind taking a look? Thanks for reading.

AOT build error in Angular 6

In version 2.0.1 AOT throws this error ERROR in Error during template compile of 'AppModule' Function calls are not supported in decorators but 'HighlightModule' was called.

Registering a custom language when using ngx-highlightjs

Bug Report or Feature Request (mark with an x)

- [ ] bug report -> please search issues before submitting
- [ ] feature request
- [x] question

Not sure how I can hljs.registerLanguage() while loading definition from an external file in angular-/cli project. Would you be so kind to provide instructions? Thank you.

How to add a href html link

Hi,
I would like to add a <a href=""> element in my <code> tag which is displayed as an actual hyperlink.

How can I achieve this?

Best regards
Kilian

TypeError: Cannot read property 'disconnect' of undefined

- [x ] bug report -> please search issues before submitting

Versions

ngx-highlight version 3.0.2
Angular cli 7

After I do a universal build and local server serve:ssr, I get the following error when I navigate to a page with ngx-highlight

TypeError: Cannot read property 'disconnect' of undefined
    at HighlightChildren.ngOnDestroy (webpack://app/./node_modules/ngx-highlightjs/fesm5/ngx-highlightjs.js?:418:24)
    at callProviderLifecycles (webpack://app/./node_modules/@angular/core/fesm5/core.js?:21328:18)
    at callElementProvidersLifecycles (webpack://app/./node_modules/@angular/core/fesm5/core.js?:21296:13)
    at callLifecycleHooksChildrenFirst (webpack://app/./node_modules/@angular/core/fesm5/core.js?:21286:29)
    at destroyView (webpack://app/./node_modules/@angular/core/fesm5/core.js?:22348:5)
    at callViewAction (webpack://app/./node_modules/@angular/core/fesm5/core.js?:22474:13)
    at execEmbeddedViewsAction (webpack://app/./node_modules/@angular/core/fesm5/core.js?:22417:17)
    at destroyView (webpack://app/./node_modules/@angular/core/fesm5/core.js?:22346:5)
    at callViewAction (webpack://app/./node_modules/@angular/core/fesm5/core.js?:22474:13)
    at execEmbeddedViewsAction (webpack://app/./node_modules/@angular/core/fesm5/core.js?:22417:17)

Sample angular 7 program with latest ngx-highlightjs module

The stackblitz code showing very old code 1.x version. can you provide with latest example code.

Bug Report or Feature Request (mark with an x)

- [ ] bug report -> please search issues before submitting
- [ ] feature request
- [ ] question

OS and Version?

Versions

Repro steps

The log given by the failure

Desired functionality

Mention any other details that might be useful

How to enable instant highlighting?

Bug Report or Feature Request (mark with an x)

- [ ] bug report -> please search issues before submitting
- [ ] feature request
- [x] question

OS and Version?

Windows 10

Versions

Repro steps

My Code:

<textarea [(ngModel)]="highlightCode"></textarea>

"

<code #code highlight [textContent]="highlightCode">
"

ngAfterViewInit() {
hljs.highlightBlock(this.codeElement.nativeElement);
}

The log given by the failure

Desired functionality

I want to enable instant highlighting in the code tag if user add text into textarea.

Mention any other details that might be useful

Python instructions not getting syntax-highlight if inside same code block

Bug Report or Feature Request (mark with an x)

- [ x] bug report -> please search issues before submitting
- [ ] feature request
- [ ] question

OS and Version?

Archlinux

Versions

Angular CLI: 1.5.0
Node: 9.5.0
OS: linux x64
Angular: 5.1.2
... animations, common, compiler, compiler-cli, core, forms
... http, language-service, platform-browser
... platform-browser-dynamic, router

@angular/cdk: 5.0.2
@angular/cli: 1.5.0
@angular/flex-layout: 2.0.0-beta.12
@angular/material: 5.0.2
@angular-devkit/build-optimizer: 0.0.36
@angular-devkit/core: 0.0.22
@angular-devkit/schematics: 0.0.42
@ngtools/json-schema: 1.1.0
@ngtools/webpack: 1.8.0
@schematics/angular: 0.1.11
@schematics/schematics: 0.0.11
typescript: 2.4.2
webpack: 3.8.1

Repro steps

The following two python instructions won't get syntax-highlighed if they're in the same <pre><code>...</code></pre> block, but they're normally syntax-highlighted if we put each in a different code block:

k_means = cluster.KMeans(n_clusters=2)
l = k_means.fit(X)

This error can be reproduced on stackblitz.

Support Angular V6 and RXJS V6 - error TS2307: Cannot find module 'rxjs-compat/BehaviorSubject'

- [ -] bug report -> please search issues before submitting
- [x ] feature request
- [ ] question

OS and Version?

macOs HighSierra

Versions

Angular CLI: 6.0.0
Node: 8.11.1
OS: darwin x64
Angular: 
... 

Package                      Version
------------------------------------------------------
@angular-devkit/architect    0.6.0
@angular-devkit/core         0.6.0
@angular-devkit/schematics   0.6.0
@schematics/angular          0.6.0
@schematics/update           0.6.0
rxjs                         6.1.0
typescript     

Repro steps

  1. update angular to v6
  2. this implicate to update rxjs to version 6

or try local the demo app of ngx-material-pages

  1. clone the repo https://github.com/AnthonyNahas/ngx-material-pages.git
  2. cd ngx-material-pages
  3. npm i && gulp link
  4. cd demo && npm i
  5. npm start or ng serve

The log given by the failure

> [email protected] start /Users/.../ngx-material-pages/demo
> ng serve

** NG Live Development Server is listening on localhost:4200, open your browser on http://localhost:4200/ **

Date: 2018-05-07T19:35:54.533ZERROR in node_modules/ngx-highlightjs/highlight.service.d.ts(1,10): error TS2305: Module '"/Users/.../ngx-material-pages/demo/node_modules/rxjs/BehaviorSubject"' has no exported member 'BehaviorSubject'.

Hash: node_modules/rxjs/BehaviorSubject.d.ts(1,15): error TS2307: Cannot find module 'rxjs-compat/BehaviorSubject'.041760bcb8281eba4132

Time: 
5580ms
chunk {inline} inline.bundle.js (inline) 3.85 kB [entry] [rendered]
chunk {main} main.bundle.js (main) 2.91 kB [initial] [rendered]
chunk {polyfills} polyfills.bundle.js (polyfills) 577 bytes [initial] [rendered]
chunk {styles} styles.bundle.js (styles) 881 kB [initial] [rendered]
chunk {vendor} vendor.bundle.js (vendor) 852 kB [initial] [rendered]
webpack: Failed to compile.

Desired functionality

to compile and serve, something like below...

** NG Live Development Server is listening on localhost:4200, open your browser on http://localhost:xxxx/ **
Date: 2018-05-07T19:41:29.730Z
Hash: ff55ace6328f73835229
Time: 11611ms
chunk {inline} inline.bundle.js (inline) 3.85 kB [entry] [rendered]
chunk {main} main.bundle.js (main) 109 kB [initial] [rendered]
chunk {polyfills} polyfills.bundle.js (polyfills) 554 kB [initial] [rendered]
chunk {styles} styles.bundle.js (styles) 881 kB [initial] [rendered]
chunk {vendor} vendor.bundle.js (vendor) 17.1 MB [initial] [rendered]

webpack: Compiled successfully.

Mention any other details that might be useful

here is the official migration guide of rxjs v6

Select programming language

Bug Report or Feature Request (mark with an x)

- [ ] bug report -> please search issues before submitting
- [X] feature request
- [ ] question

OS and Version?

Ubuntu Linux 17.10

Versions

Angular CLI: 1.5.0
Node: 8.9.3
OS: linux x64
Angular: 5.1.2
... animations, common, compiler, compiler-cli, core, forms
... http, language-service, platform-browser
... platform-browser-dynamic, router

@angular/cli: 1.5.0
@angular-devkit/build-optimizer: 0.0.36
@angular-devkit/core: 0.0.22
@angular-devkit/schematics: 0.0.42
@ngtools/json-schema: 1.1.0
@ngtools/webpack: 1.8.0
@schematics/angular: 0.1.11
@schematics/schematics: 0.0.11
typescript: 2.4.2
webpack: 3.8.1

Desired functionality

It should be a great improvement to select the programming language.
For example:

<pre><code highlight [code]="someJavaCode" [language]="java"></code></pre>
<pre><code highlight [code]="someConsoleCommands" [language]="console"></code></pre>

Now, if you write console commands in your text, you have different colors in the same line which looks very strange.

Mention any other details that might be useful

No languages were registred inside lazy module.

Bug Report or Feature Request (mark with an x)

- [x] bug report -> please search issues before submitting
- [ ] feature request
- [ ] question

It looks like that HightlightModule can't be used inside lazy loaded module.

OS and Version?

macOS 10.14.2

Versions

ng --version

 _                      _                 ____ _     ___
/ \   _ __   __ _ _   _| | __ _ _ __     / ___| |   |_ _|

/ โ–ณ \ | '_ \ / | | | | |/ _ | '__| | | | | | |
/ ___ | | | | (
| | || | | (| | | | || | | |
// __| ||_, |_,||_,|| _|||
|___/

Angular CLI: 7.2.2
Node: 10.15.0
OS: darwin x64
Angular: 7.2.2
... animations, cli, common, compiler, compiler-cli, core, forms
... language-service, platform-browser, platform-browser-dynamic
... router

Package Version

@angular-devkit/architect 0.12.2
@angular-devkit/build-angular 0.12.2
@angular-devkit/build-optimizer 0.12.2
@angular-devkit/build-webpack 0.12.2
@angular-devkit/core 7.2.2
@angular-devkit/schematics 7.2.2
@ngtools/webpack 7.2.2
@schematics/angular 7.2.2
@schematics/update 0.12.2
rxjs 6.3.3
typescript 3.2.4
webpack 4.28.4

Repro steps

The log given by the failure

core.js:15714 ERROR Error: Uncaught (in promise): Error: [HighlightJS]: No languages were registered!
Error: [HighlightJS]: No languages were registered!
at new HighlightJS (ngx-highlightjs.js:30)
at HighlightJS_Factory (ngx-highlightjs.js:227)
at callFactory (core.js:21182)
at createProviderInstance (core.js:21140)
at resolveNgModuleDep (core.js:21115)
at NgModuleRef
.push../node_modules/@angular/core/fesm5/core.js.NgModuleRef
.get (core.js:21809)
at resolveNgModuleDep (core.js:21120)
at NgModuleRef_.push../node_modules/@angular/core/fesm5/core.js.NgModuleRef_.get (core.js:21809)
at resolveDep (core.js:22180)
at createClass (core.js:22054)
at resolvePromise (zone.js:831)
at resolvePromise (zone.js:788)
at zone.js:892
at ZoneDelegate.push../node_modules/zone.js/dist/zone.js.ZoneDelegate.invokeTask (zone.js:423)
at Object.onInvokeTask (core.js:17280)
at ZoneDelegate.push../node_modules/zone.js/dist/zone.js.ZoneDelegate.invokeTask (zone.js:422)
at Zone.push../node_modules/zone.js/dist/zone.js.Zone.runTask (zone.js:195)
at drainMicroTaskQueue (zone.js:601)

Desired functionality

Mention any other details that might be useful

Need a help

I followed the https://stackblitz.com/edit/ngx-highlightjs-all?file=styles.css sample, but I get the bellow error

Error details
core.js:1448 ERROR TypeError: Object(...) is not a function
at HighlightDirective.highlightChildren (ngx-highlightjs.js:269)
at HighlightDirective.highlightTextContent (ngx-highlightjs.js:239)
at SafeSubscriber.eval [as _next] (ngx-highlightjs.js:218)
at SafeSubscriber.__tryOrUnsub (Subscriber.js:238)
at SafeSubscriber.next (Subscriber.js:185)
at Subscriber._next (Subscriber.js:125)
at Subscriber.next (Subscriber.js:89)
at SafeSubscriber.__tryOrUnsub (Subscriber.js:239)
at SafeSubscriber.next (Subscriber.js:186)
at TakeSubscriber._next (take.js:83)

Package jsosn
{
"name": "angular-template",
"description": "",
"dependencies": {
"@agm/core": "^1.0.0-beta.3",
"@angular/animations": "5.2.9",
"@angular/cdk": "5.2.4",
"@angular/common": "5.2.9",
"@angular/compiler": "5.2.9",
"@angular/core": "5.2.9",
"@angular/flex-layout": "5.0.0-beta.13",
"@angular/forms": "5.2.9",
"@angular/http": "5.2.9",
"@angular/material": "5.2.4",
"@angular/platform-browser": "5.2.9",
"@angular/platform-browser-dynamic": "5.2.9",
"@angular/platform-server": "^5.2.9",
"@angular/router": "5.1.1",
"@ngx-progressbar/core": "^4.3.0",
"@types/quill": "^1.3.6",
"angular2-text-mask": "^8.0.5",
"classlist.js": "1.1.20150312",
"core-js": "2.4.1",
"ngx-highlightjs": "^2.1.1",
"ngx-image-cropper": "^0.2.5",
"quill": "^1.3.6",
"rxjs": "5.5.2",
"web-animations-js": "2.3.1",
"zone.js": "0.8.12"
},
"version": "0.0.0",
"license": "MIT",
"scripts": {
"ng": "ng",
"start": "ng serve",
"build": "ng build",
"test": "ng test",
"lint": "ng lint",
"e2e": "ng e2e"
},
"private": true,
"devDependencies": {
"@angular/cli": "1.6.7",
"@angular/compiler-cli": "^5.0.0",
"@angular/language-service": "^5.0.0",
"@types/jasmine": "~2.5.53",
"@types/jasminewd2": "~2.0.2",
"@types/node": "~6.0.60",
"codelyzer": "~3.0.1",
"jasmine-core": "~2.6.2",
"jasmine-spec-reporter": "~4.1.0",
"karma": "~1.7.0",
"karma-chrome-launcher": "~2.1.1",
"karma-cli": "~1.0.1",
"karma-coverage-istanbul-reporter": "^1.2.1",
"karma-jasmine": "~1.1.0",
"karma-jasmine-html-reporter": "^0.2.2",
"protractor": "~5.1.2",
"ts-node": "~3.0.4",
"tslint": "~5.3.2",
"typescript": "~2.4.2"
}
}

Here id my code
Module
import { HighlightModule } from 'ngx-highlightjs';
HighlightModule.forRoot({ theme: 'default' }),

Component

code = `

Using highlight="all"

First code

      
function myFunction() {
  document.getElementById("demo1").innerHTML = "Hello there!";
  document.getElementById("demo2").innerHTML = "How are you?";
}
      
    

Second code

      
.wrapper {
  flex: 1;
  display: flex;
  flex-direction: column;
}

.container {
flex: 1;
margin: 1em;
position: relative;
max-width: 100%;
display: flex;
flex-direction: column;
align-items: center;
}

`;

NullInjectorError: No provider for InjectorRef! when using in a lazy load module

Bug Report or Feature Request (mark with an x)

- [x] bug report -> please search issues before submitting
- [ ] feature request
- [ ] question

OS and Version?

Mac OS X


### Versions
@angular/cli: 1.5.2
@angular/flex-layout: 2.0.0-beta.10-4905443
@angular/material: 5.0.0-rc0
@angular-devkit/build-optimizer: 0.0.33
@angular-devkit/core: 0.0.20
@angular-devkit/schematics: 0.0.36
@ngtools/json-schema: 1.1.0
@ngtools/webpack: 1.8.2
@schematics/angular: 0.1.5
typescript: 2.4.2
webpack: 3.8.1
 @angular/cdk: 5.0.0-rc0
@angular/cli: 1.5.2
@angular/flex-layout: 2.0.0-beta.10-4905443
@angular/material: 5.0.0-rc0
@angular-devkit/build-optimizer: 0.0.33
@angular-devkit/core: 0.0.20
@angular-devkit/schematics: 0.0.36
@ngtools/json-schema: 1.1.0
@ngtools/webpack: 1.8.2
@schematics/angular: 0.1.5
typescript: 2.4.2
webpack: 3.8.1
 @angular/cdk: 5.0.0-rc0
@angular/cli: 1.5.2
@angular/flex-layout: 2.0.0-beta.10-4905443
@angular/material: 5.0.0-rc0
@angular-devkit/build-optimizer: 0.0.33
@angular-devkit/core: 0.0.20
@angular-devkit/schematics: 0.0.36
@ngtools/json-schema: 1.1.0
@ngtools/webpack: 1.8.2
@schematics/angular: 0.1.5
typescript: 2.4.2
webpack: 3.8.1

When running this on a submodule I get this error:

BlogArticleComponent.html:9 ERROR Error: StaticInjectorError[ElementRef]: StaticInjectorError[ElementRef]: NullInjectorError: No provider for ElementRef!

when I write HighlightModule.forRoot({ theme: 'agate' }),
in my module, it shows the above error. if i move my module to the root module app.module.ts it works fine. Is there a way to have this load in a child module and not be in the root?

Support For Angular 4

- [ x] bug report -> please search issues before submitting
- [ ] feature request
- [ ] question

OS and Version?

Versions

@angular/cli: 1.0.1
node: 7.10.0
"os": win32 x64
"angular/animations": 4.1.0
"angular/common": 4.1.0
"angular/compiler": 4.1.0
'angular/core": 4.1.0
"angular/forms": 4.1.0
"angular/http": 4.1.0
"angular/platform-browser": 4.1.0
"angular/platform-browser-dynamic": 4.1.0
"angular/platform-server": 4.1.0
"angular/router": 4.1.0
"angular/cli": 1.0.1
"angular/compiler-cli": 4.1.0

Desired functionality

ERROR in Metadata version mismatch for module xxx/web/node_modules/ngx-highlightjs/ngx-highlightjs.d.ts, found version 4, expected 3, resolving symbol

languages in HighLightOptions should be of type "HighlightLanguage[]"

Bug Report or Feature Request (mark with an x)

- [x] bug report -> please search issues before submitting
- [ ] feature request
- [ ] question

OS and Version?

Versions

Repro steps

The log given by the failure

Desired functionality

Currently, the type of languages is Func. I guess it is a typo. It would show intent better if the type is HighlightLanguage[]

Mention any other details that might be useful

After updating angular 5 giving below error

Bug Report or Feature Request (mark with an x)

-I am using   "ngx-highlightjs": "^1.4.0", version 
- [ ] bug report -> ERROR in Error: Metadata version mismatch for module D:/Projects/angular-components/node_modules/ngx-highlightjs/ngx-highlightjs.d.ts, found version 4, e
xpected 3, resolving symbol AppModule in D:/Projects/angular-components/src/app/app.module.ts

OS and Version?

Windows 10.

Versions

-I am using "ngx-highlightjs": "^1.4.0", version

restarting Highlighting automatically

Bug Report or Feature Request (mark with an x)

- [ ] bug report -> please search issues before submitting
- [ ] feature request
- [x] question

OS and Version?

Ubuntu 18.04

Versions

Angular CLI: 6.1.2
Node: 10.3.0
OS: linux x64
Angular: 6.1.0

Desired functionality

I have an api that responds with json content and I create blog posts with these data.
The problem is that when the user moves to a post by using the angular router (and the json is obtained from the api) the code is not highlighted, then to be able to highlight it the page needs to be reloaded.
How can I restart the highlight when the router moves, with no need to reload the page?

Thanks in advance!

Theme option in directive

- [ ] bug report -> please search issues before submitting
- [x] feature request
- [ ] question

It would be great if the directive has a way of specifying different themes. Something like:

<code highlight [theme]="'github'" ...
<code highlight [theme]="'agate'" ...

Imports for highlight.js files doesn't works

For me, import doesn't work, but with require it's ok.

For example, with Angular 7 without Angular/cli:

export function hljsLanguages() {
    return [
        { name: 'typescript', func: require('highlight.js/lib/languages/typescript') },
        { name: 'javascript', func: require('highlight.js/lib/languages/javascript') },
        { name: 'scss', func: require('highlight.js/lib/languages/scss') },
        { name: 'xml', func: require('highlight.js/lib/languages/xml') }
    ];
}

Using HighlightModule in a complex app's submodule

Here's the scenario:

  • huge app
  • uses routing
  • all routing uses lazy modules
  • the app contains a module for previewing highlighted code which uses your lib for highlighting (let's call it CodePreviewModule which contains a component CodePreviewComponent)
  • therefore not all modules in the app need the HighlightModule, only the CodePreviewModule needs it

Could you suggest a setup where your lib is only loaded wherever needed. Now it only works if it's loaded in the root module (e.g. app module) and again in the CodePreviewModule.

Will add more details in due time, but first please let me know if this is a config/usage issue. Thanks.

t.filter is not a function

Today, I tried to use this but i got this error
core.es5.js:1020 ERROR TypeError: t.filter is not a function
at Object.g [as highlightAuto] (highlight.pack.js:formatted:298)
at HighlightDirective.webpackJsonp.../../../../ngx-highlightjs/ngx-highlightjs.es5.js.HighlightDirective.highlightElement (ngx-highlightjs.es5.js:1578)
at SafeSubscriber._next (ngx-highlightjs.es5.js:1530)
at SafeSubscriber.webpackJsonp.../../../../ngx-highlightjs/ngx-highlightjs.es5.js.SafeSubscriber.__tryOrSetError (ngx-highlightjs.es5.js:611)
at SafeSubscriber.webpackJsonp.../../../../ngx-highlightjs/ngx-highlightjs.es5.js.SafeSubscriber.next (ngx-highlightjs.es5.js:551)
at Subscriber.webpackJsonp.../../../../ngx-highlightjs/ngx-highlightjs.es5.js.Subscriber._next (ngx-highlightjs.es5.js:489)
at Subscriber.webpackJsonp.../../../../ngx-highlightjs/ngx-highlightjs.es5.js.Subscriber.next (ngx-highlightjs.es5.js:453)
at DoSubscriber.webpackJsonp.../../../../ngx-highlightjs/ngx-highlightjs.es5.js.DoSubscriber._next (ngx-highlightjs.es5.js:1475)
at DoSubscriber.webpackJsonp.../../../../ngx-highlightjs/ngx-highlightjs.es5.js.Subscriber.next (ngx-highlightjs.es5.js:453)
at TakeSubscriber.webpackJsonp.../../../../ngx-highlightjs/ngx-highlightjs.es5.js.TakeSubscriber._next (ngx-highlightjs.es5.js:1291)
please help!

Warning during compilation under Angular 8 with IVY enabled

Bug Report or Feature Request (mark with an x)

- [x] bug report -> please search issues before submitting
- [ ] feature request
- [ ] question

OS and Version?

macOS HighSierra

Versions

Angular CLI: 8.0.2
Node: 11.14.0
OS: darwin x64
Angular: 8.0.0
... cdk, common, compiler, compiler-cli, core, forms
... language-service, platform-browser, platform-browser-dynamic
... router

Package                            Version
------------------------------------------------------------
@angular-devkit/architect          0.800.2
@angular-devkit/build-angular      0.800.2
@angular-devkit/build-ng-packagr   0.800.2
@angular-devkit/build-optimizer    0.800.2
@angular-devkit/build-webpack      0.800.2
@angular-devkit/core               8.0.2
@angular-devkit/schematics         8.0.2
@angular/cli                       8.0.2
@ngtools/json-schema               1.1.0
@ngtools/webpack                   8.0.2
@schematics/angular                8.0.2
@schematics/update                 0.800.2
ng-packagr                         5.3.0
rxjs                               6.5.2
typescript                         3.4.5
webpack                            4.30.0

When compiling this library under Angular 8 with IVY enabled warning appears:

WARNING in Entry point 'ngx-highlightjs' contains deep imports into 'highlight.js/lib/highlight.js'.
This is probably not a problem, but may cause the compilation of entry points to be out of order.

Run time issue

I get this issue in runtime

ERROR TypeError: "Object(...) is not a function"

Cannot read property 'highlightAuto' of undefined

Bug Report or Feature Request (mark with an x)

- [x] bug report -> please search issues before submitting
- [ ] feature request
- [ ] question

OS and Version?

Windows 10

Versions

Angular CLI: 8.0.3
Node: 10.13.0
OS: win32 x64
Angular: 8.0.2

Repro steps

<pre><code [highlight]="someCode"></code></pre>

The log given by the failure

CodeComponent.html:2 ERROR TypeError: Cannot read property 'highlightAuto' of undefined
    at ngx-highlightjs.js:288
    at ZoneDelegate.push.../../node_modules/zone.js/dist/zone.js.ZoneDelegate.invoke (zone.js:391)
    at Zone.push.../../node_modules/zone.js/dist/zone.js.Zone.run (zone.js:150)
    at NgZone.push.../../node_modules/@angular/core/fesm5/core.js.NgZone.runOutsideAngular (core.js:24308)
    at Highlight.push.../../node_modules/ngx-highlightjs/fesm5/ngx-highlightjs.js.Highlight.highlightElement (ngx-highlightjs.js:283)
    at Highlight.push.../../node_modules/ngx-highlightjs/fesm5/ngx-highlightjs.js.Highlight.ngOnChanges (ngx-highlightjs.js:260)
    at checkAndUpdateDirectiveInline (core.js:19337)
    at checkAndUpdateNodeInline (core.js:27597)
    at checkAndUpdateNode (core.js:27559)
    at debugCheckAndUpdateNode (core.js:28193)

Desired functionality

Mention any other details that might be useful

Use with innerHTML?

Bug Report or Feature Request (mark with an x)

- [ ] bug report -> please search issues before submitting
- [ ] feature request
- [ ] question

OS and Version?

Versions

Repro steps

The log given by the failure

Desired functionality

Mention any other details that might be useful

Missing ElementRef

Bug Report or Feature Request (mark with an x)

- [ x] bug report -> please search issues before submitting
- [ ] feature request
- [ ] question

OS and Version?

Versions

Angular CLI: 6.0.8
Node: 10.6.0
OS: linux x64
Angular:
...

Package Version

@angular-devkit/architect 0.6.8
@angular-devkit/core 0.6.8
@angular-devkit/schematics 0.6.8
@angular/cli 6.0.8
@angular/common 6.0.9
@angular/core 6.0.9
@angular/platform-browser 6.0.9
@schematics/angular 0.6.8
@schematics/update 0.6.8
rxjs 6.2.2
typescript 2.7.2

Repro steps

Followed the instructions, which seem pretty simple but receive the following error in the logs

The log given by the failure

ERROR Error: StaticInjectorError(AppModule)[HighlightDirective -> ElementRef]:
StaticInjectorError(Platform: core)[HighlightDirective -> ElementRef]:
NullInjectorError: No provider for ElementRef!
at NullInjector.push../node_modules/@angular/core/fesm5/core.js.NullInjector.get (core.js:1034)
at resolveToken (core.js:1271)
at tryResolveToken (core.js:1216)
at StaticInjector.push../node_modules/@angular/core/fesm5/core.js.StaticInjector.get (core.js:1113)
at resolveToken (core.js:1271)
at tryResolveToken (core.js:1216)
at StaticInjector.push../node_modules/@angular/core/fesm5/core.js.StaticInjector.get (core.js:1113)
at resolveNgModuleDep (core.js:8161)
at NgModuleRef_.push../node_modules/@angular/core/fesm5/core.js.NgModuleRef_.get (core.js:8849)
at resolveDep (core.js:9214)

Desired functionality

Mention any other details that might be useful

Most likely my fault I'm sure, but a little lost and confused

Do not throw an error if [highlight] input got an undefined value

Bug Report or Feature Request (mark with an x)

- [x] bug report -> please search issues before submitting
- [ ] feature request
- [ ] question

OS and Version?

Windows 7

Versions

Angular CLI: 7.3.9
Node: 8.11.1
OS: win32 x64
Angular: 7.2.15
... animations, common, compiler, compiler-cli, core, forms
... http, language-service, platform-browser
... platform-browser-dynamic, router

Package Version

@angular-devkit/architect 0.13.9
@angular-devkit/build-angular 0.13.9
@angular-devkit/build-optimizer 0.13.9
@angular-devkit/build-webpack 0.13.9
@angular-devkit/core 7.3.9
@angular-devkit/schematics 7.3.9
@angular/cdk 7.3.7
@angular/cli 7.3.9
@angular/material 7.3.7
@ngtools/webpack 7.3.9
@schematics/angular 7.3.9
@schematics/update 0.13.9
rxjs 6.5.1
typescript 3.2.4
webpack 4.29.0

Repro steps

I use the directive in a lazy module and as stream:
<pre><code #code *ngIf="showCode" [highlight]="code$ | async"></code></pre>

The log given by the failure

The directive does it's work, but I see the following console error:

ERROR TypeError: Cannot read property 'replace' of null
    at escape (highlight.js:62)
    at Object.highlightAuto (highlight.js:624)
    at HighlightJS.push../node_modules/ngx-highlightjs/fesm5/ngx-highlightjs.js.HighlightJS.highlightAuto (ngx-highlightjs.js:91)
    at ngx-highlightjs.js:288
    at ZoneDelegate.push../node_modules/zone.js/dist/zone.js.ZoneDelegate.invoke (zone.js:391)
    at Zone.push../node_modules/zone.js/dist/zone.js.Zone.run (zone.js:150)
    at NgZone.push../node_modules/@angular/core/fesm5/core.js.NgZone.runOutsideAngular (core.js:17258)
    at Highlight.push../node_modules/ngx-highlightjs/fesm5/ngx-highlightjs.js.Highlight.highlightElement (ngx-highlightjs.js:283)
    at Highlight.push../node_modules/ngx-highlightjs/fesm5/ngx-highlightjs.js.Highlight.ngOnChanges (ngx-highlightjs.js:260)
    at checkAndUpdateDirectiveInline (core.js:22095)

Desired functionality

no error

less-than and greater-than in html make ngx-highlightjs ineffective

Bug Report or Feature Request (mark with an x)

- [ ] bug report -> please search issues before submitting
- [ ] feature request
- [ ] question

OS and Version?

Versions

Repro steps

The log given by the failure

Desired functionality

Mention any other details that might be useful

highlight="all" applying 'hljs' class on the container instead of the code elements

Bug Report or Feature Request (mark with an x)

- [x] bug report -> please search issues before submitting
- [ ] feature request
- [ ] question

OS and Version?

Linux archlinux 4.13.12-1-ARCH #1 SMP PREEMPT Wed Nov 8 11:54:06 CET 2017 x86_64 GNU/Linux

Versions

Angular CLI: 1.5.0
Node: 9.2.0
OS: linux x64
Angular: 5.1.2
... animations, common, compiler, compiler-cli, core, forms
... http, language-service, platform-browser
... platform-browser-dynamic, router

Repro steps

<div highlight="pre code" innerHtml="{{ article.text }}"></div>

Below is an example of a text to highlight:

<pre>
<code class="language-javascript">var s2 = ee.ImageCollection('COPERNICUS/S2');</code></pre>

Mention any other details that might be useful

Both highlight="all" and highlight="pre code" when applied on the parent of the code to highlight (i.e. on the div) tend to apply the style on the whole div instead of applying it on each individual pre > code. In fact using the code above I got the whole div with a background: #f8f8f8.
Is this the normal behaviour to expect?

Another problem I've observed is that only the first occurence of pre>code was being attributed the classes hljs-*, and was therefore the only one to be syntax-highlighted.

Thanks.

Refused to execute do to MIME type

Bug Report or Feature Request (mark with an x)

- [x ] bug report -> please search issues before submitting
- [ ] feature request
- [ ] question

OS and Version?

Sierra 10.12.6

Versions

Package Version

angular-devkit/architect 0.6.3
angular-devkit/build-angular 0.6.3
angular-devkit/build-optimizer 0.6.3
angular-devkit/core 0.6.3
angular-devkit/schematics 0.6.3
angular/cli 6.0.3
angular/flex-layout 6.0.0-beta.15
ngtools/webpack 6.0.3
schematics/angular 0.6.3
schematics/update 0.6.3
rxjs 6.1.0
typescript 2.7.2
webpack 4.8.3

Repro steps

I copied your stackblitz code directly but get these errors in the console:

Refused to apply style from 'http://localhost:4200/assets/lib/hljs/styles/github.css' because its MIME type ('text/html') is not a supported stylesheet MIME type, and strict MIME checking is enabled.

Refused to execute script from 'http://localhost:4200/assets/lib/hljs/highlight.pack.js' because its MIME type ('text/html') is not executable, and strict MIME type checking is enabled.

The log given by the failure

Desired functionality

Mention any other details that might be useful

Looks like its related to angular/angular-cli#10325

Highlight example code in one line in IE11 with lazy module

Bug Report or Feature Request (mark with an x)

- [x] bug report -> please search issues before submitting
- [ ] feature request
- [ ] question

OS and Version?

Windows 7, 8 or 10

Versions

Angular CLI: 1.7.4/^6
Node: 10.11.0
Angular: 5.2.11/^6
ngx-highlightjs: 1.4.1 and above

Repro steps

Run stackblitz example or other example/project with lazy module on IE11

windev1802eval running 2018-09-22 10-36-32

The log given by the failure

Desired functionality

Mention any other details that might be useful

Using inside ng-boostrap tab does not work well when switching tabs

Bug Report or Feature Request (mark with an x)

- [ x] bug report -> please search issues before submitting
- [ ] feature request
- [ ] question

OS and Version?

Linux Ubuntu 16.04 LTS

Versions

Angular CLI: 6.0.5
Node: 8.11.3
Angular: 6.0.0

Repro steps

  1. follow the "Usage" steps from the github repo
  2. the highlight works ok
  3. integrate ng-boostrap tabs
  4. integrate highlight inside one of the tabs: highlight works ok
  5. switch tabs: error when going back to a tab with highlighted code, that code "disappears" is not visible any more

Desired functionality

  • ngx-highlightjs should work also using ng-boostrap tabs

highlightChildren example

I add highlightChildren to div like this:
<div class="question-description" highlightChildren [innerHtml]="question.description | safeHtml"></div>
but noting work

@MurhafSousli

Is there anyway to use this module in a featured, lazy loaded module without having to load it in the app.module.ts?

- [x ] feature request
- [ x] question

OS and Version?

Versions

Angular version 7 cli

Lazy Loaded modules

Is there anyway to use this module in a featured, lazy loaded module without having to load it in the app.module.ts?

using with ngx-quill editor

Also I was wondering, in a case where you have a blog post edited by quill editor, which adds just a pre tag for code block.

How can we use this module in such a case to highlight the pre tags code blocks?

Thanks

Getting "TypeError: language is not a function" in unit tests

Bug Report or Feature Request (mark with an x)

- [x] bug report -> please search issues before submitting
- [ ] feature request
- [ ] question

OS and Version?

Linux Ubuntu

Versions

Angular CLI: 8.0.1
Node: 10.16.0
OS: linux x64
Angular: 8.0.0
... animations, common, compiler, compiler-cli, core, forms
... platform-browser, platform-browser-dynamic, router

Package                           Version
-----------------------------------------------------------
@angular-devkit/architect         0.800.1
@angular-devkit/build-angular     0.800.1
@angular-devkit/build-optimizer   0.800.1
@angular-devkit/build-webpack     0.800.1
@angular-devkit/core              8.0.1
@angular-devkit/schematics        8.0.1
@angular/cli                      8.0.1
@angular/http                     7.2.15
@ngtools/webpack                  8.0.1
@schematics/angular               8.0.1
@schematics/update                0.800.1
rxjs                              6.5.2
typescript                        3.4.5
webpack                           4.30.0

Repro steps

Create a unit test of a Component that uses the [highlight] directive.

The log given by the failure

error properties: Object({ ngDebugContext: DebugContext_({ view: Object({ def: Object({ factory: Function, nodeFlags: 674819, rootNodeFlags: 1, nodeMatchedQueries: 0, flags: 0, nodes: [ Object({ nodeIndex: 0, parent: null, renderParent: null, bindingIndex: 0, outputIndex: 0, checkIndex: 0, flags: 1, childFlags: 674819, directChildFlags: 542721, childMatchedQueries: 0, matchedQueries: Object({ }), matchedQueryIds: 0, references: Object({ }), ngContentIndex: null, childCount: 37, bindings: [ Object({ flags: 2, ns: '', name: 'ng-untouched', nonMinifiedName: 'ng-untouched', securityContext: undefined, suffix: undefined }), Object({ flags: 2, ns: '', name: 'ng-touched', nonMinifiedName: 'ng-touched', securityContext: undefined, suffix: undefined }), Object({ flags: 2, ns: '', name: 'ng-pristine', nonMinifiedName: 'ng-pristine', securityContext: undefined, suffix: undefined }), Object({ flags: 2, ns: '', name: 'ng-dirty', nonMinifiedName: 'ng-dirty', securityContext: undefined, suffix: undefined }), Object ...
at
at Object.registerLanguage (http://localhost:9876/karma_webpack/webpack:/node_modules/highlight.js/lib/highlight.js:749:1)
at HighlightJS.push../node_modules/ngx-highlightjs/fesm5/ngx-highlightjs.js.HighlightJS.registerLanguage (http://localhost:9876/karma_webpack/webpack:/node_modules/ngx-highlightjs/fesm5/ngx-highlightjs.js:191:13)
at http://localhost:9876/karma_webpack/webpack:/node_modules/ngx-highlightjs/fesm5/ngx-highlightjs.js:26:1
at
at new HighlightJS (http://localhost:9876/karma_webpack/webpack:/node_modules/ngx-highlightjs/fesm5/ngx-highlightjs.js:21:1)
at HighlightJS_Factory (http://localhost:9876/karma_webpack/webpack:/node_modules/ngx-highlightjs/fesm5/ngx-highlightjs.js:232:114)
at callFactory (http://localhost:9876/karma_webpack/webpack:/node_modules/@angular/core/fesm5/core.js:18508:1)
at createProviderInstance (http://localhost:9876/karma_webpack/webpack:/node_modules/@angular/core/fesm5/core.js:18466:1)
at resolveNgModuleDep (http://localhost:9876/karma_webpack/webpack:/node_modules/@angular/core/fesm5/core.js:18441:1)
at NgModuleRef
.push../node_modules/@angular/core/fesm5/core.js.NgModuleRef
.get (http://localhost:9876/karma_webpack/webpack:/node_modules/@angular/core/fesm5/core.js:19135:1)

Mention any other details that might be useful

In my unit test's module, I've imported HighlightModule.forRoot(highlightOptions) exactly in the same way I'm using it in my main app.module.ts (there it works).

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.