Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

Example Analysis of automatic recognition and loading of scripting language by SyntaxHighlighter

2025-01-15 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

Shulou(Shulou.com)06/03 Report--

Today, I will talk to you about the example analysis of SyntaxHighlighter automatic recognition and loading scripting language, which may not be well understood by many people. in order to make you understand better, the editor has summarized the following content for you. I hope you can get something according to this article.

SyntaxHighlighter is a JS plug-in written in JavaScript that supports syntax highlighting in multiple programming languages and is used by many large websites or blogs.

By default, the SyntaxHighlighter plug-in loads the corresponding JS libraries for each programming language, so how to implement SyntaxHighlighter to automatically load the JS libraries of different languages?

SyntaxHighlighter has officially given a solution to the shAutoloader.js autoload library.

Reference the SyntaxHighlighter core runtime in the HTML file

Hello SyntaxHighlighter

Core runtime of the shCore.js SyntaxHighlighter plug-in

This file must be introduced into the shAutoloader.js automatic loading runtime to achieve automatic loading.

ShCore.css Core CSS style

ShCoreDefault.css theme CSS style

The above four files must be referenced into the document

Please enter the code that needs to be highlighted.

The code is as follows:

Hello SyntaxHighlighter Hello SyntaxHighlighterfunction helloSyntaxHighlighter () {return "hi!";}

The class= "brush: js;" in is based on the display code language

The following is the main code that implements the automatic loading of SyntaxHighlighter

Function path () {var args = arguments, result = []; for (var I = 0; I < args.length; iTunes +) result.push (args [I] .replace ('@','/ pub/sh/current/scripts/')); / / replace with the specific path of SyntaxHighlighter in your project return result} 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 ()

The above is the code for SyntaxHighlighter to automatically recognize the language and automatically load the language library. Students who need it can test it.

After reading the above, do you have any further understanding of the example analysis of SyntaxHighlighter automatically recognizing and loading scripting languages? If you want to know more knowledge or related content, please follow the industry information channel, thank you for your support.

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Development

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report