🎉 initiate project *astro_rewrite*

This commit is contained in:
sindrekjelsrud 2023-07-19 21:31:30 +02:00
parent ffd4d5e86c
commit 2ba37bfbe3
8658 changed files with 2268794 additions and 2538 deletions

View file

@ -0,0 +1,2 @@
import { HTMLDataV1 } from '../../htmlLanguageTypes';
export declare const htmlData: HTMLDataV1;

File diff suppressed because one or more lines are too long

View file

@ -0,0 +1,91 @@
/*---------------------------------------------------------------------------------------------
* Copyright (c) Microsoft Corporation. All rights reserved.
* Licensed under the MIT License. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/
(function (factory) {
if (typeof module === "object" && typeof module.exports === "object") {
var v = factory(require, exports);
if (v !== undefined) module.exports = v;
}
else if (typeof define === "function" && define.amd) {
define(["require", "exports", "./dataProvider", "./data/webCustomData", "../utils/arrays"], factory);
}
})(function (require, exports) {
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.HTMLDataManager = void 0;
const dataProvider_1 = require("./dataProvider");
const webCustomData_1 = require("./data/webCustomData");
const arrays = require("../utils/arrays");
class HTMLDataManager {
constructor(options) {
this.dataProviders = [];
this.setDataProviders(options.useDefaultDataProvider !== false, options.customDataProviders || []);
}
setDataProviders(builtIn, providers) {
this.dataProviders = [];
if (builtIn) {
this.dataProviders.push(new dataProvider_1.HTMLDataProvider('html5', webCustomData_1.htmlData));
}
this.dataProviders.push(...providers);
}
getDataProviders() {
return this.dataProviders;
}
isVoidElement(e, voidElements) {
return !!e && arrays.binarySearch(voidElements, e.toLowerCase(), (s1, s2) => s1.localeCompare(s2)) >= 0;
}
getVoidElements(languageOrProviders) {
const dataProviders = Array.isArray(languageOrProviders) ? languageOrProviders : this.getDataProviders().filter(p => p.isApplicable(languageOrProviders));
const voidTags = [];
dataProviders.forEach((provider) => {
provider.provideTags().filter(tag => tag.void).forEach(tag => voidTags.push(tag.name));
});
return voidTags.sort();
}
isPathAttribute(tag, attr) {
// should eventually come from custom data
if (attr === 'src' || attr === 'href') {
return true;
}
const a = PATH_TAG_AND_ATTR[tag];
if (a) {
if (typeof a === 'string') {
return a === attr;
}
else {
return a.indexOf(attr) !== -1;
}
}
return false;
}
}
exports.HTMLDataManager = HTMLDataManager;
// Selected from https://stackoverflow.com/a/2725168/1780148
const PATH_TAG_AND_ATTR = {
// HTML 4
a: 'href',
area: 'href',
body: 'background',
blockquote: 'cite',
del: 'cite',
form: 'action',
frame: ['src', 'longdesc'],
img: ['src', 'longdesc'],
ins: 'cite',
link: 'href',
object: 'data',
q: 'cite',
script: 'src',
// HTML 5
audio: 'src',
button: 'formaction',
command: 'icon',
embed: 'src',
html: 'manifest',
input: ['src', 'formaction'],
source: 'src',
track: 'src',
video: ['src', 'poster']
};
});

View file

@ -0,0 +1,127 @@
/*---------------------------------------------------------------------------------------------
* Copyright (c) Microsoft Corporation. All rights reserved.
* Licensed under the MIT License. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/
(function (factory) {
if (typeof module === "object" && typeof module.exports === "object") {
var v = factory(require, exports);
if (v !== undefined) module.exports = v;
}
else if (typeof define === "function" && define.amd) {
define(["require", "exports", "../utils/markup"], factory);
}
})(function (require, exports) {
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.generateDocumentation = exports.HTMLDataProvider = void 0;
const markup_1 = require("../utils/markup");
class HTMLDataProvider {
isApplicable() {
return true;
}
/**
* Currently, unversioned data uses the V1 implementation
* In the future when the provider handles multiple versions of HTML custom data,
* use the latest implementation for unversioned data
*/
constructor(id, customData) {
this.id = id;
this._tags = [];
this._tagMap = {};
this._valueSetMap = {};
this._tags = customData.tags || [];
this._globalAttributes = customData.globalAttributes || [];
this._tags.forEach(t => {
this._tagMap[t.name.toLowerCase()] = t;
});
if (customData.valueSets) {
customData.valueSets.forEach(vs => {
this._valueSetMap[vs.name] = vs.values;
});
}
}
getId() {
return this.id;
}
provideTags() {
return this._tags;
}
provideAttributes(tag) {
const attributes = [];
const processAttribute = (a) => {
attributes.push(a);
};
const tagEntry = this._tagMap[tag.toLowerCase()];
if (tagEntry) {
tagEntry.attributes.forEach(processAttribute);
}
this._globalAttributes.forEach(processAttribute);
return attributes;
}
provideValues(tag, attribute) {
const values = [];
attribute = attribute.toLowerCase();
const processAttributes = (attributes) => {
attributes.forEach(a => {
if (a.name.toLowerCase() === attribute) {
if (a.values) {
a.values.forEach(v => {
values.push(v);
});
}
if (a.valueSet) {
if (this._valueSetMap[a.valueSet]) {
this._valueSetMap[a.valueSet].forEach(v => {
values.push(v);
});
}
}
}
});
};
const tagEntry = this._tagMap[tag.toLowerCase()];
if (tagEntry) {
processAttributes(tagEntry.attributes);
}
processAttributes(this._globalAttributes);
return values;
}
}
exports.HTMLDataProvider = HTMLDataProvider;
/**
* Generate Documentation used in hover/complete
* From `documentation` and `references`
*/
function generateDocumentation(item, settings = {}, doesSupportMarkdown) {
const result = {
kind: doesSupportMarkdown ? 'markdown' : 'plaintext',
value: ''
};
if (item.description && settings.documentation !== false) {
const normalizedDescription = (0, markup_1.normalizeMarkupContent)(item.description);
if (normalizedDescription) {
result.value += normalizedDescription.value;
}
}
if (item.references && item.references.length > 0 && settings.references !== false) {
if (result.value.length) {
result.value += `\n\n`;
}
if (doesSupportMarkdown) {
result.value += item.references.map(r => {
return `[${r.name}](${r.url})`;
}).join(' | ');
}
else {
result.value += item.references.map(r => {
return `${r.name}: ${r.url}`;
}).join('\n');
}
}
if (result.value === '') {
return undefined;
}
return result;
}
exports.generateDocumentation = generateDocumentation;
});