本文整理匯總了TypeScript中vs/base/common/strings.escape函數的典型用法代碼示例。如果您正苦於以下問題:TypeScript escape函數的具體用法?TypeScript escape怎麽用?TypeScript escape使用的例子?那麽, 這裏精選的函數代碼示例或許可以為您提供幫助。
在下文中一共展示了escape函數的10個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的TypeScript代碼示例。
示例1: render
private render(): void {
let htmlContent = '';
let pos = 0;
for (const highlight of this.highlights) {
if (highlight.end === highlight.start) {
continue;
}
if (pos < highlight.start) {
htmlContent += '<span>';
const substring = this.text.substring(pos, highlight.start);
htmlContent += this.supportOcticons ? renderOcticons(substring) : escape(substring);
htmlContent += '</span>';
pos = highlight.end;
}
htmlContent += '<span class="highlight">';
const substring = this.text.substring(highlight.start, highlight.end);
htmlContent += this.supportOcticons ? renderOcticons(substring) : escape(substring);
htmlContent += '</span>';
pos = highlight.end;
}
if (pos < this.text.length) {
htmlContent += '<span>';
const substring = this.text.substring(pos);
htmlContent += this.supportOcticons ? renderOcticons(substring) : escape(substring);
htmlContent += '</span>';
}
this.domNode.innerHTML = htmlContent;
this.domNode.title = this.title;
this.didEverRender = true;
}
示例2: render
private render() {
dom.clearNode(this.domNode);
let htmlContent: string[] = [];
let pos = 0;
for (const highlight of this.highlights) {
if (highlight.end === highlight.start) {
continue;
}
if (pos < highlight.start) {
htmlContent.push('<span>');
const substring = this.text.substring(pos, highlight.start);
htmlContent.push(this.supportOcticons ? renderOcticons(substring) : escape(substring));
htmlContent.push('</span>');
pos = highlight.end;
}
htmlContent.push('<span class="highlight">');
const substring = this.text.substring(highlight.start, highlight.end);
htmlContent.push(this.supportOcticons ? renderOcticons(substring) : escape(substring));
htmlContent.push('</span>');
pos = highlight.end;
}
if (pos < this.text.length) {
htmlContent.push('<span>');
const substring = this.text.substring(pos);
htmlContent.push(this.supportOcticons ? renderOcticons(substring) : escape(substring));
htmlContent.push('</span>');
}
this.domNode.innerHTML = htmlContent.join('');
this.domNode.title = this.title;
this.didEverRender = true;
}
示例3: render
private render() {
dom.clearNode(this.domNode);
let htmlContent: string[] = [],
highlight: IHighlight,
pos = 0;
for (let i = 0; i < this.highlights.length; i++) {
highlight = this.highlights[i];
if (highlight.end === highlight.start) {
continue;
}
if (pos < highlight.start) {
htmlContent.push('<span>')
htmlContent.push(expandOcticons(escape(this.text.substring(pos, highlight.start))));
htmlContent.push('</span>')
pos = highlight.end;
}
htmlContent.push('<span class="highlight">')
htmlContent.push(expandOcticons(escape(this.text.substring(highlight.start, highlight.end))));
htmlContent.push('</span>')
pos = highlight.end;
}
if (pos < this.text.length) {
htmlContent.push('<span>')
htmlContent.push(expandOcticons(escape(this.text.substring(pos))));
htmlContent.push('</span>')
}
this.domNode.innerHTML = htmlContent.join('');
this.didEverRender = true;
}
示例4: _tokenizeToString
function _tokenizeToString(text: string, tokenizationSupport: ITokenizationSupport): string {
let result = `<div class="monaco-tokenized-source">`;
let lines = text.split(/\r\n|\r|\n/);
let currentState = tokenizationSupport.getInitialState();
for (let i = 0, len = lines.length; i < len; i++) {
let line = lines[i];
if (i > 0) {
result += `<br/>`;
}
let tokenizationResult = tokenizationSupport.tokenize2(line, currentState, 0);
let lineTokens = new LineTokens(null, tokenizationResult.tokens, line);
let viewLineTokens = lineTokens.inflate();
let startOffset = 0;
let className = viewLineTokens[0].type;
for (let j = 1, lenJ = viewLineTokens.length; j < lenJ; j++) {
let viewLineToken = viewLineTokens[j];
result += `<span class="${className}">${strings.escape(line.substring(startOffset, viewLineToken.startIndex))}</span>`;
startOffset = viewLineToken.startIndex;
className = viewLineToken.type;
}
result += `<span class="${className}">${strings.escape(line.substring(startOffset))}</span>`;
currentState = tokenizationResult.endState;
}
result += `</div>`;
return result;
}
示例5: _tokenizeToString
function _tokenizeToString(text: string, tokenizationSupport: ITokenizationSupport): string {
let result = `<div class="monaco-tokenized-source">`;
let lines = text.split(/\r\n|\r|\n/);
let currentState = tokenizationSupport.getInitialState();
for (let i = 0, len = lines.length; i < len; i++) {
let line = lines[i];
if (i > 0) {
result += `<br/>`;
}
let tokenizationResult = tokenizationSupport.tokenize2(line, currentState, 0);
LineTokens.convertToEndOffset(tokenizationResult.tokens, line.length);
let lineTokens = new LineTokens(tokenizationResult.tokens, line);
let viewLineTokens = lineTokens.inflate();
let startOffset = 0;
for (let j = 0, lenJ = viewLineTokens.getCount(); j < lenJ; j++) {
const type = viewLineTokens.getClassName(j);
const endIndex = viewLineTokens.getEndOffset(j);
result += `<span class="${type}">${strings.escape(line.substring(startOffset, endIndex))}</span>`;
startOffset = endIndex;
}
currentState = tokenizationResult.endState;
}
result += `</div>`;
return result;
}
示例6:
renderer.code = (code, lang) => {
const value = options.codeBlockRenderer(lang, code);
// when code-block rendering is async we return sync
// but update the node with the real result later.
const id = defaultGenerator.nextId();
// {{SQL CARBON EDIT}} - Promise.all not returning the strValue properly in original code?
const promise = value.then(strValue => {
withInnerHTML.then(e => {
const span = element.querySelector(`div[data-code="${id}"]`);
if (span) {
span.innerHTML = strValue;
}
}).catch(err => {
// ignore
});
});
// original VS Code source
// const promise = Promise.all([value, withInnerHTML]).then(values => {
// const strValue = values[0];
// const span = element.querySelector(`div[data-code="${id}"]`);
// if (span) {
// span.innerHTML = strValue;
// }
// }).catch(err => {
// // ignore
// });
if (options.codeBlockRenderCallback) {
promise.then(options.codeBlockRenderCallback);
}
return `<div class="code" data-code="${id}">${escape(code)}</div>`;
};
示例7:
renderer.code = (code, lang) => {
const value = options.codeBlockRenderer!(lang, code);
// when code-block rendering is async we return sync
// but update the node with the real result later.
const id = defaultGenerator.nextId();
const promise = Promise.all([value, withInnerHTML]).then(values => {
const strValue = values[0];
const span = element.querySelector(`div[data-code="${id}"]`);
if (span) {
span.innerHTML = strValue;
}
}).catch(err => {
// ignore
});
if (options.codeBlockRenderCallback) {
promise.then(options.codeBlockRenderCallback);
}
return `<div class="code" data-code="${id}">${escape(code)}</div>`;
};
示例8:
renderer.code = (code, lang) => {
const value = options.codeBlockRenderer(lang, code);
if (typeof value === 'string') {
return value;
}
if (TPromise.is(value)) {
// when code-block rendering is async we return sync
// but update the node with the real result later.
const id = defaultGenerator.nextId();
TPromise.join([value, withInnerHTML]).done(values => {
const strValue = values[0] as string;
const span = element.querySelector(`div[data-code="${id}"]`);
if (span) {
span.innerHTML = strValue;
}
}, err => {
// ignore
});
return `<div class="code" data-code="${id}">${escape(code)}</div>`;
}
return code;
};
示例9:
var emitToken = (className: string, tokenText: string) => {
result += '<span class="' + className + extraTokenClass + '">' + strings.escape(tokenText) + '</span>';
};
示例10: default
export default () => `
<div class="welcomePageContainer">
<div class="welcomePage">
<div class="title">
<h1>${escape(localize('welcomePage.vscode', "Visual Studio Code"))}</h1>
<p class="subtitle">${escape(localize('welcomePage.editingEvolved', "Editing evolved"))}</p>
</div>
<div class="row">
<div class="splash">
<div class="section start">
<h2>${escape(localize('welcomePage.start', "Start"))}</h2>
<ul>
<li><a href="command:workbench.action.files.newUntitledFile">${escape(localize('welcomePage.newFile', "New file"))}</a></li>
<li class="mac-only"><a href="command:workbench.action.files.openFileFolder">${escape(localize('welcomePage.openFolder', "Open folder..."))}</a></li>
<li class="windows-only linux-only"><a href="command:workbench.action.files.openFolder">${escape(localize('welcomePage.openFolder', "Open folder..."))}</a></li>
<li><a href="command:git.clone">${escape(localize('welcomePage.cloneGitRepository', "Clone Git repository..."))}</a></li>
</ul>
</div>
<div class="section recent">
<h2>${escape(localize('welcomePage.recent', "Recent"))}</h2>
<ul class="list">
<!-- Filled programmatically -->
<li class="moreRecent"><a href="command:workbench.action.openRecent">${escape(localize('welcomePage.moreRecent', "More..."))}</a><span class="path if_shortcut" data-command="workbench.action.openRecent">(<span class="shortcut" data-command="workbench.action.openRecent"></span>)</span></li>
</ul>
<p class="none">${escape(localize('welcomePage.noRecentFolders', "No recent folders"))}</p>
</div>
<div class="section help">
<h2>${escape(localize('welcomePage.help', "Help"))}</h2>
<ul>
<li class="keybindingsReferenceLink"><a href="command:workbench.action.keybindingsReference">${escape(localize('welcomePage.keybindingsCheatsheet', "Printable keyboard cheatsheet"))}</a></li>
<li><a href="command:workbench.action.openIntroductoryVideosUrl">${escape(localize('welcomePage.introductoryVideos', "Introductory videos"))}</a></li>
<li><a href="command:workbench.action.openDocumentationUrl">${escape(localize('welcomePage.productDocumentation', "Product documentation"))}</a></li>
<li><a href="https://github.com/Microsoft/vscode">${escape(localize('welcomePage.gitHubRepository', "GitHub repository"))}</a></li>
<li><a href="http://stackoverflow.com/questions/tagged/vscode?sort=votes&pageSize=50">${escape(localize('welcomePage.stackOverflow', "Stack Overflow"))}</a></li>
</ul>
</div>
<p class="showOnStartup"><input type="checkbox" id="showOnStartup"> <label for="showOnStartup">${escape(localize('welcomePage.showOnStartup', "Show welcome page on startup"))}</label></p>
</div>
<div class="commands">
<div class="section customize">
<h2>${escape(localize('welcomePage.customize', "Customize"))}</h2>
<ul>
<li class="showExtensionPacks"><button data-href="command:workbench.extensions.action.showExtensionPacks"><h3>${escape(localize('welcomePage.installExtensionPacks', "Tools and languages"))}</h3> <span>${escape(localize('welcomePage.installExtensionPacksDescription', "Install support for {0} and {1}"))
.replace('{0}', `<span class="extensionPackList"></span>`)
.replace('{1}', `<a href="command:workbench.extensions.action.showExtensionPacks">${escape(localize('welcomePage.moreExtensions', "more"))}</a>`)}
</span></button></li>
<li class="showRecommendedKeymapExtensions"><button data-href="command:workbench.extensions.action.showRecommendedKeymapExtensions"><h3>${escape(localize('welcomePage.installKeymapDescription', "Install keyboard shortcuts"))}</h3> <span>${escape(localize('welcomePage.installKeymapExtension', "Install the keyboard shortcuts of {0} and {1}"))
.replace('{0}', `<span class="keymapList"></span>`)
.replace('{1}', `<a href="command:workbench.extensions.action.showRecommendedKeymapExtensions">${escape(localize('welcomePage.others', "others"))}</a>`)}
</span></button></li>
<li class="selectTheme"><button data-href="command:workbench.action.selectTheme"><h3>${escape(localize('welcomePage.colorTheme', "Color theme"))}</h3> <span>${escape(localize('welcomePage.colorThemeDescription', "Make the editor and your code look the way you love"))}</span></button></li>
</ul>
</div>
<div class="section learn">
<h2>${escape(localize('welcomePage.learn', "Learn"))}</h2>
<ul>
<li class="showCommands"><button data-href="command:workbench.action.showCommands"><h3>${escape(localize('welcomePage.showCommands', "Find and run all commands"))}</h3> <span>${escape(localize('welcomePage.showCommandsDescription', "Rapidly access and search commands from the control panel ({0})")).replace('{0}', '<span class="shortcut" data-command="workbench.action.showCommands"></span>')}</span></button></li>
<li class="showInterfaceOverview"><button data-href="command:workbench.action.showInterfaceOverview"><h3>${escape(localize('welcomePage.interfaceOverview', "Interface overview"))}</h3> <span>${escape(localize('welcomePage.interfaceOverviewDescription', "Get a visual overlay highlighting the major components of the UI"))}</span></button></li>
<li class="showInteractivePlayground"><button data-href="command:workbench.action.showInteractivePlayground"><h3>${escape(localize('welcomePage.interactivePlayground', "Interactive playground"))}</h3> <span>${escape(localize('welcomePage.interactivePlaygroundDescription', "Try essential editor features out in a short walkthrough"))}</span></button></li>
</ul>
</div>
<div class="section quickLinks">
<h2>${escape(localize('welcomePage.quickLinks', "Quick links"))}</h2>
<ul>
<li class="keybindingsReference"><button data-href="command:workbench.action.keybindingsReference"><h3>${escape(localize('welcomePage.keybindingsReference', "Keyboard shortcuts reference"))}</h3> <span>${escape(localize('welcomePage.keybindingsReferenceDescription', "A printable PDF with the most common keyboard shortcuts"))}</span></button></li>
<li class="openGlobalSettings"><button data-href="command:workbench.action.openGlobalSettings"><h3>${escape(localize('welcomePage.configureSettings', "Configure settings"))}</h3> <span>${escape(localize('welcomePage.configureSettingsDescription', "Unlock the full power of VS Code by tweaking the settings"))}</span></button></li>
</ul>
</div>
</div>
</div>
</div>
</div>
`;