vscode-css-languageservice 6.0.1 → 6.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (87) hide show
  1. package/CHANGELOG.md +3 -1
  2. package/SECURITY.md +41 -0
  3. package/lib/esm/beautify/beautify-css.js +11 -4
  4. package/lib/esm/cssLanguageService.d.ts +38 -37
  5. package/lib/esm/cssLanguageService.js +73 -72
  6. package/lib/esm/cssLanguageTypes.d.ts +238 -238
  7. package/lib/esm/cssLanguageTypes.js +42 -42
  8. package/lib/esm/data/webCustomData.js +22089 -21959
  9. package/lib/esm/languageFacts/builtinData.js +142 -142
  10. package/lib/esm/languageFacts/colors.js +469 -469
  11. package/lib/esm/languageFacts/dataManager.js +88 -88
  12. package/lib/esm/languageFacts/dataProvider.js +73 -73
  13. package/lib/esm/languageFacts/entry.js +137 -137
  14. package/lib/esm/languageFacts/facts.js +8 -8
  15. package/lib/esm/parser/cssErrors.js +48 -48
  16. package/lib/esm/parser/cssNodes.js +1511 -1502
  17. package/lib/esm/parser/cssParser.js +1606 -1534
  18. package/lib/esm/parser/cssScanner.js +592 -592
  19. package/lib/esm/parser/cssSymbolScope.js +311 -311
  20. package/lib/esm/parser/lessParser.js +715 -714
  21. package/lib/esm/parser/lessScanner.js +57 -57
  22. package/lib/esm/parser/scssErrors.js +18 -18
  23. package/lib/esm/parser/scssParser.js +806 -796
  24. package/lib/esm/parser/scssScanner.js +95 -95
  25. package/lib/esm/services/cssCodeActions.js +77 -77
  26. package/lib/esm/services/cssCompletion.js +1054 -1054
  27. package/lib/esm/services/cssFolding.js +190 -190
  28. package/lib/esm/services/cssFormatter.js +136 -136
  29. package/lib/esm/services/cssHover.js +148 -148
  30. package/lib/esm/services/cssNavigation.js +441 -378
  31. package/lib/esm/services/cssSelectionRange.js +47 -47
  32. package/lib/esm/services/cssValidation.js +41 -41
  33. package/lib/esm/services/lessCompletion.js +378 -378
  34. package/lib/esm/services/lint.js +518 -518
  35. package/lib/esm/services/lintRules.js +76 -76
  36. package/lib/esm/services/lintUtil.js +196 -196
  37. package/lib/esm/services/pathCompletion.js +157 -157
  38. package/lib/esm/services/scssCompletion.js +354 -354
  39. package/lib/esm/services/scssNavigation.js +82 -82
  40. package/lib/esm/services/selectorPrinting.js +492 -492
  41. package/lib/esm/utils/arrays.js +40 -40
  42. package/lib/esm/utils/objects.js +11 -11
  43. package/lib/esm/utils/resources.js +11 -11
  44. package/lib/esm/utils/strings.js +102 -102
  45. package/lib/umd/beautify/beautify-css.js +11 -4
  46. package/lib/umd/cssLanguageService.d.ts +38 -37
  47. package/lib/umd/cssLanguageService.js +104 -99
  48. package/lib/umd/cssLanguageTypes.d.ts +238 -238
  49. package/lib/umd/cssLanguageTypes.js +89 -89
  50. package/lib/umd/data/webCustomData.js +22102 -21972
  51. package/lib/umd/languageFacts/builtinData.js +154 -154
  52. package/lib/umd/languageFacts/colors.js +492 -492
  53. package/lib/umd/languageFacts/dataManager.js +101 -101
  54. package/lib/umd/languageFacts/dataProvider.js +86 -86
  55. package/lib/umd/languageFacts/entry.js +152 -152
  56. package/lib/umd/languageFacts/facts.js +33 -29
  57. package/lib/umd/parser/cssErrors.js +61 -61
  58. package/lib/umd/parser/cssNodes.js +1597 -1587
  59. package/lib/umd/parser/cssParser.js +1619 -1547
  60. package/lib/umd/parser/cssScanner.js +606 -606
  61. package/lib/umd/parser/cssSymbolScope.js +328 -328
  62. package/lib/umd/parser/lessParser.js +728 -727
  63. package/lib/umd/parser/lessScanner.js +70 -70
  64. package/lib/umd/parser/scssErrors.js +31 -31
  65. package/lib/umd/parser/scssParser.js +819 -809
  66. package/lib/umd/parser/scssScanner.js +108 -108
  67. package/lib/umd/services/cssCodeActions.js +90 -90
  68. package/lib/umd/services/cssCompletion.js +1067 -1067
  69. package/lib/umd/services/cssFolding.js +203 -203
  70. package/lib/umd/services/cssFormatter.js +150 -150
  71. package/lib/umd/services/cssHover.js +161 -161
  72. package/lib/umd/services/cssNavigation.js +454 -391
  73. package/lib/umd/services/cssSelectionRange.js +60 -60
  74. package/lib/umd/services/cssValidation.js +54 -54
  75. package/lib/umd/services/lessCompletion.js +391 -391
  76. package/lib/umd/services/lint.js +531 -531
  77. package/lib/umd/services/lintRules.js +91 -91
  78. package/lib/umd/services/lintUtil.js +210 -210
  79. package/lib/umd/services/pathCompletion.js +171 -171
  80. package/lib/umd/services/scssCompletion.js +367 -367
  81. package/lib/umd/services/scssNavigation.js +95 -95
  82. package/lib/umd/services/selectorPrinting.js +510 -510
  83. package/lib/umd/utils/arrays.js +55 -55
  84. package/lib/umd/utils/objects.js +25 -25
  85. package/lib/umd/utils/resources.js +26 -26
  86. package/lib/umd/utils/strings.js +120 -120
  87. package/package.json +13 -12
