SyntaxHighlighter 頁面動態js載入方式整理

龐順龍發表於2019-05-11

SyntaxHighlighter 頁面動態js載入方式整理

首先頁面引用外掛js檔案:


單獨的js處理,直接貼程式碼,如下:

function HighLine() {
    SyntaxHighlighter.config.clipboardSwf = '../Syntaxhighlighter/src/clipboard.swf';
    SyntaxHighlighter.autoloader(
    ['applescript', '../Syntaxhighlighter/scripts/shBrushAppleScript.js'],
    ['actionscript3', 'as3', '../Syntaxhighlighter/scripts/shBrushAS3.js'],
    ['bash', 'shell', '../Syntaxhighlighter/scripts/shBrushBash.js'],
    ['coldfusion', 'cf', '../Syntaxhighlighter/scripts/shBrushColdFusion.js'],
    ['cpp', 'c', '../Syntaxhighlighter/scripts/shBrushCpp.js'],
    ['c#', 'c-sharp', 'csharp', '../Syntaxhighlighter/scripts/shBrushCSharp.js'],
    ['css', '../Syntaxhighlighter/scripts/shBrushCss.js'],
    ['delphi', 'pascal', '../Syntaxhighlighter/scripts/shBrushDelphi.js'],
    ['diff', 'patch', 'pas', '../Syntaxhighlighter/scripts/shBrushDiff.js'],
    ['erl', 'erlang', '../Syntaxhighlighter/scripts/shBrushErlang.js'],
    ['groovy', '../Syntaxhighlighter/scripts/shBrushGroovy.js'],
    ['java', '../Syntaxhighlighter/scripts/shBrushJava.js'],
    ['jfx', 'javafx', '../Syntaxhighlighter/scripts/shBrushJavaFX.js'],
    ['js', 'jscript', 'javascript', '../Syntaxhighlighter/scripts/shBrushJScript.js'],
    ['perl', 'pl', '../Syntaxhighlighter/scripts/shBrushPerl.js'],
    ['php', '../Syntaxhighlighter/scripts/shBrushPhp.js'],
    ['text', 'plain', '../Syntaxhighlighter/scripts/shBrushPlain.js'],
    ['py', 'python', '../Syntaxhighlighter/scripts/shBrushPython.js'],
    ['ruby', 'rails', 'ror', 'rb', '../Syntaxhighlighter/scripts/shBrushRuby.js'],
    ['sass', 'scss', '../Syntaxhighlighter/scripts/shBrushSass.js'],
    ['scala', '../Syntaxhighlighter/scripts/shBrushScala.js'],
    ['sql', '../Syntaxhighlighter/scripts/shBrushSql.js'],
    ['vb', 'vbnet', '../Syntaxhighlighter/scripts/shBrushVb.js'],
    ['xml', 'xhtml', 'xslt', 'html', '../Syntaxhighlighter/scripts/shBrushXml.js']
    );

    SyntaxHighlighter.all();
}

$(function () {
	//載入高亮js
    HighLine(); 
})

龐順龍最後編輯於:4年前

內容均為作者獨立觀點,不代表八零IT人立場,如涉及侵權,請及時告知。

相關文章