Syntaxhighlighter-autoloader (auto load)

Source: Internet
Author: User
Tags autoloader

Because the use of syntaxhighlighter will be used in many languages, one must load all the language configuration file download will be more, so Syntaxhighlighter provides a shautoloader.js script. This site is in use, the site code is as follows:

1234567891011121314151617181920212223242526272829303132333435363738394041 <script type="text/javascript"src="/Themes/BootStrap/scripts/Syntaxhighlighter/scripts/shCore.js"></script><script type="text/javascript"src="/Themes/BootStrap/scripts/Syntaxhighlighter/scripts/shAutoloader.js"></script><link type="text/css"rel="stylesheet"href="/Themes/BootStrap/scripts/Syntaxhighlighter/styles/shCoreDefault.css"/><script type="text/javascript">    functionpath() {        var args = arguments,        result = [];        for(vari = 0; i < args.length; i++)            result.push(args[i].replace(‘$‘‘/Themes/BootStrap/scripts/Syntaxhighlighter/scripts/‘));        returnresult    }    $(function() {        SyntaxHighlighter.autoloader.apply(null, path(            ‘applescript            $shBrushAppleScript.js‘,            ‘actionscript3 as3      $shBrushAS3.js‘,            ‘bash shell             $shBrushBash.js‘,            ‘coldfusion cf          $shBrushColdFusion.js‘,            ‘cpp c                  $shBrushCpp.js‘,            ‘c# c-sharp csharp      $shBrushCSharp.js‘,            ‘css                    $shBrushCss.js‘,            ‘delphi pascal          $shBrushDelphi.js‘,            ‘diff patch pas         $shBrushDiff.js‘,            ‘erl erlang             $shBrushErlang.js‘,            ‘groovy                 $shBrushGroovy.js‘,            ‘java                   $shBrushJava.js‘,            ‘jfx javafx             $shBrushJavaFX.js‘,            ‘js jscript javascript  $shBrushJScript.js‘,            ‘perl pl                $shBrushPerl.js‘,            ‘php                    $shBrushPhp.js‘,            ‘text plain             $shBrushPlain.js‘,            ‘py python              $shBrushPython.js‘,            ‘ruby rails ror rb      $shBrushRuby.js‘,            ‘sass scss              $shBrushSass.js‘,            ‘scala                  $shBrushScala.js‘,            ‘sql                    $shBrushSql.js‘,            ‘vb vbnet               $shBrushVb.js‘,            ‘xml xhtml xslt html    $shBrushXml.js‘        ));        SyntaxHighlighter.all();    }</script>

However, the article detail page often does not have any code, so these JS files and JS code need to determine whether to execute:

1234567 //判断文章是否需要加载代码高亮插件var isCode = Model.Html.ToString().Contains("<pre class=\"brush:");@{    if(isCode){        //这里放置上面的js文件链接以及js代码。    }}

This article from: http://www.itdos.com/JavaScript/20150303/0135261.html reproduced please keep this text, thank you!

Syntaxhighlighter-autoloader (auto load)

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.