[d24f17c] | 1 | 'use strict'
|
---|
| 2 |
|
---|
| 3 | module.exports = dot
|
---|
| 4 | dot.displayName = 'dot'
|
---|
| 5 | dot.aliases = ['gv']
|
---|
| 6 | function dot(Prism) {
|
---|
| 7 | // https://www.graphviz.org/doc/info/lang.html
|
---|
| 8 | ;(function (Prism) {
|
---|
| 9 | var ID =
|
---|
| 10 | '(?:' +
|
---|
| 11 | [
|
---|
| 12 | // an identifier
|
---|
| 13 | /[a-zA-Z_\x80-\uFFFF][\w\x80-\uFFFF]*/.source, // a number
|
---|
| 14 | /-?(?:\.\d+|\d+(?:\.\d*)?)/.source, // a double-quoted string
|
---|
| 15 | /"[^"\\]*(?:\\[\s\S][^"\\]*)*"/.source, // HTML-like string
|
---|
| 16 | /<(?:[^<>]|(?!<!--)<(?:[^<>"']|"[^"]*"|'[^']*')+>|<!--(?:[^-]|-(?!->))*-->)*>/
|
---|
| 17 | .source
|
---|
| 18 | ].join('|') +
|
---|
| 19 | ')'
|
---|
| 20 | var IDInside = {
|
---|
| 21 | markup: {
|
---|
| 22 | pattern: /(^<)[\s\S]+(?=>$)/,
|
---|
| 23 | lookbehind: true,
|
---|
| 24 | alias: ['language-markup', 'language-html', 'language-xml'],
|
---|
| 25 | inside: Prism.languages.markup
|
---|
| 26 | }
|
---|
| 27 | }
|
---|
| 28 | /**
|
---|
| 29 | * @param {string} source
|
---|
| 30 | * @param {string} flags
|
---|
| 31 | * @returns {RegExp}
|
---|
| 32 | */
|
---|
| 33 | function withID(source, flags) {
|
---|
| 34 | return RegExp(
|
---|
| 35 | source.replace(/<ID>/g, function () {
|
---|
| 36 | return ID
|
---|
| 37 | }),
|
---|
| 38 | flags
|
---|
| 39 | )
|
---|
| 40 | }
|
---|
| 41 | Prism.languages.dot = {
|
---|
| 42 | comment: {
|
---|
| 43 | pattern: /\/\/.*|\/\*[\s\S]*?\*\/|^#.*/m,
|
---|
| 44 | greedy: true
|
---|
| 45 | },
|
---|
| 46 | 'graph-name': {
|
---|
| 47 | pattern: withID(
|
---|
| 48 | /(\b(?:digraph|graph|subgraph)[ \t\r\n]+)<ID>/.source,
|
---|
| 49 | 'i'
|
---|
| 50 | ),
|
---|
| 51 | lookbehind: true,
|
---|
| 52 | greedy: true,
|
---|
| 53 | alias: 'class-name',
|
---|
| 54 | inside: IDInside
|
---|
| 55 | },
|
---|
| 56 | 'attr-value': {
|
---|
| 57 | pattern: withID(/(=[ \t\r\n]*)<ID>/.source),
|
---|
| 58 | lookbehind: true,
|
---|
| 59 | greedy: true,
|
---|
| 60 | inside: IDInside
|
---|
| 61 | },
|
---|
| 62 | 'attr-name': {
|
---|
| 63 | pattern: withID(/([\[;, \t\r\n])<ID>(?=[ \t\r\n]*=)/.source),
|
---|
| 64 | lookbehind: true,
|
---|
| 65 | greedy: true,
|
---|
| 66 | inside: IDInside
|
---|
| 67 | },
|
---|
| 68 | keyword: /\b(?:digraph|edge|graph|node|strict|subgraph)\b/i,
|
---|
| 69 | 'compass-point': {
|
---|
| 70 | pattern: /(:[ \t\r\n]*)(?:[ewc_]|[ns][ew]?)(?![\w\x80-\uFFFF])/,
|
---|
| 71 | lookbehind: true,
|
---|
| 72 | alias: 'builtin'
|
---|
| 73 | },
|
---|
| 74 | node: {
|
---|
| 75 | pattern: withID(/(^|[^-.\w\x80-\uFFFF\\])<ID>/.source),
|
---|
| 76 | lookbehind: true,
|
---|
| 77 | greedy: true,
|
---|
| 78 | inside: IDInside
|
---|
| 79 | },
|
---|
| 80 | operator: /[=:]|-[->]/,
|
---|
| 81 | punctuation: /[\[\]{};,]/
|
---|
| 82 | }
|
---|
| 83 | Prism.languages.gv = Prism.languages.dot
|
---|
| 84 | })(Prism)
|
---|
| 85 | }
|
---|