Last active
March 28, 2024 02:52
-
-
Save MurhafSousli/6fd1b8fe940ded9f792335addb60c809 to your computer and use it in GitHub Desktop.
ngx-highlightjs code examples
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 { | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 { | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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'; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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