Research
Security News
Malicious npm Package Targets Solana Developers and Hijacks Funds
A malicious npm package targets Solana developers, rerouting funds in 2% of transactions to a hardcoded address.
ngx-highlightjs
Advanced tools
Super easy to use, auto highlight code and auto-detect language
$ npm install --save ngx-highlightjs
Head to highlight.js download page and get your custom package bundle including only the languages you need.
Create new folder in src/assets/lib/hljs
and extract the downloaded zip file there.
If you are using SystemJS, you should also adjust your configuration to point to the UMD bundle.
In your systemjs config file, map needs to tell the System loader where to look for ngx-highlightjs
:
map: {
'ngx-highlightjs': 'node_modules/ngx-highlightjs/bundles/ngx-highlightjs.umd.js',
}
Import HighlightUmdModule
, you will need to import highlight.js script and style manually, Here is a working plunker.
Import HighlightModule
library from any module:
import { HighlightModule } from 'ngx-highlightjs';
@NgModule({
imports: [
// ...
HighlightModule.forRoot()
]
})
export class AppModule { }
default theme is github
, but you can choose any theme by HighlightModule.forRoot('theme-name')
with the .css
in the end
List of all available themes from highlight.js
forRoot(theme?, path?) function has two optional parameters:
'github'
'assets/lib/hljs'
Choose highlighting theme:
HighlightModule.forRoot('monokai-sublime');
Import from custom path
HighlightModule.forRoot('monokai-sublime', 'assets/js/highlight-js');
Now you can use the directive highlight
, you can:
<!-- Highlight target element -->
<pre><code highlight [textContent]="someCode"></code></pre>
<!-- Highlight child elements of type <pre><code> -->
<div highlight="all">
<pre><code [textContent]="htmlCode"></code></pre>
<pre><code [textContent]="tsCode"></code></pre>
<pre><code [textContent]="cssCode"></code></pre>
</div>
<!-- Highlight custom child elements -->
<div highlight="section code">
<section><code [textContent]="pythonCode"></code></section>
<section><code [textContent]="swiftCode"></code></section>
</div>
Highlight element(s)
[highlight]: string, default ''
highlight
on the element to highlight it.highlight="all"
to highlight all child code elements.highlight="{selector}"
to highlight custom child elements.Auto-highlight on changes
[hlAuto]: boolean, default true
;
Highlight delay
[hlDelay]: number, default 200
ms;
To generate all *.js
, *.d.ts
and *.metadata.json
files:
$ npm run build
To lint all *.ts
files:
$ npm run lint
If you identify any errors in the library, or have an idea for an improvement, please open an issue. I am excited to see what the community thinks of this project, and I would love your input!
FAQs
Instant code highlighting, auto-detect language, super easy to use.
We found that ngx-highlightjs demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Research
Security News
A malicious npm package targets Solana developers, rerouting funds in 2% of transactions to a hardcoded address.
Security News
Research
Socket researchers have discovered malicious npm packages targeting crypto developers, stealing credentials and wallet data using spyware delivered through typosquats of popular cryptographic libraries.
Security News
Socket's package search now displays weekly downloads for npm packages, helping developers quickly assess popularity and make more informed decisions.