[d24f17c] | 1 | Prism.languages.mermaid = {
|
---|
| 2 | 'comment': {
|
---|
| 3 | pattern: /%%.*/,
|
---|
| 4 | greedy: true
|
---|
| 5 | },
|
---|
| 6 |
|
---|
| 7 | 'style': {
|
---|
| 8 | pattern: /^([ \t]*(?:classDef|linkStyle|style)[ \t]+[\w$-]+[ \t]+)\w.*[^\s;]/m,
|
---|
| 9 | lookbehind: true,
|
---|
| 10 | inside: {
|
---|
| 11 | 'property': /\b\w[\w-]*(?=[ \t]*:)/,
|
---|
| 12 | 'operator': /:/,
|
---|
| 13 | 'punctuation': /,/
|
---|
| 14 | }
|
---|
| 15 | },
|
---|
| 16 |
|
---|
| 17 | 'inter-arrow-label': {
|
---|
| 18 | pattern: /([^<>ox.=-])(?:-[-.]|==)(?![<>ox.=-])[ \t]*(?:"[^"\r\n]*"|[^\s".=-](?:[^\r\n.=-]*[^\s.=-])?)[ \t]*(?:\.+->?|--+[->]|==+[=>])(?![<>ox.=-])/,
|
---|
| 19 | lookbehind: true,
|
---|
| 20 | greedy: true,
|
---|
| 21 | inside: {
|
---|
| 22 | 'arrow': {
|
---|
| 23 | pattern: /(?:\.+->?|--+[->]|==+[=>])$/,
|
---|
| 24 | alias: 'operator'
|
---|
| 25 | },
|
---|
| 26 | 'label': {
|
---|
| 27 | pattern: /^([\s\S]{2}[ \t]*)\S(?:[\s\S]*\S)?/,
|
---|
| 28 | lookbehind: true,
|
---|
| 29 | alias: 'property'
|
---|
| 30 | },
|
---|
| 31 | 'arrow-head': {
|
---|
| 32 | pattern: /^\S+/,
|
---|
| 33 | alias: ['arrow', 'operator']
|
---|
| 34 | }
|
---|
| 35 | }
|
---|
| 36 | },
|
---|
| 37 |
|
---|
| 38 | 'arrow': [
|
---|
| 39 | // This might look complex but it really isn't.
|
---|
| 40 | // There are many possible arrows (see tests) and it's impossible to fit all of them into one pattern. The
|
---|
| 41 | // problem is that we only have one lookbehind per pattern. However, we cannot disallow too many arrow
|
---|
| 42 | // characters in the one lookbehind because that would create too many false negatives. So we have to split the
|
---|
| 43 | // arrows into different patterns.
|
---|
| 44 | {
|
---|
| 45 | // ER diagram
|
---|
| 46 | pattern: /(^|[^{}|o.-])[|}][|o](?:--|\.\.)[|o][|{](?![{}|o.-])/,
|
---|
| 47 | lookbehind: true,
|
---|
| 48 | alias: 'operator'
|
---|
| 49 | },
|
---|
| 50 | {
|
---|
| 51 | // flow chart
|
---|
| 52 | // (?:==+|--+|-\.*-)
|
---|
| 53 | pattern: /(^|[^<>ox.=-])(?:[<ox](?:==+|--+|-\.*-)[>ox]?|(?:==+|--+|-\.*-)[>ox]|===+|---+|-\.+-)(?![<>ox.=-])/,
|
---|
| 54 | lookbehind: true,
|
---|
| 55 | alias: 'operator'
|
---|
| 56 | },
|
---|
| 57 | {
|
---|
| 58 | // sequence diagram
|
---|
| 59 | pattern: /(^|[^<>()x-])(?:--?(?:>>|[x>)])(?![<>()x])|(?:<<|[x<(])--?(?!-))/,
|
---|
| 60 | lookbehind: true,
|
---|
| 61 | alias: 'operator'
|
---|
| 62 | },
|
---|
| 63 | {
|
---|
| 64 | // class diagram
|
---|
| 65 | pattern: /(^|[^<>|*o.-])(?:[*o]--|--[*o]|<\|?(?:--|\.\.)|(?:--|\.\.)\|?>|--|\.\.)(?![<>|*o.-])/,
|
---|
| 66 | lookbehind: true,
|
---|
| 67 | alias: 'operator'
|
---|
| 68 | },
|
---|
| 69 | ],
|
---|
| 70 |
|
---|
| 71 | 'label': {
|
---|
| 72 | pattern: /(^|[^|<])\|(?:[^\r\n"|]|"[^"\r\n]*")+\|/,
|
---|
| 73 | lookbehind: true,
|
---|
| 74 | greedy: true,
|
---|
| 75 | alias: 'property'
|
---|
| 76 | },
|
---|
| 77 |
|
---|
| 78 | 'text': {
|
---|
| 79 | pattern: /(?:[(\[{]+|\b>)(?:[^\r\n"()\[\]{}]|"[^"\r\n]*")+(?:[)\]}]+|>)/,
|
---|
| 80 | alias: 'string'
|
---|
| 81 | },
|
---|
| 82 | 'string': {
|
---|
| 83 | pattern: /"[^"\r\n]*"/,
|
---|
| 84 | greedy: true
|
---|
| 85 | },
|
---|
| 86 |
|
---|
| 87 | 'annotation': {
|
---|
| 88 | pattern: /<<(?:abstract|choice|enumeration|fork|interface|join|service)>>|\[\[(?:choice|fork|join)\]\]/i,
|
---|
| 89 | alias: 'important'
|
---|
| 90 | },
|
---|
| 91 |
|
---|
| 92 | 'keyword': [
|
---|
| 93 | // This language has both case-sensitive and case-insensitive keywords
|
---|
| 94 | {
|
---|
| 95 | pattern: /(^[ \t]*)(?:action|callback|class|classDef|classDiagram|click|direction|erDiagram|flowchart|gantt|gitGraph|graph|journey|link|linkStyle|pie|requirementDiagram|sequenceDiagram|stateDiagram|stateDiagram-v2|style|subgraph)(?![\w$-])/m,
|
---|
| 96 | lookbehind: true,
|
---|
| 97 | greedy: true
|
---|
| 98 | },
|
---|
| 99 | {
|
---|
| 100 | pattern: /(^[ \t]*)(?:activate|alt|and|as|autonumber|deactivate|else|end(?:[ \t]+note)?|loop|opt|par|participant|rect|state|note[ \t]+(?:over|(?:left|right)[ \t]+of))(?![\w$-])/im,
|
---|
| 101 | lookbehind: true,
|
---|
| 102 | greedy: true
|
---|
| 103 | }
|
---|
| 104 | ],
|
---|
| 105 |
|
---|
| 106 | 'entity': /#[a-z0-9]+;/,
|
---|
| 107 |
|
---|
| 108 | 'operator': {
|
---|
| 109 | pattern: /(\w[ \t]*)&(?=[ \t]*\w)|:::|:/,
|
---|
| 110 | lookbehind: true
|
---|
| 111 | },
|
---|
| 112 | 'punctuation': /[(){};]/
|
---|
| 113 | };
|
---|