Skip to content

Commit

Permalink
Merge pull request #284 from MurhafSousli/release/v11
Browse files Browse the repository at this point in the history
v11.0.0
  • Loading branch information
MurhafSousli committed May 25, 2024
2 parents f17271e + 51ca159 commit a10b312
Show file tree
Hide file tree
Showing 5 changed files with 58 additions and 30 deletions.
2 changes: 1 addition & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Changelog

## 11.0.0-beta.1
## 11.0.0

- Update to Angular 17.
- feat: Add `provideHighlightOptions` function to easily override the default options.
Expand Down
37 changes: 23 additions & 14 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,10 @@ ___
- [Live Demo](https://ngx-highlight.netlify.com/) | [Stackblitz](https://stackblitz.com/edit/ngx-highlightjs)
- [Installation](#installation)
- [Usage](#usage)
- [Lazy-load highlight.js script](#usage)
- [Import highlight.js theme](#themes)
- [Highlight usage](#highlight)
- [HighlightAuto usage](#highlight-auto)
- [Line numbers addon usage](#line-numbers)
- [Plus package](#plus)
- [Issues](#issues)
Expand Down Expand Up @@ -92,6 +96,8 @@ export const appConfig: ApplicationConfig = {
| lineNumbersOptions | Set line numbers plugin options |
| themePath | The path to the CSS file for the highlighting theme |

<a name="themes"/>

### Import highlighting theme

**Dynamic Approach**
Expand Down Expand Up @@ -141,12 +147,14 @@ In `angular.json`:
Or directly in `src/style.scss`:

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

_[List of all available themes from highlight.js](https://github.com/isagalaev/highlight.js/tree/master/src/styles)_

### Use highlight directive
<a name="highlight"/>

### Highlight Directive Usage

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

Expand All @@ -165,7 +173,7 @@ export class AppComponent {
}
```

## Options
#### Options

| Name | Type | Description |
|----------------------|-----------------|----------------------------------------------------------------------------------------------------------------------------------------------------------------|
Expand All @@ -174,26 +182,29 @@ export class AppComponent {
| **[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

<a name="highlight-auto"/>

### HighlightAuto Directive Usage

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

```ts
import { HighlightAuto } from 'ngx-highlightjs';

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

## Options
#### Options

| Name | Type | Description |
|---------------------|---------------------|------------------------------------------------------------------------------------------------------------|
Expand All @@ -204,9 +215,7 @@ export class AppComponent {

<a name="line-numbers"/>

## Line Numbers

### `lineNumbers` directive
## Line Numbers Directive Usage

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

Expand All @@ -215,18 +224,18 @@ import { HighlightAuto } from 'ngx-highlightjs';
import { HighlightLineNumbers } from 'ngx-highlightjs/line-numbers';

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

## Options
#### Options

| Name | Type | Description |
|------------------|---------|--------------------------------------------------------------|
Expand Down Expand Up @@ -295,13 +304,13 @@ export const appConfig: ApplicationConfig = {
import { HighlightPlusModule } from 'ngx-highlightjs';

@Component({
standalone: true,
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 {
Expand All @@ -320,6 +329,7 @@ To highlight all files within a gist, iterate through `gist.files` and utilize t
import { HighlightPlusModule } from 'ngx-highlightjs';

@Component({
standalone: true,
selector: 'app-root',
template: `
<ng-container [gist]="gistId" (gistLoaded)="gist = $event">
Expand All @@ -328,7 +338,6 @@ import { HighlightPlusModule } from 'ngx-highlightjs';
}
</ng-container>
`,
standalone: true,
imports: [HighlightPlusModule, CommonModule]
})
export class AppComponent {
Expand All @@ -345,13 +354,13 @@ Use the pipe `codeFromUrl` with the `async` pipe to get the code text from a raw
import { HighlightPlusModule } from 'ngx-highlightjs';

@Component({
standalone: true,
selector: 'app-root',
template: `
<pre>
<code [highlight]="codeUrl | codeFromUrl | async"></code>
</pre>
`,
standalone: true,
imports: [HighlightPlusModule, CommonModule]
})
export class AppComponent {
Expand Down
10 changes: 10 additions & 0 deletions codecov.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
coverage:
status:
project:
default:
target: auto
threshold: 1% # Allow up to a 1% decrease in coverage without failing
patch:
default:
target: auto
informational: true # Report but do not fail on patch coverage
37 changes: 23 additions & 14 deletions projects/ngx-highlightjs/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,10 @@ ___
- [Live Demo](https://ngx-highlight.netlify.com/) | [Stackblitz](https://stackblitz.com/edit/ngx-highlightjs)
- [Installation](#installation)
- [Usage](#usage)
- [Lazy-load highlight.js script](#usage)
- [Import highlight.js theme](#themes)
- [Highlight usage](#highlight)
- [HighlightAuto usage](#highlight-auto)
- [Line numbers addon usage](#line-numbers)
- [Plus package](#plus)
- [Issues](#issues)
Expand Down Expand Up @@ -92,6 +96,8 @@ export const appConfig: ApplicationConfig = {
| lineNumbersOptions | Set line numbers plugin options |
| themePath | The path to the CSS file for the highlighting theme |

<a name="themes"/>

### Import highlighting theme

**Dynamic Approach**
Expand Down Expand Up @@ -141,12 +147,14 @@ In `angular.json`:
Or directly in `src/style.scss`:

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

_[List of all available themes from highlight.js](https://github.com/isagalaev/highlight.js/tree/master/src/styles)_

### Use highlight directive
<a name="highlight"/>

### Highlight Directive Usage

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

Expand All @@ -165,7 +173,7 @@ export class AppComponent {
}
```

## Options
#### Options

| Name | Type | Description |
|----------------------|-----------------|----------------------------------------------------------------------------------------------------------------------------------------------------------------|
Expand All @@ -174,26 +182,29 @@ export class AppComponent {
| **[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

<a name="highlight-auto"/>

### HighlightAuto Directive Usage

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

```ts
import { HighlightAuto } from 'ngx-highlightjs';

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

## Options
#### Options

| Name | Type | Description |
|---------------------|---------------------|------------------------------------------------------------------------------------------------------------|
Expand All @@ -204,9 +215,7 @@ export class AppComponent {

<a name="line-numbers"/>

## Line Numbers

### `lineNumbers` directive
## Line Numbers Directive Usage

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

Expand All @@ -215,18 +224,18 @@ import { HighlightAuto } from 'ngx-highlightjs';
import { HighlightLineNumbers } from 'ngx-highlightjs/line-numbers';

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

## Options
#### Options

| Name | Type | Description |
|------------------|---------|--------------------------------------------------------------|
Expand Down Expand Up @@ -295,13 +304,13 @@ export const appConfig: ApplicationConfig = {
import { HighlightPlusModule } from 'ngx-highlightjs';

@Component({
standalone: true,
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 {
Expand All @@ -320,6 +329,7 @@ To highlight all files within a gist, iterate through `gist.files` and utilize t
import { HighlightPlusModule } from 'ngx-highlightjs';

@Component({
standalone: true,
selector: 'app-root',
template: `
<ng-container [gist]="gistId" (gistLoaded)="gist = $event">
Expand All @@ -328,7 +338,6 @@ import { HighlightPlusModule } from 'ngx-highlightjs';
}
</ng-container>
`,
standalone: true,
imports: [HighlightPlusModule, CommonModule]
})
export class AppComponent {
Expand All @@ -345,13 +354,13 @@ Use the pipe `codeFromUrl` with the `async` pipe to get the code text from a raw
import { HighlightPlusModule } from 'ngx-highlightjs';

@Component({
standalone: true,
selector: 'app-root',
template: `
<pre>
<code [highlight]="codeUrl | codeFromUrl | async"></code>
</pre>
`,
standalone: true,
imports: [HighlightPlusModule, CommonModule]
})
export class AppComponent {
Expand Down
2 changes: 1 addition & 1 deletion projects/ngx-highlightjs/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "ngx-highlightjs",
"version": "11.0.0-beta.1",
"version": "11.0.0",
"description": "Instant code highlighting, auto-detect language, super easy to use.",
"homepage": "http://github.com/murhafsousli/ngx-highlightjs",
"author": {
Expand Down

0 comments on commit a10b312

Please sign in to comment.