;
10 | }
11 | }
12 |
--------------------------------------------------------------------------------
/projects/demo/e2e/tsconfig.json:
--------------------------------------------------------------------------------
1 | {
2 | "extends": "../../../tsconfig.json",
3 | "compilerOptions": {
4 | "outDir": "../../../out-tsc/e2e",
5 | "module": "commonjs",
6 | "target": "es5",
7 | "types": [
8 | "jasmine",
9 | "jasminewd2",
10 | "node"
11 | ]
12 | }
13 | }
14 |
--------------------------------------------------------------------------------
/projects/demo/karma.conf.js:
--------------------------------------------------------------------------------
1 | // Karma configuration file, see link for more information
2 | // https://karma-runner.github.io/1.0/config/configuration-file.html
3 |
4 | module.exports = function (config) {
5 | config.set({
6 | basePath: '',
7 | frameworks: ['jasmine', '@angular-devkit/build-angular'],
8 | plugins: [
9 | require('karma-jasmine'),
10 | require('karma-chrome-launcher'),
11 | require('karma-jasmine-html-reporter'),
12 | require('karma-coverage-istanbul-reporter'),
13 | require('@angular-devkit/build-angular/plugins/karma')
14 | ],
15 | client: {
16 | clearContext: false // leave Jasmine Spec Runner output visible in browser
17 | },
18 | coverageIstanbulReporter: {
19 | dir: require('path').join(__dirname, '../../coverage/demo'),
20 | reports: ['html', 'lcovonly', 'text-summary'],
21 | fixWebpackSourcePaths: true
22 | },
23 | reporters: ['progress', 'kjhtml'],
24 | port: 9876,
25 | colors: true,
26 | logLevel: config.LOG_INFO,
27 | autoWatch: true,
28 | browsers: ['Chrome'],
29 | singleRun: false,
30 | restartOnFileChange: true
31 | });
32 | };
33 |
--------------------------------------------------------------------------------
/projects/demo/src/app/app.component.html:
--------------------------------------------------------------------------------
1 |
2 | Overview
3 |
4 | For full instructions on click
5 | here . To find out more about highlight.js can be found
10 | here
11 |
12 |
13 |
14 | Using the HighlightJsContent directive
15 |
16 |
17 | Use this directive to handle dynamic content which contains snippets. Both
18 | the sections below have innerHTML bound to the the sampleContent property.
19 |
20 | Raw pre code without highlighting
21 |
22 | Add dynamic content and highlight it
23 |
28 |
29 |
30 |
37 | add content
38 |
39 |
40 |
41 |
--------------------------------------------------------------------------------
/projects/demo/src/app/app.component.scss:
--------------------------------------------------------------------------------
1 | mat-card {
2 | margin: 12px;
3 | }
4 |
--------------------------------------------------------------------------------
/projects/demo/src/app/app.component.spec.ts:
--------------------------------------------------------------------------------
1 | import { TestBed, async } from '@angular/core/testing';
2 | import { AppComponent } from './app.component';
3 |
4 | describe('AppComponent', () => {
5 | beforeEach(async(() => {
6 | TestBed.configureTestingModule({
7 | declarations: [
8 | AppComponent
9 | ],
10 | }).compileComponents();
11 | }));
12 |
13 | it('should create the app', () => {
14 | const fixture = TestBed.createComponent(AppComponent);
15 | const app = fixture.debugElement.componentInstance;
16 | expect(app).toBeTruthy();
17 | });
18 |
19 | it(`should have as title 'demo'`, () => {
20 | const fixture = TestBed.createComponent(AppComponent);
21 | const app = fixture.debugElement.componentInstance;
22 | expect(app.title).toEqual('demo');
23 | });
24 |
25 | it('should render title in a h1 tag', () => {
26 | const fixture = TestBed.createComponent(AppComponent);
27 | fixture.detectChanges();
28 | const compiled = fixture.debugElement.nativeElement;
29 | expect(compiled.querySelector('h1').textContent).toContain('Welcome to demo!');
30 | });
31 | });
32 |
--------------------------------------------------------------------------------
/projects/demo/src/app/app.component.ts:
--------------------------------------------------------------------------------
1 | import { Component } from '@angular/core';
2 |
3 | @Component({
4 | selector: 'app-root',
5 | templateUrl: './app.component.html',
6 | styleUrls: ['./app.component.scss']
7 | })
8 | export class AppComponent {
9 | sampleContent = `
10 |
11 |
12 | class Greeter {
13 | constructor(public greeting: string) { }
14 | greet() {
15 | return "hello world";
16 | }
17 | };
18 |
19 |
20 |
21 |
22 | alert('Hello, World!');
23 |
24 |
25 | `;
26 |
27 | dynamicContent: string;
28 |
29 | addContent() {
30 | this.dynamicContent = this.sampleContent;
31 | }
32 | }
33 |
--------------------------------------------------------------------------------
/projects/demo/src/app/app.module.ts:
--------------------------------------------------------------------------------
1 | import { NgModule } from '@angular/core';
2 | import { MatButtonModule } from '@angular/material/button';
3 | import { MatCardModule } from '@angular/material/card';
4 | import { BrowserModule } from '@angular/platform-browser';
5 | import { BrowserAnimationsModule } from '@angular/platform-browser/animations';
6 | import { AngularHighlightJsModule } from 'angular-highlight-js';
7 | import { registerLanguage } from 'highlight.js';
8 | import javascript from 'highlight.js/lib/languages/javascript';
9 | import typescript from 'highlight.js/lib/languages/typescript';
10 | import { AppComponent } from './app.component';
11 |
12 | registerLanguage('typescript', typescript);
13 | registerLanguage('javascript', javascript);
14 |
15 | @NgModule({
16 | declarations: [AppComponent],
17 | imports: [
18 | BrowserModule,
19 | BrowserAnimationsModule,
20 | MatCardModule,
21 | MatButtonModule,
22 | AngularHighlightJsModule,
23 | ],
24 | providers: [],
25 | bootstrap: [AppComponent],
26 | })
27 | export class AppModule {}
28 |
--------------------------------------------------------------------------------
/projects/demo/src/assets/.gitkeep:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/JayChase/angular2-highlight-js/308564f10bdf097cef7e3974174c188d7d82f5c4/projects/demo/src/assets/.gitkeep
--------------------------------------------------------------------------------
/projects/demo/src/environments/environment.prod.ts:
--------------------------------------------------------------------------------
1 | export const environment = {
2 | production: true
3 | };
4 |
--------------------------------------------------------------------------------
/projects/demo/src/environments/environment.ts:
--------------------------------------------------------------------------------
1 | // This file can be replaced during build by using the `fileReplacements` array.
2 | // `ng build --prod` replaces `environment.ts` with `environment.prod.ts`.
3 | // The list of file replacements can be found in `angular.json`.
4 |
5 | export const environment = {
6 | production: false
7 | };
8 |
9 | /*
10 | * For easier debugging in development mode, you can import the following file
11 | * to ignore zone related error stack frames such as `zone.run`, `zoneDelegate.invokeTask`.
12 | *
13 | * This import should be commented out in production mode because it will have a negative impact
14 | * on performance if an error is thrown.
15 | */
16 | // import 'zone.js/dist/zone-error'; // Included with Angular CLI.
17 |
--------------------------------------------------------------------------------
/projects/demo/src/favicon.ico:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/JayChase/angular2-highlight-js/308564f10bdf097cef7e3974174c188d7d82f5c4/projects/demo/src/favicon.ico
--------------------------------------------------------------------------------
/projects/demo/src/index.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | Demo
6 |
7 |
8 |
9 |
10 |
14 |
18 |
19 |
20 |
21 |
22 |
23 |
--------------------------------------------------------------------------------
/projects/demo/src/main.ts:
--------------------------------------------------------------------------------
1 | import { enableProdMode } from '@angular/core';
2 | import { platformBrowserDynamic } from '@angular/platform-browser-dynamic';
3 |
4 | import { AppModule } from './app/app.module';
5 | import { environment } from './environments/environment';
6 |
7 | if (environment.production) {
8 | enableProdMode();
9 | }
10 |
11 | platformBrowserDynamic().bootstrapModule(AppModule)
12 | .catch(err => console.error(err));
13 |
--------------------------------------------------------------------------------
/projects/demo/src/polyfills.ts:
--------------------------------------------------------------------------------
1 | /**
2 | * This file includes polyfills needed by Angular and is loaded before the app.
3 | * You can add your own extra polyfills to this file.
4 | *
5 | * This file is divided into 2 sections:
6 | * 1. Browser polyfills. These are applied before loading ZoneJS and are sorted by browsers.
7 | * 2. Application imports. Files imported after ZoneJS that should be loaded before your main
8 | * file.
9 | *
10 | * The current setup is for so-called "evergreen" browsers; the last versions of browsers that
11 | * automatically update themselves. This includes Safari >= 10, Chrome >= 55 (including Opera),
12 | * Edge >= 13 on the desktop, and iOS 10 and Chrome on mobile.
13 | *
14 | * Learn more in https://angular.io/guide/browser-support
15 | */
16 |
17 | /***************************************************************************************************
18 | * BROWSER POLYFILLS
19 | */
20 |
21 | /** IE10 and IE11 requires the following for NgClass support on SVG elements */
22 | // import 'classlist.js'; // Run `npm install --save classlist.js`.
23 |
24 | /**
25 | * Web Animations `@angular/platform-browser/animations`
26 | * Only required if AnimationBuilder is used within the application and using IE/Edge or Safari.
27 | * Standard animation support in Angular DOES NOT require any polyfills (as of Angular 6.0).
28 | */
29 | // import 'web-animations-js'; // Run `npm install --save web-animations-js`.
30 |
31 | /**
32 | * By default, zone.js will patch all possible macroTask and DomEvents
33 | * user can disable parts of macroTask/DomEvents patch by setting following flags
34 | * because those flags need to be set before `zone.js` being loaded, and webpack
35 | * will put import in the top of bundle, so user need to create a separate file
36 | * in this directory (for example: zone-flags.ts), and put the following flags
37 | * into that file, and then add the following code before importing zone.js.
38 | * import './zone-flags.ts';
39 | *
40 | * The flags allowed in zone-flags.ts are listed here.
41 | *
42 | * The following flags will work for all browsers.
43 | *
44 | * (window as any).__Zone_disable_requestAnimationFrame = true; // disable patch requestAnimationFrame
45 | * (window as any).__Zone_disable_on_property = true; // disable patch onProperty such as onclick
46 | * (window as any).__zone_symbol__UNPATCHED_EVENTS = ['scroll', 'mousemove']; // disable patch specified eventNames
47 | *
48 | * in IE/Edge developer tools, the addEventListener will also be wrapped by zone.js
49 | * with the following flag, it will bypass `zone.js` patch for IE/Edge
50 | *
51 | * (window as any).__Zone_enable_cross_context_check = true;
52 | *
53 | */
54 |
55 | /***************************************************************************************************
56 | * Zone JS is required by default for Angular itself.
57 | */
58 | import 'zone.js/dist/zone'; // Included with Angular CLI.
59 |
60 |
61 | /***************************************************************************************************
62 | * APPLICATION IMPORTS
63 | */
64 |
--------------------------------------------------------------------------------
/projects/demo/src/styles.scss:
--------------------------------------------------------------------------------
1 | /* You can add global styles to this file, and also import other style files */
2 |
3 | html, body { height: 100%; }
4 | body { margin: 0; font-family: Roboto, "Helvetica Neue", sans-serif; }
5 |
--------------------------------------------------------------------------------
/projects/demo/src/test.ts:
--------------------------------------------------------------------------------
1 | // This file is required by karma.conf.js and loads recursively all the .spec and framework files
2 |
3 | import 'zone.js/dist/zone-testing';
4 | import { getTestBed } from '@angular/core/testing';
5 | import {
6 | BrowserDynamicTestingModule,
7 | platformBrowserDynamicTesting
8 | } from '@angular/platform-browser-dynamic/testing';
9 |
10 | declare const require: any;
11 |
12 | // First, initialize the Angular testing environment.
13 | getTestBed().initTestEnvironment(
14 | BrowserDynamicTestingModule,
15 | platformBrowserDynamicTesting()
16 | );
17 | // Then we find all the tests.
18 | const context = require.context('./', true, /\.spec\.ts$/);
19 | // And load the modules.
20 | context.keys().map(context);
21 |
--------------------------------------------------------------------------------
/projects/demo/tsconfig.app.json:
--------------------------------------------------------------------------------
1 | {
2 | "extends": "../../tsconfig.json",
3 | "compilerOptions": {
4 | "outDir": "../../out-tsc/app",
5 | "types": []
6 | },
7 | "include": [
8 | "src/**/*.d.ts"
9 | ],
10 | "files": [
11 | "src/main.ts",
12 | "src/polyfills.ts"
13 | ]
14 | }
15 |
--------------------------------------------------------------------------------
/projects/demo/tsconfig.spec.json:
--------------------------------------------------------------------------------
1 | {
2 | "extends": "../../tsconfig.json",
3 | "compilerOptions": {
4 | "outDir": "../../out-tsc/spec",
5 | "types": [
6 | "jasmine",
7 | "node"
8 | ]
9 | },
10 | "files": [
11 | "src/test.ts",
12 | "src/polyfills.ts"
13 | ],
14 | "include": [
15 | "src/**/*.spec.ts",
16 | "src/**/*.d.ts"
17 | ]
18 | }
19 |
--------------------------------------------------------------------------------
/projects/demo/tslint.json:
--------------------------------------------------------------------------------
1 | {
2 | "extends": "../../tslint.json",
3 | "rules": {
4 | "directive-selector": [true, "attribute", "app", "camelCase"],
5 | "component-selector": [true, "element", "app", "kebab-case"]
6 | }
7 | }
8 |
--------------------------------------------------------------------------------
/tsconfig.json:
--------------------------------------------------------------------------------
1 | {
2 | "compileOnSave": false,
3 | "compilerOptions": {
4 | "baseUrl": "./",
5 | "outDir": "./dist/out-tsc",
6 | "sourceMap": true,
7 | "declaration": false,
8 | "downlevelIteration": true,
9 | "emitDecoratorMetadata": true,
10 | "experimentalDecorators": true,
11 | "module": "esnext",
12 | "moduleResolution": "node",
13 | "importHelpers": true,
14 | "target": "es2015",
15 | "typeRoots": ["node_modules/@types"],
16 | "lib": ["es2018", "dom"],
17 | "paths": {
18 | "angular-highlight-js": [
19 | "projects/angular-highlight-js/src/public-api.ts"
20 | ],
21 | "angular-highlight-js/*": ["dist/angular-highlight-js/*"]
22 | }
23 | }
24 | }
25 |
--------------------------------------------------------------------------------
/tslint.json:
--------------------------------------------------------------------------------
1 | {
2 | "extends": "tslint:recommended",
3 | "rulesDirectory": ["codelyzer"],
4 | "rules": {
5 | "align": {
6 | "options": ["parameters", "statements"]
7 | },
8 | "array-type": false,
9 | "arrow-parens": false,
10 | "arrow-return-shorthand": true,
11 | "curly": true,
12 | "deprecation": {
13 | "severity": "warning"
14 | },
15 | "eofline": true,
16 | "import-blacklist": [true, "rxjs/Rx"],
17 | "import-spacing": true,
18 | "indent": {
19 | "options": ["spaces"]
20 | },
21 | "interface-name": false,
22 | "max-classes-per-file": false,
23 | "max-line-length": [true, 140],
24 | "member-access": false,
25 | "member-ordering": [
26 | true,
27 | {
28 | "order": [
29 | "static-field",
30 | "instance-field",
31 | "static-method",
32 | "instance-method"
33 | ]
34 | }
35 | ],
36 | "no-consecutive-blank-lines": false,
37 | "no-console": [true, "debug", "info", "time", "timeEnd", "trace"],
38 | "no-empty": false,
39 | "no-inferrable-types": [true, "ignore-params"],
40 | "no-non-null-assertion": true,
41 | "no-redundant-jsdoc": true,
42 | "no-switch-case-fall-through": true,
43 | "no-var-requires": false,
44 | "object-literal-key-quotes": [true, "as-needed"],
45 | "object-literal-sort-keys": false,
46 | "ordered-imports": false,
47 | "quotemark": [true, "single"],
48 | "semicolon": {
49 | "options": ["always"]
50 | },
51 | "space-before-function-paren": {
52 | "options": {
53 | "anonymous": "never",
54 | "asyncArrow": "always",
55 | "constructor": "never",
56 | "method": "never",
57 | "named": "never"
58 | }
59 | },
60 | "trailing-comma": false,
61 | "component-class-suffix": true,
62 | "contextual-lifecycle": true,
63 | "directive-class-suffix": true,
64 | "no-conflicting-lifecycle": true,
65 | "no-host-metadata-property": true,
66 | "no-input-rename": true,
67 | "no-inputs-metadata-property": true,
68 | "no-output-native": true,
69 | "no-output-on-prefix": true,
70 | "no-output-rename": true,
71 | "no-outputs-metadata-property": true,
72 | "template-banana-in-box": true,
73 | "template-no-negated-async": true,
74 | "typedef-whitespace": {
75 | "options": [
76 | {
77 | "call-signature": "nospace",
78 | "index-signature": "nospace",
79 | "parameter": "nospace",
80 | "property-declaration": "nospace",
81 | "variable-declaration": "nospace"
82 | },
83 | {
84 | "call-signature": "onespace",
85 | "index-signature": "onespace",
86 | "parameter": "onespace",
87 | "property-declaration": "onespace",
88 | "variable-declaration": "onespace"
89 | }
90 | ]
91 | },
92 | "use-lifecycle-interface": true,
93 | "use-pipe-transform-interface": true,
94 | "variable-name": {
95 | "options": ["ban-keywords", "check-format", "allow-pascal-case"]
96 | },
97 | "whitespace": {
98 | "options": [
99 | "check-branch",
100 | "check-decl",
101 | "check-operator",
102 | "check-separator",
103 | "check-type",
104 | "check-typecast"
105 | ]
106 | }
107 | }
108 | }
109 |
--------------------------------------------------------------------------------