本文整理汇总了TypeScript中he.encode函数的典型用法代码示例。如果您正苦于以下问题:TypeScript encode函数的具体用法?TypeScript encode怎么用?TypeScript encode使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了encode函数的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的TypeScript代码示例。
示例1: function
this.renderer.link = function(href, title, text) {
if (!href) {
return marked.Renderer.prototype.link.call(this, href, title, text);
}
if (this.options.sanitize) {
try {
const prot = decodeURIComponent(unescape(href))
.replace(/[^\w:]/g, '')
.toLowerCase();
if (prot.startsWith('javascript:') || prot.startsWith('vbscript:')) {
return '';
}
} catch (e) {
return '';
}
}
let onclick = 'cancelClick(event)';
if (href.startsWith('http://') || href.startsWith('https://')) {
onclick = 'openLinkWithExternalBrowser(event)';
} else if (re_ext.test(href)) {
onclick = 'openMarkdownLink(event)';
} else if (href.indexOf('#') !== -1) {
onclick = 'openHashLink(event)';
}
self.link_id += 1;
const id = `md-link-${self.link_id}`;
self.tooltips += `<paper-tooltip for="${id}" offset="0">${he.encode(href)}</paper-tooltip>`;
return title !== null ?
`<a id="${id}" href="${href}" onclick="${onclick}" title=${title}>${text}</a>` :
`<a id="${id}" href="${href}" onclick="${onclick}">${text}</a>`;
};
开发者ID:WondermSwift,项目名称:Shiba,代码行数:35,代码来源:markdown-preview.ts
示例2: commandPaletteFormatEntry
function commandPaletteFormatEntry(entry: CommandMenuItem, selected: boolean, extraClassString = ""): string {
return `<div class='${PopDownListPicker.CLASS_RESULT_ENTRY} ${selected ? PopDownListPicker.CLASS_RESULT_SELECTED : ""} ${extraClassString}' ${PopDownListPicker.ATTR_DATA_ID}='${entry.id}'>
<div class='${CLASS_RESULT_ICON_LEFT}'>${commandPaletteFormatIcon(entry.iconLeft)}</div>
<div class='${CLASS_RESULT_ICON_RIGHT}'>${commandPaletteFormatIcon(entry.iconRight)}</div>
<div class='${CLASS_RESULT_LABEL}'>${he.encode(entry.label)}</div>
<div class='${CLASS_RESULT_SHORTCUT}'>${entry.shortcut !== undefined && entry.shortcut !== null ? he.encode(entry.shortcut) : ""}</div>
</div>`;
}
开发者ID:mathpunk,项目名称:extraterm,代码行数:8,代码来源:CommandPaletteFunctions.ts
示例3: parseSrcSet
opts => {
const parsed = parseSrcSet(he.decode(opts.srcset));
const firstCandidate: { url?: string } = parsed[0];
const { url } = firstCandidate || { url: null };
let encodedUrl = '';
// Must re-encode url prior to comparison with expected string.
if (url !== null) {
encodedUrl = he.encode(url);
} else {
encodedUrl = '';
}
expect(encodedUrl).toStrictEqual(opts.expect);
},
开发者ID:growcss,项目名称:growcss,代码行数:16,代码来源:srcset-parser.ts
示例4: generateStackblitzContent
function generateStackblitzContent(componentName, demoName) {
const fileName = `${componentName}-${demoName}`;
const basePath = `demo/src/app/components/${componentName}/demos/${demoName}/${fileName}`;
const codeContent = fs.readFileSync(`${basePath}.ts`).toString();
const markupContent = fs.readFileSync(`${basePath}.html`).toString();
return `<!DOCTYPE html>
<html lang="en">
<body>
<form id="mainForm" method="post" action="${stackblitzUrl}">
<input type="hidden" name="description" value="Example usage of the ${componentName} widget from https://ng-bootstrap.github.io">
${generateTags(['Angular', 'Bootstrap', 'ng-bootstrap', capitalize(componentName)])}
<input type="hidden" name="files[.angular-cli.json]" value="${he.encode(getStackblitzTemplate('.angular-cli.json'))}">
<input type="hidden" name="files[index.html]" value="${he.encode(generateIndexHtml())}">
<input type="hidden" name="files[main.ts]" value="${he.encode(getStackblitzTemplate('main.ts'))}">
<input type="hidden" name="files[polyfills.ts]" value="${he.encode(getStackblitzTemplate('polyfills.ts'))}">
<input type="hidden" name="files[styles.css]" value="${he.encode(generateDemosCSS())}">
<input type="hidden" name="files[app/app.module.ts]" value="${he.encode(generateAppModuleTsContent(componentName, demoName, basePath + '.ts'))}">
<input type="hidden" name="files[app/app.component.ts]" value="${he.encode(getStackblitzTemplate('app/app.component.ts'))}">
<input type="hidden" name="files[app/app.component.html]" value="${he.encode(generateAppComponentHtmlContent(componentName, demoName))}">
<input type="hidden" name="files[app/${fileName}.ts]" value="${he.encode(codeContent)}">
<input type="hidden" name="files[app/${fileName}.html]" value="${he.encode(markupContent)}">
<input type="hidden" name="dependencies" value="${he.encode(JSON.stringify(generateDependencies()))}">
</form>
<script>document.getElementById("mainForm").submit();</script>
</body>
</html>`;
}
开发者ID:ExFlo,项目名称:ng-boostrap,代码行数:31,代码来源:generate-stackblitzes.ts
示例5: highlight
let mermaid: any = undefined;
marked.setOptions({
langPrefix: 'hljs ',
highlight(code: string, lang: string): string {
if (lang === undefined) {
return code;
}
if (lang === 'mermaid') {
if (mermaid === undefined) {
mermaid = require('mermaid');
mermaid.init(undefined, 'div.mermaid');
}
return '<div class="mermaid">' + he.encode(code) + '</div>';
}
if (lang === 'katex') {
return '<div class="katex">' + katex.renderToString(code, { displayMode: true }) + '</div>';
}
try {
return highlight(lang, code).value;
} catch (e) {
console.log('Error on highlight: ' + e.message);
return code;
}
},
// @ts-ignore: emoji is a dedicated method added by my fork
开发者ID:Sheshouzuo,项目名称:Shiba,代码行数:31,代码来源:markdown-preview.ts
注:本文中的he.encode函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论