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

IgniteUI / igniteui-angular / 19546882539

20 Nov 2025 06:11PM UTC coverage: 91.573% (-0.02%) from 91.592%
19546882539

Pull #16255

github

web-flow
Merge 6c1ec770e into 144b2d49e
Pull Request #16255: feat: Added chat component Angular wrapper

13923 of 16349 branches covered (85.16%)

73 of 88 new or added lines in 3 files covered. (82.95%)

28092 of 30677 relevant lines covered (91.57%)

34291.9 hits per line

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

92.86
/projects/igniteui-angular/chat-extras/src/markdown-service.ts
1
import { Injectable } from '@angular/core';
2
import { Marked } from 'marked';
3
import markedShiki from 'marked-shiki';
4
import { bundledThemes, createHighlighter } from 'shiki/bundle/web';
5

6

7
const DEFAULT_LANGUAGES = ['javascript', 'typescript', 'html', 'css'];
3✔
8
const DEFAULT_THEMES = {
3✔
9
    light: 'github-light',
10
    dark: 'github-dark'
11
};
12

13
@Injectable({ providedIn: 'root' })
14
export class IgxChatMarkdownService {
3✔
15

16
    private _instance: Marked;
17
    private _isInitialized: Promise<void>;
18

19
    private _initializeMarked(): void {
20
        this._instance = new Marked({
4✔
21
            breaks: true,
22
            gfm: true,
23
            extensions: [
24
                {
25
                    name: 'link',
26
                    renderer({ href, title, text }) {
27
                        return `<a href="${href}" target="_blank" rel="noopener noreferrer" ${title ? `title="${title}"` : ''}>${text}</a>`;
1!
28
                    }
29
                }
30
            ]
31
        });
32
    }
33

34
    private async _initializeShiki(): Promise<void> {
35
        const highlighter = await createHighlighter({
4✔
36
            langs: DEFAULT_LANGUAGES,
37
            themes: Object.keys(bundledThemes)
38
        });
39

40
        this._instance.use(
4✔
41
            markedShiki({
42
                highlight(code, lang, _) {
43
                    try {
1✔
44
                        return highlighter.codeToHtml(code, {
1✔
45
                            lang,
46
                            themes: DEFAULT_THEMES,
47
                        });
48

49
                    } catch {
NEW
50
                        return `<pre><code>${code}</code></pre>`;
×
51
                    }
52
                }
53
            })
54
        );
55
    }
56

57

58
    constructor() {
59
        this._initializeMarked();
4✔
60
        this._isInitialized = this._initializeShiki();
4✔
61
    }
62

63
    public async parse(text: string): Promise<string> {
64
        await this._isInitialized;
3✔
65
        return await this._instance.parse(text);
3✔
66
    }
67
}
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