Skip to content

Instantly share code, notes, and snippets.

@MurhafSousli
Last active March 28, 2024 02:52
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save MurhafSousli/6fd1b8fe940ded9f792335addb60c809 to your computer and use it in GitHub Desktop.
Save MurhafSousli/6fd1b8fe940ded9f792335addb60c809 to your computer and use it in GitHub Desktop.
ngx-highlightjs code examples
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 {
}
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 {
}
import { HighlightPlusModule } from 'ngx-highlightjs';
@Component({
selector: 'app-root',
template: `
<pre>
<code [highlight]="codeUrl | codeFromUrl | async" language="ts"></code>
</pre>
`,
standalone: true,
imports: [HighlightPlusModule, CommonModule]
})
export class AppComponent {
codeUrl: string = 'assets/example-code.ts';
}
import { provideHttpClient, withFetch } from '@angular/common/http';
import { provideHighlightOptions } from 'ngx-highlightjs';
import { provideGistOptions } from 'ngx-highlightjs/plus';
import { environment } from '../environments/environment';
export const appConfig: ApplicationConfig = {
providers: [
provideHttpClient(withFetch()),
provideHighlightOptions({
fullLibraryLoader: () => import('highlight.js'),
lineNumbersLoader: () => import('ngx-highlightjs/line-numbers'),
themePath: 'assets/styles/androidstudio.css'
}),
provideGistOptions({
clientId: environment.clientId,
clientSecret: environment.clientSecret,
})
]
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment