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

mermaid-js / mermaid / 5240835666

pending completion
5240835666

Pull #4450

github

web-flow
Merge 03bb1328a into 6115f6976
Pull Request #4450: add `mermaid-parser` separate package

3320 of 3759 branches covered (88.32%)

Branch coverage included in aggregate %.

2115 of 2115 new or added lines in 35 files covered. (100.0%)

38619 of 54312 relevant lines covered (71.11%)

243.64 hits per line

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

70.0
/packages/parser/src/language/services/value-converters/pieValueConverter.ts
1
/* eslint-disable @typescript-eslint/no-non-null-assertion */
1✔
2
import { DefaultValueConverter, type CstNode, type GrammarAST, type ValueType } from 'langium';
1✔
3

1✔
4
import { CommonValueConverter } from './commonValueConverters.js';
1✔
5

1✔
6
export class PieValueConverter extends DefaultValueConverter {
1✔
7
  public override runConverter(
1✔
8
    rule: GrammarAST.AbstractRule,
×
9
    input: string,
×
10
    cstNode: CstNode
×
11
  ): ValueType {
×
12
    let value = CommonValueConverter.customRunConverter(rule, input, cstNode);
×
13
    if (value === null) {
×
14
      value = PieValueConverter.customRunConverter(rule, input, cstNode);
×
15
    }
×
16

×
17
    if (value === null) {
×
18
      return super.runConverter(rule, input, cstNode);
×
19
    } else {
×
20
      return value;
×
21
    }
×
22
  }
×
23

1✔
24
  /**
1✔
25
   * A method contains convert logic to be used by class itself or `MermaidValueConverter`.
1✔
26
   *
1✔
27
   * @param rule - Parsed rule.
1✔
28
   * @param input - Matched string.
1✔
29
   * @param cstNode - Node in the Concrete Syntax Tree (CST).
1✔
30
   * @returns converted the value if it's pie rule or `null` if it's not.
1✔
31
   */
1✔
32
  public static customRunConverter(
1✔
33
    rule: GrammarAST.AbstractRule,
75✔
34
    input: string,
75✔
35
    // eslint-disable-next-line @typescript-eslint/no-unused-vars
75✔
36
    cstNode: CstNode
75✔
37
  ): ValueType | null {
75✔
38
    if (rule.name === 'PIE_SECTION_LABEL') {
75✔
39
      return input
20✔
40
        .replace(/"/g, '')
20✔
41
        .trim()
20✔
42
        .replaceAll(/[\t ]{2,}/gm, ' ');
20✔
43
    }
20✔
44
    return null;
55✔
45
  }
75✔
46
}
1✔
47
/* eslint-enable @typescript-eslint/no-non-null-assertion */
1✔
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