@@ -1,88 +1,88 @@
1
- /*---------------------------------------------------------------------------------------------
2
- * Copyright (c) Microsoft Corporation. All rights reserved.
3
- * Licensed under the MIT License. See License.txt in the project root for license information.
4
- *--------------------------------------------------------------------------------------------*/
5
- 'use strict';
6
- import * as objects from '../utils/objects';
7
- import { cssData } from '../data/webCustomData';
8
- import { CSSDataProvider } from './dataProvider';
9
- export class CSSDataManager {
10
- constructor(options) {
11
- this.dataProviders = [];
12
- this._propertySet = {};
13
- this._atDirectiveSet = {};
14
- this._pseudoClassSet = {};
15
- this._pseudoElementSet = {};
16
- this._properties = [];
17
- this._atDirectives = [];
18
- this._pseudoClasses = [];
19
- this._pseudoElements = [];
20
- this.setDataProviders(options?.useDefaultDataProvider !== false, options?.customDataProviders || []);
21
- }
22
- setDataProviders(builtIn, providers) {
23
- this.dataProviders = [];
24
- if (builtIn) {
25
- this.dataProviders.push(new CSSDataProvider(cssData));
26
- }
27
- this.dataProviders.push(...providers);
28
- this.collectData();
29
- }
30
- /**
31
- * Collect all data & handle duplicates
32
- */
33
- collectData() {
34
- this._propertySet = {};
35
- this._atDirectiveSet = {};
36
- this._pseudoClassSet = {};
37
- this._pseudoElementSet = {};
38
- this.dataProviders.forEach(provider => {
39
- provider.provideProperties().forEach(p => {
40
- if (!this._propertySet[p.name]) {
41
- this._propertySet[p.name] = p;
42
- }
43
- });
44
- provider.provideAtDirectives().forEach(p => {
45
- if (!this._atDirectiveSet[p.name]) {
46
- this._atDirectiveSet[p.name] = p;
47
- }
48
- });
49
- provider.providePseudoClasses().forEach(p => {
50
- if (!this._pseudoClassSet[p.name]) {
51
- this._pseudoClassSet[p.name] = p;
52
- }
53
- });
54
- provider.providePseudoElements().forEach(p => {
55
- if (!this._pseudoElementSet[p.name]) {
56
- this._pseudoElementSet[p.name] = p;
57
- }
58
- });
59
- });
60
- this._properties = objects.values(this._propertySet);
61
- this._atDirectives = objects.values(this._atDirectiveSet);
62
- this._pseudoClasses = objects.values(this._pseudoClassSet);
63
- this._pseudoElements = objects.values(this._pseudoElementSet);
64
- }
65
- getProperty(name) { return this._propertySet[name]; }
66
- getAtDirective(name) { return this._atDirectiveSet[name]; }
67
- getPseudoClass(name) { return this._pseudoClassSet[name]; }
68
- getPseudoElement(name) { return this._pseudoElementSet[name]; }
69
- getProperties() {
70
- return this._properties;
71
- }
72
- getAtDirectives() {
73
- return this._atDirectives;
74
- }
75
- getPseudoClasses() {
76
- return this._pseudoClasses;
77
- }
78
- getPseudoElements() {
79
- return this._pseudoElements;
80
- }
81
- isKnownProperty(name) {
82
- return name.toLowerCase() in this._propertySet;
83
- }
84
- isStandardProperty(name) {
85
- return this.isKnownProperty(name) &&
86
- (!this._propertySet[name.toLowerCase()].status || this._propertySet[name.toLowerCase()].status === 'standard');
87
- }
88
- }
1
+ /*---------------------------------------------------------------------------------------------
2
+ * Copyright (c) Microsoft Corporation. All rights reserved.
3
+ * Licensed under the MIT License. See License.txt in the project root for license information.
4
+ *--------------------------------------------------------------------------------------------*/
5
+ 'use strict';
6
+ import * as objects from '../utils/objects';
7
+ import { cssData } from '../data/webCustomData';
8
+ import { CSSDataProvider } from './dataProvider';
9
+ export class CSSDataManager {
10
+ constructor(options) {
11
+ this.dataProviders = [];
12
+ this._propertySet = {};
13
+ this._atDirectiveSet = {};
14
+ this._pseudoClassSet = {};
15
+ this._pseudoElementSet = {};
16
+ this._properties = [];
17
+ this._atDirectives = [];
18
+ this._pseudoClasses = [];
19
+ this._pseudoElements = [];
20
+ this.setDataProviders(options?.useDefaultDataProvider !== false, options?.customDataProviders || []);
21
+ }
22
+ setDataProviders(builtIn, providers) {
23
+ this.dataProviders = [];
24
+ if (builtIn) {
25
+ this.dataProviders.push(new CSSDataProvider(cssData));
26
+ }
27
+ this.dataProviders.push(...providers);
28
+ this.collectData();
29
+ }
30
+ /**
31
+ * Collect all data & handle duplicates
32
+ */
33
+ collectData() {
34
+ this._propertySet = {};
35
+ this._atDirectiveSet = {};
36
+ this._pseudoClassSet = {};
37
+ this._pseudoElementSet = {};
38
+ this.dataProviders.forEach(provider => {
39
+ provider.provideProperties().forEach(p => {
40
+ if (!this._propertySet[p.name]) {
41
+ this._propertySet[p.name] = p;
42
+ }
43
+ });
44
+ provider.provideAtDirectives().forEach(p => {
45
+ if (!this._atDirectiveSet[p.name]) {
46
+ this._atDirectiveSet[p.name] = p;
47
+ }
48
+ });
49
+ provider.providePseudoClasses().forEach(p => {
50
+ if (!this._pseudoClassSet[p.name]) {
51
+ this._pseudoClassSet[p.name] = p;
52
+ }
53
+ });
54
+ provider.providePseudoElements().forEach(p => {
55
+ if (!this._pseudoElementSet[p.name]) {
56
+ this._pseudoElementSet[p.name] = p;
57
+ }
58
+ });
59
+ });
60
+ this._properties = objects.values(this._propertySet);
61
+ this._atDirectives = objects.values(this._atDirectiveSet);
62
+ this._pseudoClasses = objects.values(this._pseudoClassSet);
63
+ this._pseudoElements = objects.values(this._pseudoElementSet);
64
+ }
65
+ getProperty(name) { return this._propertySet[name]; }
66
+ getAtDirective(name) { return this._atDirectiveSet[name]; }
67
+ getPseudoClass(name) { return this._pseudoClassSet[name]; }
68
+ getPseudoElement(name) { return this._pseudoElementSet[name]; }
69
+ getProperties() {
70
+ return this._properties;
71
+ }
72
+ getAtDirectives() {
73
+ return this._atDirectives;
74
+ }
75
+ getPseudoClasses() {
76
+ return this._pseudoClasses;
77
+ }
78
+ getPseudoElements() {
79
+ return this._pseudoElements;
80
+ }
81
+ isKnownProperty(name) {
82
+ return name.toLowerCase() in this._propertySet;
83
+ }
84
+ isStandardProperty(name) {
85
+ return this.isKnownProperty(name) &&
86
+ (!this._propertySet[name.toLowerCase()].status || this._propertySet[name.toLowerCase()].status === 'standard');
87
+ }
88
+ }
@@ -1,73 +1,73 @@
1
- /*---------------------------------------------------------------------------------------------
2
- * Copyright (c) Microsoft Corporation. All rights reserved.
3
- * Licensed under the MIT License. See License.txt in the project root for license information.
4
- *--------------------------------------------------------------------------------------------*/
5
- 'use strict';
6
- export class CSSDataProvider {
7
- /**
8
- * Currently, unversioned data uses the V1 implementation
9
- * In the future when the provider handles multiple versions of HTML custom data,
10
- * use the latest implementation for unversioned data
11
- */
12
- constructor(data) {
13
- this._properties = [];
14
- this._atDirectives = [];
15
- this._pseudoClasses = [];
16
- this._pseudoElements = [];
17
- this.addData(data);
18
- }
19
- provideProperties() {
20
- return this._properties;
21
- }
22
- provideAtDirectives() {
23
- return this._atDirectives;
24
- }
25
- providePseudoClasses() {
26
- return this._pseudoClasses;
27
- }
28
- providePseudoElements() {
29
- return this._pseudoElements;
30
- }
31
- addData(data) {
32
- if (Array.isArray(data.properties)) {
33
- for (const prop of data.properties) {
34
- if (isPropertyData(prop)) {
35
- this._properties.push(prop);
36
- }
37
- }
38
- }
39
- if (Array.isArray(data.atDirectives)) {
40
- for (const prop of data.atDirectives) {
41
- if (isAtDirective(prop)) {
42
- this._atDirectives.push(prop);
43
- }
44
- }
45
- }
46
- if (Array.isArray(data.pseudoClasses)) {
47
- for (const prop of data.pseudoClasses) {
48
- if (isPseudoClassData(prop)) {
49
- this._pseudoClasses.push(prop);
50
- }
51
- }
52
- }
53
- if (Array.isArray(data.pseudoElements)) {
54
- for (const prop of data.pseudoElements) {
55
- if (isPseudoElementData(prop)) {
56
- this._pseudoElements.push(prop);
57
- }
58
- }
59
- }
60
- }
61
- }
62
- function isPropertyData(d) {
63
- return typeof d.name === 'string';
64
- }
65
- function isAtDirective(d) {
66
- return typeof d.name === 'string';
67
- }
68
- function isPseudoClassData(d) {
69
- return typeof d.name === 'string';
70
- }
71
- function isPseudoElementData(d) {
72
- return typeof d.name === 'string';
73
- }
1
+ /*---------------------------------------------------------------------------------------------
2
+ * Copyright (c) Microsoft Corporation. All rights reserved.
3
+ * Licensed under the MIT License. See License.txt in the project root for license information.
4
+ *--------------------------------------------------------------------------------------------*/
5
+ 'use strict';
6
+ export class CSSDataProvider {
7
+ /**
8
+ * Currently, unversioned data uses the V1 implementation
9
+ * In the future when the provider handles multiple versions of HTML custom data,
10
+ * use the latest implementation for unversioned data
11
+ */
12
+ constructor(data) {
13
+ this._properties = [];
14
+ this._atDirectives = [];
15
+ this._pseudoClasses = [];
16
+ this._pseudoElements = [];
17
+ this.addData(data);
18
+ }
19
+ provideProperties() {
20
+ return this._properties;
21
+ }
22
+ provideAtDirectives() {
23
+ return this._atDirectives;
24
+ }
25
+ providePseudoClasses() {
26
+ return this._pseudoClasses;
27
+ }
28
+ providePseudoElements() {
29
+ return this._pseudoElements;
30
+ }
31
+ addData(data) {
32
+ if (Array.isArray(data.properties)) {
33
+ for (const prop of data.properties) {
34
+ if (isPropertyData(prop)) {
35
+ this._properties.push(prop);
36
+ }
37
+ }
38
+ }
39
+ if (Array.isArray(data.atDirectives)) {
40
+ for (const prop of data.atDirectives) {
41
+ if (isAtDirective(prop)) {
42
+ this._atDirectives.push(prop);
43
+ }
44
+ }
45
+ }
46
+ if (Array.isArray(data.pseudoClasses)) {
47
+ for (const prop of data.pseudoClasses) {
48
+ if (isPseudoClassData(prop)) {
49
+ this._pseudoClasses.push(prop);
50
+ }
51
+ }
52
+ }
53
+ if (Array.isArray(data.pseudoElements)) {
54
+ for (const prop of data.pseudoElements) {
55
+ if (isPseudoElementData(prop)) {
56
+ this._pseudoElements.push(prop);
57
+ }
58
+ }
59
+ }
60
+ }
61
+ }
62
+ function isPropertyData(d) {
63
+ return typeof d.name === 'string';
64
+ }
65
+ function isAtDirective(d) {
66
+ return typeof d.name === 'string';
67
+ }
68
+ function isPseudoClassData(d) {
69
+ return typeof d.name === 'string';
70
+ }
71
+ function isPseudoElementData(d) {
72
+ return typeof d.name === 'string';
73
+ }
@@ -1,137 +1,137 @@
1
- /*---------------------------------------------------------------------------------------------
2
- * Copyright (c) Microsoft Corporation. All rights reserved.
3
- * Licensed under the MIT License. See License.txt in the project root for license information.
4
- *--------------------------------------------------------------------------------------------*/
5
- 'use strict';
6
- import { MarkupKind } from '../cssLanguageTypes';
7
- export const browserNames = {
8
- E: 'Edge',
9
- FF: 'Firefox',
10
- S: 'Safari',
11
- C: 'Chrome',
12
- IE: 'IE',
13
- O: 'Opera'
14
- };
15
- function getEntryStatus(status) {
16
- switch (status) {
17
- case 'experimental':
18
- return '⚠️ Property is experimental. Be cautious when using it.️\n\n';
19
- case 'nonstandard':
20
- return '🚨️ Property is nonstandard. Avoid using it.\n\n';
21
- case 'obsolete':
22
- return '🚨️️️ Property is obsolete. Avoid using it.\n\n';
23
- default:
24
- return '';
25
- }
26
- }
27
- export function getEntryDescription(entry, doesSupportMarkdown, settings) {
28
- let result;
29
- if (doesSupportMarkdown) {
30
- result = {
31
- kind: 'markdown',
32
- value: getEntryMarkdownDescription(entry, settings)
33
- };
34
- }
35
- else {
36
- result = {
37
- kind: 'plaintext',
38
- value: getEntryStringDescription(entry, settings)
39
- };
40
- }
41
- if (result.value === '') {
42
- return undefined;
43
- }
44
- return result;
45
- }
46
- export function textToMarkedString(text) {
47
- text = text.replace(/[\\`*_{}[\]()#+\-.!]/g, '\\$&'); // escape markdown syntax tokens: http://daringfireball.net/projects/markdown/syntax#backslash
48
- return text.replace(/</g, '&lt;').replace(/>/g, '&gt;');
49
- }
50
- function getEntryStringDescription(entry, settings) {
51
- if (!entry.description || entry.description === '') {
52
- return '';
53
- }
54
- if (typeof entry.description !== 'string') {
55
- return entry.description.value;
56
- }
57
- let result = '';
58
- if (settings?.documentation !== false) {
59
- if (entry.status) {
60
- result += getEntryStatus(entry.status);
61
- }
62
- result += entry.description;
63
- const browserLabel = getBrowserLabel(entry.browsers);
64
- if (browserLabel) {
65
- result += '\n(' + browserLabel + ')';
66
- }
67
- if ('syntax' in entry) {
68
- result += `\n\nSyntax: ${entry.syntax}`;
69
- }
70
- }
71
- if (entry.references && entry.references.length > 0 && settings?.references !== false) {
72
- if (result.length > 0) {
73
- result += '\n\n';
74
- }
75
- result += entry.references.map(r => {
76
- return `${r.name}: ${r.url}`;
77
- }).join(' | ');
78
- }
79
- return result;
80
- }
81
- function getEntryMarkdownDescription(entry, settings) {
82
- if (!entry.description || entry.description === '') {
83
- return '';
84
- }
85
- let result = '';
86
- if (settings?.documentation !== false) {
87
- if (entry.status) {
88
- result += getEntryStatus(entry.status);
89
- }
90
- if (typeof entry.description === 'string') {
91
- result += textToMarkedString(entry.description);
92
- }
93
- else {
94
- result += entry.description.kind === MarkupKind.Markdown ? entry.description.value : textToMarkedString(entry.description.value);
95
- }
96
- const browserLabel = getBrowserLabel(entry.browsers);
97
- if (browserLabel) {
98
- result += '\n\n(' + textToMarkedString(browserLabel) + ')';
99
- }
100
- if ('syntax' in entry && entry.syntax) {
101
- result += `\n\nSyntax: ${textToMarkedString(entry.syntax)}`;
102
- }
103
- }
104
- if (entry.references && entry.references.length > 0 && settings?.references !== false) {
105
- if (result.length > 0) {
106
- result += '\n\n';
107
- }
108
- result += entry.references.map(r => {
109
- return `[${r.name}](${r.url})`;
110
- }).join(' | ');
111
- }
112
- return result;
113
- }
114
- /**
115
- * Input is like `["E12","FF49","C47","IE","O"]`
116
- * Output is like `Edge 12, Firefox 49, Chrome 47, IE, Opera`
117
- */
118
- export function getBrowserLabel(browsers = []) {
119
- if (browsers.length === 0) {
120
- return null;
121
- }
122
- return browsers
123
- .map(b => {
124
- let result = '';
125
- const matches = b.match(/([A-Z]+)(\d+)?/);
126
- const name = matches[1];
127
- const version = matches[2];
128
- if (name in browserNames) {
129
- result += browserNames[name];
130
- }
131
- if (version) {
132
- result += ' ' + version;
133
- }
134
- return result;
135
- })
136
- .join(', ');
137
- }
1
+ /*---------------------------------------------------------------------------------------------
2
+ * Copyright (c) Microsoft Corporation. All rights reserved.
3
+ * Licensed under the MIT License. See License.txt in the project root for license information.
4
+ *--------------------------------------------------------------------------------------------*/
5
+ 'use strict';
6
+ import { MarkupKind } from '../cssLanguageTypes';
7
+ export const browserNames = {
8
+ E: 'Edge',
9
+ FF: 'Firefox',
10
+ S: 'Safari',
11
+ C: 'Chrome',
12
+ IE: 'IE',
13
+ O: 'Opera'
14
+ };
15
+ function getEntryStatus(status) {
16
+ switch (status) {
17
+ case 'experimental':
18
+ return '⚠️ Property is experimental. Be cautious when using it.️\n\n';
19
+ case 'nonstandard':
20
+ return '🚨️ Property is nonstandard. Avoid using it.\n\n';
21
+ case 'obsolete':
22
+ return '🚨️️️ Property is obsolete. Avoid using it.\n\n';
23
+ default:
24
+ return '';
25
+ }
26
+ }
27
+ export function getEntryDescription(entry, doesSupportMarkdown, settings) {
28
+ let result;
29
+ if (doesSupportMarkdown) {
30
+ result = {
31
+ kind: 'markdown',
32
+ value: getEntryMarkdownDescription(entry, settings)
33
+ };
34
+ }
35
+ else {
36
+ result = {
37
+ kind: 'plaintext',
38
+ value: getEntryStringDescription(entry, settings)
39
+ };
40
+ }
41
+ if (result.value === '') {
42
+ return undefined;
43
+ }
44
+ return result;
45
+ }
46
+ export function textToMarkedString(text) {
47
+ text = text.replace(/[\\`*_{}[\]()#+\-.!]/g, '\\$&'); // escape markdown syntax tokens: http://daringfireball.net/projects/markdown/syntax#backslash
48
+ return text.replace(/</g, '&lt;').replace(/>/g, '&gt;');
49
+ }
50
+ function getEntryStringDescription(entry, settings) {
51
+ if (!entry.description || entry.description === '') {
52
+ return '';
53
+ }
54
+ if (typeof entry.description !== 'string') {
55
+ return entry.description.value;
56
+ }
57
+ let result = '';
58
+ if (settings?.documentation !== false) {
59
+ if (entry.status) {
60
+ result += getEntryStatus(entry.status);
61
+ }
62
+ result += entry.description;
63
+ const browserLabel = getBrowserLabel(entry.browsers);
64
+ if (browserLabel) {
65
+ result += '\n(' + browserLabel + ')';
66
+ }
67
+ if ('syntax' in entry) {
68
+ result += `\n\nSyntax: ${entry.syntax}`;
69
+ }
70
+ }
71
+ if (entry.references && entry.references.length > 0 && settings?.references !== false) {
72
+ if (result.length > 0) {
73
+ result += '\n\n';
74
+ }
75
+ result += entry.references.map(r => {
76
+ return `${r.name}: ${r.url}`;
77
+ }).join(' | ');
78
+ }
79
+ return result;
80
+ }
81
+ function getEntryMarkdownDescription(entry, settings) {
82
+ if (!entry.description || entry.description === '') {
83
+ return '';
84
+ }
85
+ let result = '';
86
+ if (settings?.documentation !== false) {
87
+ if (entry.status) {
88
+ result += getEntryStatus(entry.status);
89
+ }
90
+ if (typeof entry.description === 'string') {
91
+ result += textToMarkedString(entry.description);
92
+ }
93
+ else {
94
+ result += entry.description.kind === MarkupKind.Markdown ? entry.description.value : textToMarkedString(entry.description.value);
95
+ }
96
+ const browserLabel = getBrowserLabel(entry.browsers);
97
+ if (browserLabel) {
98
+ result += '\n\n(' + textToMarkedString(browserLabel) + ')';
99
+ }
100
+ if ('syntax' in entry && entry.syntax) {
101
+ result += `\n\nSyntax: ${textToMarkedString(entry.syntax)}`;
102
+ }
103
+ }
104
+ if (entry.references && entry.references.length > 0 && settings?.references !== false) {
105
+ if (result.length > 0) {
106
+ result += '\n\n';
107
+ }
108
+ result += entry.references.map(r => {
109
+ return `[${r.name}](${r.url})`;
110
+ }).join(' | ');
111
+ }
112
+ return result;
113
+ }
114
+ /**
115
+ * Input is like `["E12","FF49","C47","IE","O"]`
116
+ * Output is like `Edge 12, Firefox 49, Chrome 47, IE, Opera`
117
+ */
118
+ export function getBrowserLabel(browsers = []) {
119
+ if (browsers.length === 0) {
120
+ return null;
121
+ }
122
+ return browsers
123
+ .map(b => {
124
+ let result = '';
125
+ const matches = b.match(/([A-Z]+)(\d+)?/);
126
+ const name = matches[1];
127
+ const version = matches[2];
128
+ if (name in browserNames) {
129
+ result += browserNames[name];
130
+ }
131
+ if (version) {
132
+ result += ' ' + version;
133
+ }
134
+ return result;
135
+ })
136
+ .join(', ');
137
+ }
@@ -1,8 +1,8 @@
1
- /*---------------------------------------------------------------------------------------------
2
- * Copyright (c) Microsoft Corporation. All rights reserved.
3
- * Licensed under the MIT License. See License.txt in the project root for license information.
4
- *--------------------------------------------------------------------------------------------*/
5
- 'use strict';
6
- export * from './entry';
7
- export * from './colors';
8
- export * from './builtinData';
1
+ /*---------------------------------------------------------------------------------------------
2
+ * Copyright (c) Microsoft Corporation. All rights reserved.
3
+ * Licensed under the MIT License. See License.txt in the project root for license information.
4
+ *--------------------------------------------------------------------------------------------*/
5
+ 'use strict';
6
+ export * from './entry';
7
+ export * from './colors';
8
+ export * from './builtinData';