• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

jfcere / ngx-markdown / 3fd6366a-f091-402b-aa3c-ca4a17b31cfc

01 Sep 2025 04:49PM UTC coverage: 61.982% (-34.9%) from 96.89%
3fd6366a-f091-402b-aa3c-ca4a17b31cfc

Pull #597

circleci

jfcere
add support for sanitizer function
Pull Request #597: feat: add support for sanitizer function

84 of 121 branches covered (69.42%)

Branch coverage included in aggregate %.

12 of 12 new or added lines in 3 files covered. (100.0%)

123 existing lines in 6 files now uncovered.

185 of 313 relevant lines covered (59.11%)

12.86 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

5.88
/lib/src/markdown.pipe.ts
1
import { ElementRef, NgZone, Pipe, PipeTransform, ViewContainerRef } from '@angular/core';
2
import { DomSanitizer, SafeHtml } from '@angular/platform-browser';
3
import { first } from 'rxjs/operators';
4
import { MarkdownService, ParseOptions, RenderOptions } from './markdown.service';
5

6
export type MarkdownPipeOptions = ParseOptions & RenderOptions;
7

8
@Pipe({
9
  name: 'markdown',
10
})
11
export class MarkdownPipe implements PipeTransform {
1✔
12

13
  constructor(
UNCOV
14
    private domSanitizer: DomSanitizer,
×
UNCOV
15
    private elementRef: ElementRef<HTMLElement>,
×
UNCOV
16
    private markdownService: MarkdownService,
×
UNCOV
17
    private viewContainerRef: ViewContainerRef,
×
UNCOV
18
    private zone: NgZone,
×
19
  ) { }
20

21
  async transform(value: string, options?: MarkdownPipeOptions): Promise<SafeHtml> {
UNCOV
22
    if (value == null) {
×
UNCOV
23
      return '';
×
24
    }
25

UNCOV
26
    if (typeof value !== 'string') {
×
UNCOV
27
      console.error(`MarkdownPipe has been invoked with an invalid value type [${typeof value}]`);
×
UNCOV
28
      return value;
×
29
    }
30

UNCOV
31
    const markdown = await this.markdownService.parse(value, options);
×
32

UNCOV
33
    this.zone.onStable
×
34
      .pipe(first())
UNCOV
35
      .subscribe(() => this.markdownService.render(this.elementRef.nativeElement, options, this.viewContainerRef));
×
36

UNCOV
37
    return this.domSanitizer.bypassSecurityTrustHtml(markdown);
×
38
  }
39
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2025 Coveralls, Inc