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

yunnysunny / bookforge / 22036642206

15 Feb 2026 01:38PM UTC coverage: 70.995% (+14.8%) from 56.206%
22036642206

Pull #2

github

yunnysunny
feat: fix html generate test
Pull Request #2: feat: refactor ui flow

63 of 81 branches covered (77.78%)

Branch coverage included in aggregate %.

98 of 169 new or added lines in 13 files covered. (57.99%)

4 existing lines in 3 files now uncovered.

358 of 512 relevant lines covered (69.92%)

27.05 hits per line

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

26.09
/src/core/marked-plugins/gitbook-tab.plugin.ts
1
import type { RendererThis, MarkedExtension, Tokens } from 'marked';
2

3
interface TabItem {
4
  title: string;
5
  content: string;
6
  tokens: Tokens.Generic[];
7
}
8
interface GitbookTabsToken extends Tokens.Generic {
9
  type: 'gb-tabs';
10
  tag: 'tabs';
11
  tabItems: TabItem[];
12
}
13
export const gitbookTabExtension: MarkedExtension = {
15✔
14
  extensions: [
15
    {
16
      name: 'gb-tabs',
17
      level: 'block',
18
      start(src: string) {
19
        return src.indexOf('{%');
42✔
20
      },
21
      tokenizer(this, src: string): GitbookTabsToken | undefined {
22
        const rule = /^\{%\s*tabs\s*%\}([\s\S]*?)\{%\s*endtabs\s*%\}/;
99✔
23
        const match = rule.exec(src);
99✔
24
        if (!match) return;
99✔
25

NEW
26
        const [, content] = match;
×
27

NEW
28
        const tabRegex = /\{%\s*tab\s+title="([^"]+)"\s*%\}([\s\S]*?)\{%\s*endtab\s*%\}/g;
×
NEW
29
        const tabItems: TabItem[] = [];
×
NEW
30
        let matchTab: RegExpExecArray | null = tabRegex.exec(content);
×
NEW
31
        while (matchTab !== null) {
×
NEW
32
          tabItems.push({
×
33
            title: matchTab[1],
34
            content: matchTab[2],
35
            tokens: this.lexer.blockTokens(matchTab[2]),
36
          });
NEW
37
          matchTab = tabRegex.exec(content);
×
38
        }
39

NEW
40
        return {
×
41
          type: 'gb-tabs',
42
          tag: 'tabs',
43
          raw: match[0],
44
          tabItems,
45
        };
46
      },
47
      renderer(this: RendererThis<string, string>, token: Tokens.Generic) {
NEW
48
        const { tag, tabItems, raw } = token as GitbookTabsToken;
×
NEW
49
        if (!tag || !tabItems || tabItems.length === 0) {
×
NEW
50
          return raw;
×
51
        }
NEW
52
        return `<div class="gb-tabs">
×
53
          <div class="tabs-header">
54
          ${tabItems
55
            .map((item, index) => {
NEW
56
              return `<div class="tab${index === 0 ? ' active' : ''}">${item.title}</div>`;
×
57
            })
58
            .join('\n')}
59
          </div>
60
          <div class="tabs-body">
61
          ${tabItems
62
            .map((item, index) => {
NEW
63
              return `<div class="tab-panel${index === 0 ? ' active' : ''}">${this.parser.parse(item.tokens)}</div>`;
×
64
            })
65
            .join('\n')}
66
          </div>
67
        </div>`;
68
      },
69
    },
70
  ],
71
};
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

© 2026 Coveralls, Inc