當前位置: 首頁>>代碼示例>>TypeScript>>正文


TypeScript he.encode函數代碼示例

本文整理匯總了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;未經允許,請勿轉載。